This commit is contained in:
2025-10-06 13:59:59 -05:00
parent bacd0e6e39
commit ea50d893d4
5 changed files with 106 additions and 11 deletions

View File

@@ -31,8 +31,6 @@ elseif(DUSK_TARGET_SYSTEM STREQUAL "psp")
DISPLAY_SDL2=1
DISPLAY_WINDOW_WIDTH_DEFAULT=480
DISPLAY_WINDOW_HEIGHT_DEFAULT=272
DISPLAY_WIDTH=480
DISPLAY_HEIGHT=272
DISPLAY_SIZE_DYNAMIC=0
)
endif()

View File

@@ -12,6 +12,7 @@
#include "display/spritebatch/spritebatch.h"
#include "display/mesh/quad.h"
#include "game/game.h"
#include "display/screen.h"
display_t DISPLAY;
@@ -71,6 +72,7 @@ errorret_t displayInit(void) {
quadInit();
frameBufferInitBackbuffer();
spriteBatchInit();
screenInit();
errorOk();
}
@@ -106,11 +108,19 @@ errorret_t displayUpdate(void) {
SDL_GL_MakeCurrent(DISPLAY.window, DISPLAY.glContext);
#endif
// Reset state
spriteBatchClear();
frameBufferBind(NULL);
// Bind screen and render scene
screenBind();
sceneManagerRender();
// Finish up
spriteBatchFlush();
screenUnbind();
screenRender();
#if DISPLAY_SDL2
SDL_GL_SwapWindow(DISPLAY.window);
@@ -127,6 +137,7 @@ errorret_t displayUpdate(void) {
errorret_t displayDispose(void) {
spriteBatchDispose();
screenDispose();
#if DISPLAY_SDL2
if(DISPLAY.glContext) {

View File

@@ -21,15 +21,8 @@
#error "Need to specify display backend."
#endif
#ifndef DISPLAY_WIDTH
#define DISPLAY_WIDTH 320
#endif
#ifndef DISPLAY_HEIGHT
#define DISPLAY_HEIGHT 240
#endif
#ifndef DISPLAY_WINDOW_WIDTH_DEFAULT
#define DISPLAY_WINDOW_WIDTH_DEFAULT DISPLAY_WIDTH
#error "DISPLAY_WINDOW_WIDTH_DEFAULT must be defined."
#endif
#ifndef DISPLAY_WINDOW_HEIGHT_DEFAULT
#define DISPLAY_WINDOW_HEIGHT_DEFAULT DISPLAY_HEIGHT

30
src/display/screen.c Normal file
View File

@@ -0,0 +1,30 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#include "screen.h"
#include "assert/assert.h"
#include "util/memory.h"
void screenInit() {
memoryZero(&SCREEN, sizeof(screen_t));
}
void screenBind() {
// Assume framebuffer is already unbound
}
void screenUnbind() {
}
void screenRender() {
}
void screenDispose() {
}

63
src/display/screen.h Normal file
View File

@@ -0,0 +1,63 @@
/**
* Copyright (c) 2025 Dominic Masters
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
#pragma once
#include "dusk.h"
typedef enum {
SCREEN_MODE_BACKBUFFER,
#if DISPLAY_SIZE_DYNAMIC == 1
#endif
// SCREEN_MODE_FIXED_ASPECT,
// SCREEN_MODE_FIXED_ASPECT_INTEGER,
// SCREEN_MODE_FIXED_HEIGHT,
// SCREEN_MODE_FIXED_HEIGHT_INTEGER,
// SCREEN_MODE_FIXED_WIDTH,
// SCREEN_MODE_FIXED_WIDTH_INTEGER,
// SCREEN_MODE_SUPER_RESOLUTION_HEIGHT,
// SCREEN_MODE_SUPER_RESOLUTION_WIDTH
} screenmode_t;
typedef struct {
screenmode_t mode;
// Calculated dimensions of the viewport, to be used by the camera
int32_t width;
int32_t height;
union {
};
} 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();