diff --git a/CMakeLists.txt b/CMakeLists.txt index c3322eb3..483b965c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the wi set(BACKEND_RENDERER "SDLTexture" CACHE STRING "Which renderer the game should use: 'OpenGL3' for an OpenGL 3.2 renderer, 'OpenGLES2' for an OpenGL ES 2.0 renderer, 'SDLTexture' for SDL2's hardware-accelerated Texture API, 'SDLSurface' for SDL2's software-rendered Surface API, or 'Software' for a handwritten software renderer") set(BACKEND_AUDIO "SDL2" CACHE STRING "Which audio backend the game should use: 'SDL2', 'miniaudio', or 'Null'") -set(BACKEND_PLATFORM "SDL2" CACHE STRING "Which platform backend the game should use: 'SDL2' or 'GLFW3'") +set(BACKEND_PLATFORM "SDL2" CACHE STRING "Which platform backend the game should use: 'SDL2', 'GLFW3', or 'Null'") option(LTO "Enable link-time optimisation" OFF) option(PKG_CONFIG_STATIC_LIBS "On platforms with pkg-config, static-link the dependencies (good for Windows builds, so you don't need to bundle DLL files)" OFF) @@ -350,6 +350,11 @@ elseif(BACKEND_PLATFORM MATCHES "GLFW3") "src/Backends/GLFW3/Misc.cpp" "src/Backends/GLFW3/Window.h" ) +elseif(BACKEND_PLATFORM MATCHES "Null") + target_sources(CSE2 PRIVATE + "src/Backends/Null/Controller.cpp" + "src/Backends/Null/Misc.cpp" + ) endif() if(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "OpenGL3") @@ -366,6 +371,8 @@ elseif(BACKEND_PLATFORM MATCHES "GLFW3" AND BACKEND_RENDERER MATCHES "OpenGLES2" target_sources(CSE2 PRIVATE "src/Backends/GLFW3/Window-OpenGLES2.cpp") elseif(BACKEND_PLATFORM MATCHES "GLFW3" AND BACKEND_RENDERER MATCHES "Software") target_sources(CSE2 PRIVATE "src/Backends/GLFW3/Window-Software.cpp") +elseif(BACKEND_PLATFORM MATCHES "Null" AND BACKEND_RENDERER MATCHES "Software") + target_sources(CSE2 PRIVATE "src/Backends/Null/Window-Software.cpp") else() message(FATAL_ERROR "Invalid BACKEND_PLATFORM/BACKEND_RENDERER combination") endif() diff --git a/src/Backends/Null/Controller.cpp b/src/Backends/Null/Controller.cpp new file mode 100644 index 00000000..65359a8f --- /dev/null +++ b/src/Backends/Null/Controller.cpp @@ -0,0 +1,21 @@ +#include "../Controller.h" + +bool ControllerBackend_Init(void) +{ + return false; +} + +void ControllerBackend_Deinit(void) +{ + +} + +bool ControllerBackend_GetJoystickStatus(bool **buttons, unsigned int *button_count, short **axes, unsigned int *axis_count) +{ + (void)buttons; + (void)button_count; + (void)axes; + (void)axis_count; + + return false; +} diff --git a/src/Backends/Null/Misc.cpp b/src/Backends/Null/Misc.cpp new file mode 100644 index 00000000..c4005d9b --- /dev/null +++ b/src/Backends/Null/Misc.cpp @@ -0,0 +1,89 @@ +#include "../Misc.h" + +bool Backend_Init(void) +{ + return true; +} + +void Backend_Deinit(void) +{ + +} + +void Backend_PostWindowCreation(void) +{ + +} + +bool Backend_GetBasePath(char *string_buffer) +{ + (void)string_buffer; + + return false; +} + +void Backend_HideMouse(void) +{ + +} + +void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height) +{ + (void)rgb_pixels; + (void)width; + (void)height; +} + +void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height) +{ + (void)rgb_pixels; + (void)width; + (void)height; +} + +void PlaybackBackend_EnableDragAndDrop(void) +{ + +} + +bool Backend_SystemTask(bool active) +{ + (void)active; + + return true; +} + +void Backend_GetKeyboardState(bool *keyboard_state) +{ + (void)keyboard_state; +} + +void Backend_ShowMessageBox(const char *title, const char *message) +{ + (void)title; + (void)message; +} + +ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintError(const char *format, ...) +{ + (void)format; +} + +ATTRIBUTE_FORMAT_PRINTF(1, 2) void Backend_PrintInfo(const char *format, ...) +{ + (void)format; +} + +unsigned long Backend_GetTicks(void) +{ + static unsigned long fake_ticks = 0; + + fake_ticks += 1000 / 50; + + return fake_ticks; +} + +void Backend_Delay(unsigned int ticks) +{ + (void)ticks; +} diff --git a/src/Backends/Null/Window-Software.cpp b/src/Backends/Null/Window-Software.cpp new file mode 100644 index 00000000..3b58955e --- /dev/null +++ b/src/Backends/Null/Window-Software.cpp @@ -0,0 +1,39 @@ +#include "../Window-Software.h" + +#include +#include + +static unsigned char *framebuffer; + +unsigned char* WindowBackend_Software_CreateWindow(const char *window_title, int screen_width, int screen_height, bool fullscreen, size_t *pitch) +{ + (void)window_title; + (void)fullscreen; + + framebuffer = (unsigned char*)malloc(screen_width * screen_height * 3); + + if (framebuffer != NULL) + { + *pitch = screen_width * 3; + + return framebuffer; + } + + return NULL; +} + +void WindowBackend_Software_DestroyWindow(void) +{ + free(framebuffer); +} + +void WindowBackend_Software_Display(void) +{ + +} + +void WindowBackend_Software_HandleWindowResize(unsigned int width, unsigned int height) +{ + (void)width; + (void)height; +}