diff --git a/src/display/CMakeLists.txt b/src/display/CMakeLists.txt index 3be4dcc..fdeb76e 100644 --- a/src/display/CMakeLists.txt +++ b/src/display/CMakeLists.txt @@ -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() \ No newline at end of file diff --git a/src/display/display.c b/src/display/display.c index 5dcb480..238aa79 100644 --- a/src/display/display.c +++ b/src/display/display.c @@ -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) { diff --git a/src/display/displaydefs.h b/src/display/displaydefs.h index d25e14e..5976320 100644 --- a/src/display/displaydefs.h +++ b/src/display/displaydefs.h @@ -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 diff --git a/src/display/screen.c b/src/display/screen.c new file mode 100644 index 0000000..7e1f524 --- /dev/null +++ b/src/display/screen.c @@ -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() { + +} \ No newline at end of file diff --git a/src/display/screen.h b/src/display/screen.h new file mode 100644 index 0000000..d97c1d9 --- /dev/null +++ b/src/display/screen.h @@ -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(); \ No newline at end of file