Files
dusk/src/display/screen.h
Dominic Masters 9aaf271996
Some checks failed
Build Dusk / build-linux (push) Failing after 50s
Build Dusk / build-psp (push) Failing after 1m1s
fixing some stuff but nothing really.
2025-11-28 10:45:07 -06:00

105 lines
2.1 KiB
C

/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
#include "display/framebuffer.h"
#include "display/camera.h"
#include "display/mesh/quad.h"
#if DISPLAY_SIZE_DYNAMIC == 1
#ifndef DISPLAY_SCREEN_HEIGHT_DEFAULT
#error "DISPLAY_SCREEN_HEIGHT_DEFAULT must be defined when DISPLAY_SIZE_DYNAMIC is enabled."
#endif
#endif
typedef enum {
SCREEN_MODE_BACKBUFFER,
#if DISPLAY_SIZE_DYNAMIC == 1
SCREEN_MODE_FIXED_SIZE,
SCREEN_MODE_ASPECT_RATIO,// Maintains aspect at all cost
SCREEN_MODE_FIXED_HEIGHT, // Fixed height, width expands/contracts as needed
SCREEN_MODE_FIXED_WIDTH, // Fixed width, height expands/contracts as needed
// Fixed viewport height. Fixed height but higher resolution.
SCREEN_MODE_FIXED_VIEWPORT_HEIGHT,
#endif
} screenmode_t;
// typedef enum {
// SCREEN_SCALE_MODE_FILL,
// SCREEN_SCALE_MODE_INTEGER,
// SCREEN_SCALE_MODE_INEGER_OVERFLOW
// } screenscalemode_t;
typedef struct {
screenmode_t mode;
// screenscalemode_t scaleMode;
// Calculated dimensions of the viewport, to be used by the camera
int32_t width;
int32_t height;
float_t aspect;
#if DISPLAY_SIZE_DYNAMIC == 1
framebuffer_t framebuffer;
bool_t framebufferReady;
camera_t framebufferCamera;
mesh_t frameBufferMesh;
meshvertex_t frameBufferMeshVertices[QUAD_VERTEX_COUNT];
#endif
union {
struct {
int32_t width;
int32_t height;
} fixedSize;
struct {
float_t ratio;
} aspectRatio;
struct {
int32_t height;
} fixedHeight;
struct {
int32_t width;
} fixedWidth;
struct {
int32_t height;
} fixedViewportHeight;
};
} screen_t;
extern screen_t SCREEN;
/**
* Initializes the screen system.
*/
void screenInit();
/**
* Binds the screen, this is done before rendering game content.
*/
void screenBind();
/**
* Unbinds the screen, does nothing for now.
*/
void screenUnbind();
/**
* Renders the screen to the current framebuffer.
*/
void screenRender();
/**
* Disposes the screen system.
*/
void screenDispose();