Change 'PlatformBackend' namespace to 'Backend'
This commit is contained in:
parent
daf5d3cc7e
commit
135035bb1a
17 changed files with 105 additions and 105 deletions
|
@ -168,7 +168,7 @@ add_executable(CSE2 WIN32
|
||||||
"src/WindowsWrapper.h"
|
"src/WindowsWrapper.h"
|
||||||
"src/Backends/Audio.h"
|
"src/Backends/Audio.h"
|
||||||
"src/Backends/Controller.h"
|
"src/Backends/Controller.h"
|
||||||
"src/Backends/Platform.h"
|
"src/Backends/Misc.h"
|
||||||
"src/Backends/Rendering.h"
|
"src/Backends/Rendering.h"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -337,14 +337,14 @@ if(BACKEND_PLATFORM MATCHES "SDL2")
|
||||||
target_sources(CSE2 PRIVATE
|
target_sources(CSE2 PRIVATE
|
||||||
"src/Backends/SDL2/Controller.cpp"
|
"src/Backends/SDL2/Controller.cpp"
|
||||||
"src/Backends/SDL2/Controller.h"
|
"src/Backends/SDL2/Controller.h"
|
||||||
"src/Backends/SDL2/Platform.cpp"
|
"src/Backends/SDL2/Misc.cpp"
|
||||||
"src/Backends/SDL2/Platform.h"
|
"src/Backends/SDL2/Misc.h"
|
||||||
)
|
)
|
||||||
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
|
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
|
||||||
target_sources(CSE2 PRIVATE
|
target_sources(CSE2 PRIVATE
|
||||||
"src/Backends/GLFW3/Controller.cpp"
|
"src/Backends/GLFW3/Controller.cpp"
|
||||||
"src/Backends/GLFW3/Platform.cpp"
|
"src/Backends/GLFW3/Misc.cpp"
|
||||||
"src/Backends/GLFW3/Platform.h"
|
"src/Backends/GLFW3/Misc.h"
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "Platform.h"
|
#include "Misc.h"
|
||||||
|
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
|
@ -152,12 +152,12 @@ static void DragAndDropCallback(GLFWwindow *window, int count, const char **path
|
||||||
LoadProfile(paths[0]);
|
LoadProfile(paths[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_Init(void)
|
void Backend_Init(void)
|
||||||
{
|
{
|
||||||
glfwInit();
|
glfwInit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_Deinit(void)
|
void Backend_Deinit(void)
|
||||||
{
|
{
|
||||||
if (cursor != NULL)
|
if (cursor != NULL)
|
||||||
glfwDestroyCursor(cursor);
|
glfwDestroyCursor(cursor);
|
||||||
|
@ -165,7 +165,7 @@ void PlatformBackend_Deinit(void)
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_PostWindowCreation(void)
|
void Backend_PostWindowCreation(void)
|
||||||
{
|
{
|
||||||
// Hook callbacks
|
// Hook callbacks
|
||||||
glfwSetKeyCallback(window, KeyCallback);
|
glfwSetKeyCallback(window, KeyCallback);
|
||||||
|
@ -173,7 +173,7 @@ void PlatformBackend_PostWindowCreation(void)
|
||||||
glfwSetWindowSizeCallback(window, WindowSizeCallback);
|
glfwSetWindowSizeCallback(window, WindowSizeCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL PlatformBackend_GetBasePath(char *string_buffer)
|
BOOL Backend_GetBasePath(char *string_buffer)
|
||||||
{
|
{
|
||||||
(void)string_buffer;
|
(void)string_buffer;
|
||||||
|
|
||||||
|
@ -181,12 +181,12 @@ BOOL PlatformBackend_GetBasePath(char *string_buffer)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_HideMouse(void)
|
void Backend_HideMouse(void)
|
||||||
{
|
{
|
||||||
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_HIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
// Convert to RGBA, since that's the only think GLFW3 accepts
|
// Convert to RGBA, since that's the only think GLFW3 accepts
|
||||||
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
|
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
|
||||||
|
@ -214,7 +214,7 @@ void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
// Convert to RGBA, since that's the only think GLFW3 accepts
|
// Convert to RGBA, since that's the only think GLFW3 accepts
|
||||||
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
|
unsigned char *rgba_pixels = (unsigned char*)malloc(width * height * 4);
|
||||||
|
@ -258,7 +258,7 @@ void PlaybackBackend_EnableDragAndDrop(void)
|
||||||
glfwSetDropCallback(window, DragAndDropCallback);
|
glfwSetDropCallback(window, DragAndDropCallback);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL PlatformBackend_SystemTask(void)
|
BOOL Backend_SystemTask(void)
|
||||||
{
|
{
|
||||||
if (glfwWindowShouldClose(window))
|
if (glfwWindowShouldClose(window))
|
||||||
{
|
{
|
||||||
|
@ -276,18 +276,18 @@ BOOL PlatformBackend_SystemTask(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_ShowMessageBox(const char *title, const char *message)
|
void Backend_ShowMessageBox(const char *title, const char *message)
|
||||||
{
|
{
|
||||||
// GLFW3 doesn't have a message box
|
// GLFW3 doesn't have a message box
|
||||||
printf("ShowMessageBox - '%s' - '%s'\n", title, message);
|
printf("ShowMessageBox - '%s' - '%s'\n", title, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long PlatformBackend_GetTicks(void)
|
unsigned long Backend_GetTicks(void)
|
||||||
{
|
{
|
||||||
return (unsigned long)(glfwGetTime() * 1000.0);
|
return (unsigned long)(glfwGetTime() * 1000.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_Delay(unsigned int ticks)
|
void Backend_Delay(unsigned int ticks)
|
||||||
{
|
{
|
||||||
// GLFW3 doesn't have a delay function, so here's some butt-ugly C++11
|
// GLFW3 doesn't have a delay function, so here's some butt-ugly C++11
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(ticks));
|
std::this_thread::sleep_for(std::chrono::milliseconds(ticks));
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "Platform.h"
|
#include "Misc.h"
|
||||||
|
|
||||||
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)
|
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_width, int *screen_height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
|
@ -57,19 +57,19 @@ BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_wid
|
||||||
if (GLAD_GL_VERSION_3_2)
|
if (GLAD_GL_VERSION_3_2)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
PlatformBackend_PostWindowCreation();
|
Backend_PostWindowCreation();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#ifndef USE_OPENGLES2
|
#ifndef USE_OPENGLES2
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Your system does not support OpenGL 3.2");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Your system does not support OpenGL 3.2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not load OpenGL functions");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not load OpenGL functions");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_wid
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -87,15 +87,15 @@ extern BOOL bActive;
|
||||||
extern BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
extern BOOL backend_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
extern BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
extern BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
|
|
||||||
void PlatformBackend_Init(void);
|
void Backend_Init(void);
|
||||||
void PlatformBackend_Deinit(void);
|
void Backend_Deinit(void);
|
||||||
void PlatformBackend_PostWindowCreation(void);
|
void Backend_PostWindowCreation(void);
|
||||||
BOOL PlatformBackend_GetBasePath(char *string_buffer);
|
BOOL Backend_GetBasePath(char *string_buffer);
|
||||||
void PlatformBackend_HideMouse(void);
|
void Backend_HideMouse(void);
|
||||||
void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
||||||
void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height);
|
||||||
void PlaybackBackend_EnableDragAndDrop(void);
|
void PlaybackBackend_EnableDragAndDrop(void);
|
||||||
BOOL PlatformBackend_SystemTask(void);
|
BOOL Backend_SystemTask(void);
|
||||||
void PlatformBackend_ShowMessageBox(const char *title, const char *message);
|
void Backend_ShowMessageBox(const char *title, const char *message);
|
||||||
unsigned long PlatformBackend_GetTicks(void);
|
unsigned long Backend_GetTicks(void);
|
||||||
void PlatformBackend_Delay(unsigned int ticks);
|
void Backend_Delay(unsigned int ticks);
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "../Window-OpenGL.h"
|
#include "../Window-OpenGL.h"
|
||||||
#include "../../Resource.h"
|
#include "../../Resource.h"
|
||||||
|
|
||||||
|
@ -275,7 +275,7 @@ static GLuint CompileShader(const char *vertex_shader_source, const char *fragme
|
||||||
{
|
{
|
||||||
char buffer[0x200];
|
char buffer[0x200];
|
||||||
glGetShaderInfoLog(vertex_shader, sizeof(buffer), NULL, buffer);
|
glGetShaderInfoLog(vertex_shader, sizeof(buffer), NULL, buffer);
|
||||||
PlatformBackend_ShowMessageBox("Vertex shader error", buffer);
|
Backend_ShowMessageBox("Vertex shader error", buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -291,7 +291,7 @@ static GLuint CompileShader(const char *vertex_shader_source, const char *fragme
|
||||||
{
|
{
|
||||||
char buffer[0x200];
|
char buffer[0x200];
|
||||||
glGetShaderInfoLog(fragment_shader, sizeof(buffer), NULL, buffer);
|
glGetShaderInfoLog(fragment_shader, sizeof(buffer), NULL, buffer);
|
||||||
PlatformBackend_ShowMessageBox("Fragment shader error", buffer);
|
Backend_ShowMessageBox("Fragment shader error", buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -308,7 +308,7 @@ static GLuint CompileShader(const char *vertex_shader_source, const char *fragme
|
||||||
{
|
{
|
||||||
char buffer[0x200];
|
char buffer[0x200];
|
||||||
glGetProgramInfoLog(program_id, sizeof(buffer), NULL, buffer);
|
glGetProgramInfoLog(program_id, sizeof(buffer), NULL, buffer);
|
||||||
PlatformBackend_ShowMessageBox("Shader linker error", buffer);
|
Backend_ShowMessageBox("Shader linker error", buffer);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "../SDL2/Platform.h"
|
#include "../SDL2/Misc.h"
|
||||||
|
|
||||||
typedef struct RenderBackend_Surface
|
typedef struct RenderBackend_Surface
|
||||||
{
|
{
|
||||||
|
@ -57,7 +57,7 @@ Backend_Surface* RenderBackend_Init(const char *window_title, int screen_width,
|
||||||
|
|
||||||
if (framebuffer.sdlsurface != NULL)
|
if (framebuffer.sdlsurface != NULL)
|
||||||
{
|
{
|
||||||
PlatformBackend_PostWindowCreation();
|
Backend_PostWindowCreation();
|
||||||
|
|
||||||
return &framebuffer;
|
return &framebuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,8 +12,8 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "../SDL2/Platform.h"
|
#include "../SDL2/Misc.h"
|
||||||
#include "../../Draw.h"
|
#include "../../Draw.h"
|
||||||
#include "../../Ending.h"
|
#include "../../Ending.h"
|
||||||
#include "../../MapName.h"
|
#include "../../MapName.h"
|
||||||
|
@ -165,7 +165,7 @@ Backend_Surface* RenderBackend_Init(const char *window_title, int screen_width,
|
||||||
config.delete_texture_callback = GlyphBatch_DestroyTexture;
|
config.delete_texture_callback = GlyphBatch_DestroyTexture;
|
||||||
spritebatch_init(&glyph_batcher, &config, NULL);
|
spritebatch_init(&glyph_batcher, &config, NULL);
|
||||||
|
|
||||||
PlatformBackend_PostWindowCreation();
|
Backend_PostWindowCreation();
|
||||||
|
|
||||||
return &framebuffer;
|
return &framebuffer;
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,8 +8,8 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "../SDL2/Platform.h"
|
#include "../SDL2/Misc.h"
|
||||||
|
|
||||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
@ -56,20 +56,20 @@ Backend_Surface* RenderBackend_Init(const char *window_title, int screen_width,
|
||||||
framebuffer.height = framebuffer_sdlsurface->h;
|
framebuffer.height = framebuffer_sdlsurface->h;
|
||||||
framebuffer.pitch = framebuffer_sdlsurface->pitch;
|
framebuffer.pitch = framebuffer_sdlsurface->pitch;
|
||||||
|
|
||||||
PlatformBackend_PostWindowCreation();
|
Backend_PostWindowCreation();
|
||||||
|
|
||||||
return &framebuffer;
|
return &framebuffer;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (software rendering backend)", "Could not create framebuffer surface");
|
Backend_ShowMessageBox("Fatal error (software rendering backend)", "Could not create framebuffer surface");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (software rendering backend)", "Could not create window");
|
Backend_ShowMessageBox("Fatal error (software rendering backend)", "Could not create window");
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "Platform.h"
|
#include "Misc.h"
|
||||||
|
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
@ -30,7 +30,7 @@ BOOL backend_previous_keyboard_state[BACKEND_KEYBOARD_TOTAL];
|
||||||
static SDL_Surface *cursor_surface;
|
static SDL_Surface *cursor_surface;
|
||||||
static SDL_Cursor *cursor;
|
static SDL_Cursor *cursor;
|
||||||
|
|
||||||
void PlatformBackend_Init(void)
|
void Backend_Init(void)
|
||||||
{
|
{
|
||||||
SDL_Init(SDL_INIT_EVENTS);
|
SDL_Init(SDL_INIT_EVENTS);
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ void PlatformBackend_Init(void)
|
||||||
printf("Selected SDL2 video driver: %s\n", SDL_GetCurrentVideoDriver());
|
printf("Selected SDL2 video driver: %s\n", SDL_GetCurrentVideoDriver());
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_Deinit(void)
|
void Backend_Deinit(void)
|
||||||
{
|
{
|
||||||
if (cursor != NULL)
|
if (cursor != NULL)
|
||||||
SDL_FreeCursor(cursor);
|
SDL_FreeCursor(cursor);
|
||||||
|
@ -55,12 +55,12 @@ void PlatformBackend_Deinit(void)
|
||||||
SDL_Quit();
|
SDL_Quit();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_PostWindowCreation(void)
|
void Backend_PostWindowCreation(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL PlatformBackend_GetBasePath(char *string_buffer)
|
BOOL Backend_GetBasePath(char *string_buffer)
|
||||||
{
|
{
|
||||||
char *base_path = SDL_GetBasePath();
|
char *base_path = SDL_GetBasePath();
|
||||||
// Trim the trailing '/'
|
// Trim the trailing '/'
|
||||||
|
@ -72,19 +72,19 @@ BOOL PlatformBackend_GetBasePath(char *string_buffer)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_HideMouse(void)
|
void Backend_HideMouse(void)
|
||||||
{
|
{
|
||||||
SDL_ShowCursor(SDL_DISABLE);
|
SDL_ShowCursor(SDL_DISABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
void Backend_SetWindowIcon(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom((void*)rgb_pixels, width, height, 0, width * 3, SDL_PIXELFORMAT_RGB24);
|
SDL_Surface *surface = SDL_CreateRGBSurfaceWithFormatFrom((void*)rgb_pixels, width, height, 0, width * 3, SDL_PIXELFORMAT_RGB24);
|
||||||
SDL_SetWindowIcon(window, surface);
|
SDL_SetWindowIcon(window, surface);
|
||||||
SDL_FreeSurface(surface);
|
SDL_FreeSurface(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
void Backend_SetCursor(const unsigned char *rgb_pixels, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
cursor_surface = SDL_CreateRGBSurfaceWithFormatFrom((void*)rgb_pixels, width, height, 0, width * 3, SDL_PIXELFORMAT_RGB24);
|
cursor_surface = SDL_CreateRGBSurfaceWithFormatFrom((void*)rgb_pixels, width, height, 0, width * 3, SDL_PIXELFORMAT_RGB24);
|
||||||
SDL_SetColorKey(cursor_surface, SDL_TRUE, SDL_MapRGB(cursor_surface->format, 0xFF, 0, 0xFF));
|
SDL_SetColorKey(cursor_surface, SDL_TRUE, SDL_MapRGB(cursor_surface->format, 0xFF, 0, 0xFF));
|
||||||
|
@ -97,7 +97,7 @@ void PlaybackBackend_EnableDragAndDrop(void)
|
||||||
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
SDL_EventState(SDL_DROPFILE, SDL_ENABLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL PlatformBackend_SystemTask(void)
|
BOOL Backend_SystemTask(void)
|
||||||
{
|
{
|
||||||
memcpy(backend_previous_keyboard_state, backend_keyboard_state, sizeof(backend_keyboard_state));
|
memcpy(backend_previous_keyboard_state, backend_keyboard_state, sizeof(backend_keyboard_state));
|
||||||
|
|
||||||
|
@ -242,17 +242,17 @@ BOOL PlatformBackend_SystemTask(void)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_ShowMessageBox(const char *title, const char *message)
|
void Backend_ShowMessageBox(const char *title, const char *message)
|
||||||
{
|
{
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, window);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, title, message, window);
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned long PlatformBackend_GetTicks(void)
|
unsigned long Backend_GetTicks(void)
|
||||||
{
|
{
|
||||||
return SDL_GetTicks();
|
return SDL_GetTicks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_Delay(unsigned int ticks)
|
void Backend_Delay(unsigned int ticks)
|
||||||
{
|
{
|
||||||
SDL_Delay(ticks);
|
SDL_Delay(ticks);
|
||||||
}
|
}
|
|
@ -11,8 +11,8 @@
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "../Platform.h"
|
#include "../Misc.h"
|
||||||
#include "Platform.h"
|
#include "Misc.h"
|
||||||
#include "../../Resource.h"
|
#include "../../Resource.h"
|
||||||
|
|
||||||
static SDL_GLContext context;
|
static SDL_GLContext context;
|
||||||
|
@ -48,39 +48,39 @@ BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int *screen_wid
|
||||||
if (GLAD_GL_VERSION_3_2)
|
if (GLAD_GL_VERSION_3_2)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
PlatformBackend_PostWindowCreation();
|
Backend_PostWindowCreation();
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
#ifndef USE_OPENGLES2
|
#ifndef USE_OPENGLES2
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Your system does not support OpenGL 3.2");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Your system does not support OpenGL 3.2");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not load OpenGL functions");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not load OpenGL functions");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "SDL_GL_MakeCurrent failed");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "SDL_GL_MakeCurrent failed");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_GL_DeleteContext(context);
|
SDL_GL_DeleteContext(context);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create OpenGL context");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create OpenGL context");
|
||||||
}
|
}
|
||||||
|
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
|
Backend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Backends/Platform.h"
|
#include "Backends/Misc.h"
|
||||||
#include "Backends/Rendering.h"
|
#include "Backends/Rendering.h"
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
#include "CommonDefines.h"
|
#include "CommonDefines.h"
|
||||||
|
@ -59,12 +59,12 @@ BOOL Flip_SystemTask(void)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
// Framerate limiter
|
// Framerate limiter
|
||||||
timeNow = PlatformBackend_GetTicks();
|
timeNow = Backend_GetTicks();
|
||||||
|
|
||||||
if (timeNow >= timePrev + 20)
|
if (timeNow >= timePrev + 20)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
PlatformBackend_Delay(1);
|
Backend_Delay(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (timeNow >= timePrev + 100)
|
if (timeNow >= timePrev + 100)
|
||||||
|
|
18
src/Game.cpp
18
src/Game.cpp
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Backends/Platform.h"
|
#include "Backends/Misc.h"
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
#include "Back.h"
|
#include "Back.h"
|
||||||
#include "Boss.h"
|
#include "Boss.h"
|
||||||
|
@ -214,8 +214,8 @@ int ModeOpening(void)
|
||||||
++gCounter;
|
++gCounter;
|
||||||
}
|
}
|
||||||
|
|
||||||
wait = PlatformBackend_GetTicks();
|
wait = Backend_GetTicks();
|
||||||
while (PlatformBackend_GetTicks() < wait + 500)
|
while (Backend_GetTicks() < wait + 500)
|
||||||
{
|
{
|
||||||
CortBox(&grcGame, 0x000000);
|
CortBox(&grcGame, 0x000000);
|
||||||
PutFramePerSecound();
|
PutFramePerSecound();
|
||||||
|
@ -460,8 +460,8 @@ int ModeTitle(void)
|
||||||
ChangeMusic(MUS_SILENCE);
|
ChangeMusic(MUS_SILENCE);
|
||||||
|
|
||||||
// Black screen when option is selected
|
// Black screen when option is selected
|
||||||
wait = PlatformBackend_GetTicks();
|
wait = Backend_GetTicks();
|
||||||
while (PlatformBackend_GetTicks() < wait + 1000)
|
while (Backend_GetTicks() < wait + 1000)
|
||||||
{
|
{
|
||||||
CortBox(&grcGame, 0);
|
CortBox(&grcGame, 0);
|
||||||
PutFramePerSecound();
|
PutFramePerSecound();
|
||||||
|
@ -691,9 +691,9 @@ BOOL Game(void)
|
||||||
if (!LoadGenericData())
|
if (!LoadGenericData())
|
||||||
{
|
{
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
PlatformBackend_ShowMessageBox("エラー", "汎用ファイルが読めない");
|
Backend_ShowMessageBox("エラー", "汎用ファイルが読めない");
|
||||||
#else
|
#else
|
||||||
PlatformBackend_ShowMessageBox("Error", "Couldn't read general purpose files");
|
Backend_ShowMessageBox("Error", "Couldn't read general purpose files");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -707,9 +707,9 @@ BOOL Game(void)
|
||||||
if (!LoadNpcTable(path))
|
if (!LoadNpcTable(path))
|
||||||
{
|
{
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
PlatformBackend_ShowMessageBox("エラー", "NPCテーブルが読めない");
|
Backend_ShowMessageBox("エラー", "NPCテーブルが読めない");
|
||||||
#else
|
#else
|
||||||
PlatformBackend_ShowMessageBox("Error", "Couldn't read the NPC table");
|
Backend_ShowMessageBox("Error", "Couldn't read the NPC table");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
28
src/Main.cpp
28
src/Main.cpp
|
@ -7,7 +7,7 @@
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Backends/Platform.h"
|
#include "Backends/Misc.h"
|
||||||
#include "Backends/Rendering.h"
|
#include "Backends/Rendering.h"
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
#include "CommonDefines.h"
|
#include "CommonDefines.h"
|
||||||
|
@ -64,11 +64,11 @@ unsigned long GetFramePerSecound(void)
|
||||||
|
|
||||||
if (need_new_base_tick)
|
if (need_new_base_tick)
|
||||||
{
|
{
|
||||||
base_tick = PlatformBackend_GetTicks();
|
base_tick = Backend_GetTicks();
|
||||||
need_new_base_tick = FALSE;
|
need_new_base_tick = FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_tick = PlatformBackend_GetTicks();
|
current_tick = Backend_GetTicks();
|
||||||
++current_frame;
|
++current_frame;
|
||||||
|
|
||||||
if (base_tick + 1000 <= current_tick)
|
if (base_tick + 1000 <= current_tick)
|
||||||
|
@ -88,10 +88,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
PlatformBackend_Init();
|
Backend_Init();
|
||||||
|
|
||||||
// Get executable's path
|
// Get executable's path
|
||||||
if (!PlatformBackend_GetBasePath(gModulePath))
|
if (!Backend_GetBasePath(gModulePath))
|
||||||
{
|
{
|
||||||
// Fall back on argv[0] if the backend cannot provide a path
|
// Fall back on argv[0] if the backend cannot provide a path
|
||||||
strcpy(gModulePath, argv[0]);
|
strcpy(gModulePath, argv[0]);
|
||||||
|
@ -222,7 +222,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 0))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 0))
|
||||||
{
|
{
|
||||||
PlatformBackend_Deinit();
|
Backend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -230,7 +230,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 1))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 1))
|
||||||
{
|
{
|
||||||
PlatformBackend_Deinit();
|
Backend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -254,7 +254,7 @@ int main(int argc, char *argv[])
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2))
|
||||||
{
|
{
|
||||||
PlatformBackend_Deinit();
|
Backend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -264,7 +264,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
bFullscreen = TRUE;
|
bFullscreen = TRUE;
|
||||||
|
|
||||||
PlatformBackend_HideMouse();
|
Backend_HideMouse();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -282,7 +282,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (window_icon_rgb_pixels != NULL)
|
if (window_icon_rgb_pixels != NULL)
|
||||||
{
|
{
|
||||||
PlatformBackend_SetWindowIcon(window_icon_rgb_pixels, window_icon_width, window_icon_height);
|
Backend_SetWindowIcon(window_icon_rgb_pixels, window_icon_width, window_icon_height);
|
||||||
FreeBitmap(window_icon_rgb_pixels);
|
FreeBitmap(window_icon_rgb_pixels);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -296,7 +296,7 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
if (cursor_rgb_pixels != NULL)
|
if (cursor_rgb_pixels != NULL)
|
||||||
{
|
{
|
||||||
PlatformBackend_SetCursor(cursor_rgb_pixels, cursor_width, cursor_height);
|
Backend_SetCursor(cursor_rgb_pixels, cursor_width, cursor_height);
|
||||||
FreeBitmap(cursor_rgb_pixels);
|
FreeBitmap(cursor_rgb_pixels);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -319,7 +319,7 @@ int main(int argc, char *argv[])
|
||||||
// Draw to screen
|
// Draw to screen
|
||||||
if (!Flip_SystemTask())
|
if (!Flip_SystemTask())
|
||||||
{
|
{
|
||||||
PlatformBackend_Deinit();
|
Backend_Deinit();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -345,7 +345,7 @@ int main(int argc, char *argv[])
|
||||||
EndDirectSound();
|
EndDirectSound();
|
||||||
EndDirectDraw();
|
EndDirectDraw();
|
||||||
|
|
||||||
PlatformBackend_Deinit();
|
Backend_Deinit();
|
||||||
|
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -379,7 +379,7 @@ void JoystickProc(void);
|
||||||
|
|
||||||
BOOL SystemTask(void)
|
BOOL SystemTask(void)
|
||||||
{
|
{
|
||||||
if (!PlatformBackend_SystemTask())
|
if (!Backend_SystemTask())
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < BACKEND_KEYBOARD_TOTAL; ++i)
|
for (unsigned int i = 0; i < BACKEND_KEYBOARD_TOTAL; ++i)
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Backends/Platform.h"
|
#include "Backends/Misc.h"
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
#include "BossLife.h"
|
#include "BossLife.h"
|
||||||
#include "Fade.h"
|
#include "Fade.h"
|
||||||
|
@ -247,9 +247,9 @@ BOOL InitializeGame(void)
|
||||||
if (!TransferStage(13, 200, 10, 8))
|
if (!TransferStage(13, 200, 10, 8))
|
||||||
{
|
{
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
PlatformBackend_ShowMessageBox("エラー", "ステージの読み込みに失敗");
|
Backend_ShowMessageBox("エラー", "ステージの読み込みに失敗");
|
||||||
#else
|
#else
|
||||||
PlatformBackend_ShowMessageBox("Error", "Failed to load stage");
|
Backend_ShowMessageBox("Error", "Failed to load stage");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
|
@ -6,7 +6,7 @@
|
||||||
|
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Backends/Platform.h"
|
#include "Backends/Misc.h"
|
||||||
#include "ArmsItem.h"
|
#include "ArmsItem.h"
|
||||||
#include "Boss.h"
|
#include "Boss.h"
|
||||||
#include "BossLife.h"
|
#include "BossLife.h"
|
||||||
|
@ -726,9 +726,9 @@ int TextScriptProc(void)
|
||||||
if (!TransferStage(z, w, x, y))
|
if (!TransferStage(z, w, x, y))
|
||||||
{
|
{
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
PlatformBackend_ShowMessageBox("エラー", "ステージの読み込みに失敗");
|
Backend_ShowMessageBox("エラー", "ステージの読み込みに失敗");
|
||||||
#else
|
#else
|
||||||
PlatformBackend_ShowMessageBox("Error", "Failed to load stage");
|
Backend_ShowMessageBox("Error", "Failed to load stage");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return enum_ESCRETURN_exit;
|
return enum_ESCRETURN_exit;
|
||||||
|
@ -1283,10 +1283,10 @@ int TextScriptProc(void)
|
||||||
char str_0[0x40];
|
char str_0[0x40];
|
||||||
#ifdef JAPANESE
|
#ifdef JAPANESE
|
||||||
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
|
sprintf(str_0, "不明のコード:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
|
||||||
PlatformBackend_ShowMessageBox("エラー", str_0);
|
Backend_ShowMessageBox("エラー", str_0);
|
||||||
#else
|
#else
|
||||||
sprintf(str_0, "Unknown code:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
|
sprintf(str_0, "Unknown code:<%c%c%c", gTS.data[gTS.p_read + 1], gTS.data[gTS.p_read + 2], gTS.data[gTS.p_read + 3]);
|
||||||
PlatformBackend_ShowMessageBox("Error", str_0);
|
Backend_ShowMessageBox("Error", str_0);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return enum_ESCRETURN_exit;
|
return enum_ESCRETURN_exit;
|
||||||
|
|
Loading…
Add table
Reference in a new issue