Files
dusk/src/display/screen.h
2025-10-06 15:43:27 -05:00

81 lines
1.5 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/framebuffer.h"
#include "display/camera.h"
#include "display/mesh/quad.h"
typedef enum {
SCREEN_MODE_BACKBUFFER,
#if DISPLAY_SIZE_DYNAMIC == 1
SCREEN_MODE_ASPECT_RATIO,// Maintains aspect at all cost
SCREEN_MODE_FIXED_HEIGHT, // Fixed height, width expands/contracts as needed
#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;
#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 {
float_t ratio;
} aspectRatio;
struct {
int32_t height;
} fixedHeight;
};
} 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();