More refactoring
This commit is contained in:
parent
073712017f
commit
c4aa8e28bb
11 changed files with 177 additions and 338 deletions
|
@ -17,7 +17,6 @@ option(FIX_BUGS "Fix various bugs in the game" OFF)
|
||||||
option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF)
|
option(DEBUG_SAVE "Re-enable the ability to drag-and-drop save files onto the window" OFF)
|
||||||
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_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' or 'miniaudio'")
|
set(BACKEND_AUDIO "SDL2" CACHE STRING "Which audio backend the game should use: 'SDL2' or 'miniaudio'")
|
||||||
set(BACKEND_CONTROLLER "SDL2" CACHE STRING "Which controller backend the game should use: 'SDL2' or 'GLFW3'")
|
|
||||||
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' or 'GLFW3'")
|
||||||
|
|
||||||
option(LTO "Enable link-time optimisation" OFF)
|
option(LTO "Enable link-time optimisation" OFF)
|
||||||
|
@ -320,16 +319,10 @@ else()
|
||||||
message(FATAL_ERROR "Invalid BACKEND_AUDIO selected")
|
message(FATAL_ERROR "Invalid BACKEND_AUDIO selected")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BACKEND_CONTROLLER MATCHES "SDL2")
|
|
||||||
target_sources(CSE2 PRIVATE "src/Backends/Controller/SDL2.cpp")
|
|
||||||
elseif(BACKEND_CONTROLLER MATCHES "GLFW3")
|
|
||||||
target_sources(CSE2 PRIVATE "src/Backends/Controller/GLFW3.cpp")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(BACKEND_PLATFORM MATCHES "SDL2")
|
if(BACKEND_PLATFORM MATCHES "SDL2")
|
||||||
target_sources(CSE2 PRIVATE "src/Backends/Platform/SDL2.cpp")
|
target_sources(CSE2 PRIVATE "src/Backends/Platform/SDL2.cpp" "src/Backends/Controller/SDL2.cpp")
|
||||||
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
|
elseif(BACKEND_PLATFORM MATCHES "GLFW3")
|
||||||
target_sources(CSE2 PRIVATE "src/Backends/Platform/GLFW3.cpp")
|
target_sources(CSE2 PRIVATE "src/Backends/Platform/GLFW3.cpp" "src/Backends/Controller/GLFW3.cpp")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "OpenGL3")
|
if(BACKEND_PLATFORM MATCHES "SDL2" AND BACKEND_RENDERER MATCHES "OpenGL3")
|
||||||
|
|
|
@ -210,7 +210,7 @@ void WindowSizeCallback(GLFWwindow *window, int width, int height)
|
||||||
(void)width;
|
(void)width;
|
||||||
(void)height;
|
(void)height;
|
||||||
|
|
||||||
RenderBackend_HandleWindowResize();
|
Backend_HandleWindowResize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlatformBackend_Init(void)
|
void PlatformBackend_Init(void)
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
#include "SDL.h"
|
#include "SDL.h"
|
||||||
|
|
||||||
#include "../Window.h"
|
#include "../Rendering.h"
|
||||||
|
|
||||||
#include "../../WindowsWrapper.h"
|
#include "../../WindowsWrapper.h"
|
||||||
|
|
||||||
|
|
|
@ -5,22 +5,22 @@
|
||||||
typedef struct Backend_Surface Backend_Surface;
|
typedef struct Backend_Surface Backend_Surface;
|
||||||
typedef struct Backend_Glyph Backend_Glyph;
|
typedef struct Backend_Glyph Backend_Glyph;
|
||||||
|
|
||||||
Backend_Surface* RenderBackend_Init(int screen_width, int screen_height);
|
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen);
|
||||||
void RenderBackend_Deinit(void);
|
void Backend_Deinit(void);
|
||||||
void RenderBackend_DrawScreen(void);
|
void Backend_DrawScreen(void);
|
||||||
void RenderBackend_ClearScreen(void);
|
void Backend_ClearScreen(void);
|
||||||
Backend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height);
|
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height);
|
||||||
void RenderBackend_FreeSurface(Backend_Surface *surface);
|
void Backend_FreeSurface(Backend_Surface *surface);
|
||||||
BOOL RenderBackend_IsSurfaceLost(Backend_Surface *surface);
|
BOOL Backend_IsSurfaceLost(Backend_Surface *surface);
|
||||||
void RenderBackend_RestoreSurface(Backend_Surface *surface);
|
void Backend_RestoreSurface(Backend_Surface *surface);
|
||||||
unsigned char* RenderBackend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height);
|
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height);
|
||||||
void RenderBackend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height);
|
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height);
|
||||||
void RenderBackend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key);
|
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key);
|
||||||
void RenderBackend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
|
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
|
||||||
Backend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch);
|
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch);
|
||||||
void RenderBackend_UnloadGlyph(Backend_Glyph *glyph);
|
void Backend_UnloadGlyph(Backend_Glyph *glyph);
|
||||||
void RenderBackend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels);
|
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels);
|
||||||
void RenderBackend_DrawGlyph(Backend_Glyph *glyph, long x, long y);
|
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y);
|
||||||
void RenderBackend_FlushGlyphs(void);
|
void Backend_FlushGlyphs(void);
|
||||||
void RenderBackend_HandleRenderTargetLoss(void);
|
void Backend_HandleRenderTargetLoss(void);
|
||||||
void RenderBackend_HandleWindowResize(void);
|
void Backend_HandleWindowResize(void);
|
||||||
|
|
|
@ -513,108 +513,111 @@ static void GlyphBatch_DestroyTexture(SPRITEBATCH_U64 texture_id, void *udata)
|
||||||
// Render-backend initialisation
|
// Render-backend initialisation
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
Backend_Surface* RenderBackend_Init(int screen_width, int screen_height)
|
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen)
|
||||||
{
|
{
|
||||||
printf("GL_VENDOR = %s\n", glGetString(GL_VENDOR));
|
if (WindowBackend_OpenGL_CreateWindow(window_title, screen_width, screen_height, fullscreen))
|
||||||
printf("GL_RENDERER = %s\n", glGetString(GL_RENDERER));
|
|
||||||
printf("GL_VERSION = %s\n", glGetString(GL_VERSION));
|
|
||||||
|
|
||||||
// Set up blending (only used for font-rendering)
|
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
|
||||||
|
|
||||||
//glEnable(GL_DEBUG_OUTPUT);
|
|
||||||
//glDebugMessageCallback(MessageCallback, 0);
|
|
||||||
|
|
||||||
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
|
||||||
|
|
||||||
#ifndef USE_OPENGLES2
|
|
||||||
// Set up Vertex Array Object
|
|
||||||
glGenVertexArrays(1, &vertex_array_id);
|
|
||||||
glBindVertexArray(vertex_array_id);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Set up Vertex Buffer Objects
|
|
||||||
glGenBuffers(TOTAL_VBOS, vertex_buffer_ids);
|
|
||||||
|
|
||||||
// Set up the vertex attributes
|
|
||||||
glEnableVertexAttribArray(ATTRIBUTE_INPUT_VERTEX_COORDINATES);
|
|
||||||
|
|
||||||
// Set up our shaders
|
|
||||||
program_texture = CompileShader(vertex_shader_texture, fragment_shader_texture);
|
|
||||||
program_texture_colour_key = CompileShader(vertex_shader_texture, fragment_shader_texture_colour_key);
|
|
||||||
program_colour_fill = CompileShader(vertex_shader_plain, fragment_shader_colour_fill);
|
|
||||||
program_glyph = CompileShader(vertex_shader_texture, fragment_shader_glyph);
|
|
||||||
|
|
||||||
if (program_texture != 0 && program_texture_colour_key != 0 && program_colour_fill != 0 && program_glyph != 0)
|
|
||||||
{
|
{
|
||||||
// Get shader uniforms
|
printf("GL_VENDOR = %s\n", glGetString(GL_VENDOR));
|
||||||
program_colour_fill_uniform_colour = glGetUniformLocation(program_colour_fill, "colour");
|
printf("GL_RENDERER = %s\n", glGetString(GL_RENDERER));
|
||||||
program_glyph_uniform_colour = glGetUniformLocation(program_glyph, "colour");
|
printf("GL_VERSION = %s\n", glGetString(GL_VERSION));
|
||||||
|
|
||||||
// Set up framebuffer (used for surface-to-surface blitting)
|
// Set up blending (only used for font-rendering)
|
||||||
glGenFramebuffers(1, &framebuffer_id);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
|
|
||||||
|
//glEnable(GL_DEBUG_OUTPUT);
|
||||||
|
//glDebugMessageCallback(MessageCallback, 0);
|
||||||
|
|
||||||
|
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
// Set up framebuffer screen texture (used for screen-to-surface blitting)
|
|
||||||
glGenTextures(1, &framebuffer.texture_id);
|
|
||||||
glBindTexture(GL_TEXTURE_2D, framebuffer.texture_id);
|
|
||||||
#ifdef USE_OPENGLES2
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screen_width, screen_height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
#else
|
|
||||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, screen_width, screen_height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
|
||||||
#endif
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
|
||||||
#ifndef USE_OPENGLES2
|
#ifndef USE_OPENGLES2
|
||||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
// Set up Vertex Array Object
|
||||||
|
glGenVertexArrays(1, &vertex_array_id);
|
||||||
|
glBindVertexArray(vertex_array_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
framebuffer.width = screen_width;
|
// Set up Vertex Buffer Objects
|
||||||
framebuffer.height = screen_height;
|
glGenBuffers(TOTAL_VBOS, vertex_buffer_ids);
|
||||||
|
|
||||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebuffer.texture_id, 0);
|
// Set up the vertex attributes
|
||||||
glViewport(0, 0, framebuffer.width, framebuffer.height);
|
glEnableVertexAttribArray(ATTRIBUTE_INPUT_VERTEX_COORDINATES);
|
||||||
|
|
||||||
// Set-up glyph-batcher
|
// Set up our shaders
|
||||||
spritebatch_config_t config;
|
program_texture = CompileShader(vertex_shader_texture, fragment_shader_texture);
|
||||||
spritebatch_set_default_config(&config);
|
program_texture_colour_key = CompileShader(vertex_shader_texture, fragment_shader_texture_colour_key);
|
||||||
config.pixel_stride = 1;
|
program_colour_fill = CompileShader(vertex_shader_plain, fragment_shader_colour_fill);
|
||||||
config.atlas_width_in_pixels = 256;
|
program_glyph = CompileShader(vertex_shader_texture, fragment_shader_glyph);
|
||||||
config.atlas_height_in_pixels = 256;
|
|
||||||
config.lonely_buffer_count_till_flush = 4; // Start making atlases immediately
|
|
||||||
config.batch_callback = GlyphBatch_Draw;
|
|
||||||
config.get_pixels_callback = GlyphBatch_GetPixels;
|
|
||||||
config.generate_texture_callback = GlyphBatch_CreateTexture;
|
|
||||||
config.delete_texture_callback = GlyphBatch_DestroyTexture;
|
|
||||||
spritebatch_init(&glyph_batcher, &config, NULL);
|
|
||||||
|
|
||||||
return &framebuffer;
|
if (program_texture != 0 && program_texture_colour_key != 0 && program_colour_fill != 0 && program_glyph != 0)
|
||||||
|
{
|
||||||
|
// Get shader uniforms
|
||||||
|
program_colour_fill_uniform_colour = glGetUniformLocation(program_colour_fill, "colour");
|
||||||
|
program_glyph_uniform_colour = glGetUniformLocation(program_glyph, "colour");
|
||||||
|
|
||||||
|
// Set up framebuffer (used for surface-to-surface blitting)
|
||||||
|
glGenFramebuffers(1, &framebuffer_id);
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
|
||||||
|
|
||||||
|
// Set up framebuffer screen texture (used for screen-to-surface blitting)
|
||||||
|
glGenTextures(1, &framebuffer.texture_id);
|
||||||
|
glBindTexture(GL_TEXTURE_2D, framebuffer.texture_id);
|
||||||
|
#ifdef USE_OPENGLES2
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, screen_width, screen_height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
#else
|
||||||
|
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, screen_width, screen_height, 0, GL_RGB, GL_UNSIGNED_BYTE, NULL);
|
||||||
|
#endif
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||||
|
#ifndef USE_OPENGLES2
|
||||||
|
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
framebuffer.width = screen_width;
|
||||||
|
framebuffer.height = screen_height;
|
||||||
|
|
||||||
|
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, framebuffer.texture_id, 0);
|
||||||
|
glViewport(0, 0, framebuffer.width, framebuffer.height);
|
||||||
|
|
||||||
|
// Set-up glyph-batcher
|
||||||
|
spritebatch_config_t config;
|
||||||
|
spritebatch_set_default_config(&config);
|
||||||
|
config.pixel_stride = 1;
|
||||||
|
config.atlas_width_in_pixels = 256;
|
||||||
|
config.atlas_height_in_pixels = 256;
|
||||||
|
config.lonely_buffer_count_till_flush = 4; // Start making atlases immediately
|
||||||
|
config.batch_callback = GlyphBatch_Draw;
|
||||||
|
config.get_pixels_callback = GlyphBatch_GetPixels;
|
||||||
|
config.generate_texture_callback = GlyphBatch_CreateTexture;
|
||||||
|
config.delete_texture_callback = GlyphBatch_DestroyTexture;
|
||||||
|
spritebatch_init(&glyph_batcher, &config, NULL);
|
||||||
|
|
||||||
|
return &framebuffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (program_glyph != 0)
|
||||||
|
glDeleteProgram(program_glyph);
|
||||||
|
|
||||||
|
if (program_colour_fill != 0)
|
||||||
|
glDeleteProgram(program_colour_fill);
|
||||||
|
|
||||||
|
if (program_texture_colour_key != 0)
|
||||||
|
glDeleteProgram(program_texture_colour_key);
|
||||||
|
|
||||||
|
if (program_texture != 0)
|
||||||
|
glDeleteProgram(program_texture);
|
||||||
|
|
||||||
|
glDeleteBuffers(TOTAL_VBOS, vertex_buffer_ids);
|
||||||
|
#ifndef USE_OPENGLES2
|
||||||
|
glDeleteVertexArrays(1, &vertex_array_id);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
if (program_glyph != 0)
|
|
||||||
glDeleteProgram(program_glyph);
|
|
||||||
|
|
||||||
if (program_colour_fill != 0)
|
|
||||||
glDeleteProgram(program_colour_fill);
|
|
||||||
|
|
||||||
if (program_texture_colour_key != 0)
|
|
||||||
glDeleteProgram(program_texture_colour_key);
|
|
||||||
|
|
||||||
if (program_texture != 0)
|
|
||||||
glDeleteProgram(program_texture);
|
|
||||||
|
|
||||||
glDeleteBuffers(TOTAL_VBOS, vertex_buffer_ids);
|
|
||||||
#ifndef USE_OPENGLES2
|
|
||||||
glDeleteVertexArrays(1, &vertex_array_id);
|
|
||||||
#endif
|
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_Deinit(void)
|
void Backend_Deinit(void)
|
||||||
{
|
{
|
||||||
free(local_vertex_buffer);
|
free(local_vertex_buffer);
|
||||||
|
|
||||||
|
@ -630,9 +633,11 @@ void RenderBackend_Deinit(void)
|
||||||
#ifndef USE_OPENGLES2
|
#ifndef USE_OPENGLES2
|
||||||
glDeleteVertexArrays(1, &vertex_array_id);
|
glDeleteVertexArrays(1, &vertex_array_id);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
WindowBackend_OpenGL_DestroyWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_DrawScreen(void)
|
void Backend_DrawScreen(void)
|
||||||
{
|
{
|
||||||
spritebatch_tick(&glyph_batcher);
|
spritebatch_tick(&glyph_batcher);
|
||||||
|
|
||||||
|
@ -688,22 +693,21 @@ void RenderBackend_DrawScreen(void)
|
||||||
|
|
||||||
FlushVertexBuffer();
|
FlushVertexBuffer();
|
||||||
|
|
||||||
// Switch back to our framebuffer
|
WindowBackend_OpenGL_Display();
|
||||||
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
|
|
||||||
}
|
|
||||||
|
|
||||||
void RenderBackend_ClearScreen(void)
|
|
||||||
{
|
|
||||||
// According to https://www.khronos.org/opengl/wiki/Common_Mistakes#Swap_Buffers
|
// According to https://www.khronos.org/opengl/wiki/Common_Mistakes#Swap_Buffers
|
||||||
// the buffer should always be cleared, even if it seems unnecessary
|
// the buffer should always be cleared, even if it seems unnecessary
|
||||||
glClear(GL_COLOR_BUFFER_BIT);
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
|
|
||||||
|
// Switch back to our framebuffer
|
||||||
|
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====================
|
// ====================
|
||||||
// Surface management
|
// Surface management
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
Backend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int height)
|
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
Backend_Surface *surface = (Backend_Surface*)malloc(sizeof(Backend_Surface));
|
Backend_Surface *surface = (Backend_Surface*)malloc(sizeof(Backend_Surface));
|
||||||
|
|
||||||
|
@ -733,7 +737,7 @@ Backend_Surface* RenderBackend_CreateSurface(unsigned int width, unsigned int he
|
||||||
return surface;
|
return surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_FreeSurface(Backend_Surface *surface)
|
void Backend_FreeSurface(Backend_Surface *surface)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -746,19 +750,19 @@ void RenderBackend_FreeSurface(Backend_Surface *surface)
|
||||||
free(surface);
|
free(surface);
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOL RenderBackend_IsSurfaceLost(Backend_Surface *surface)
|
BOOL Backend_IsSurfaceLost(Backend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_RestoreSurface(Backend_Surface *surface)
|
void Backend_RestoreSurface(Backend_Surface *surface)
|
||||||
{
|
{
|
||||||
(void)surface;
|
(void)surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned char* RenderBackend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
@ -768,7 +772,7 @@ unsigned char* RenderBackend_LockSurface(Backend_Surface *surface, unsigned int
|
||||||
return surface->pixels;
|
return surface->pixels;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
||||||
{
|
{
|
||||||
if (surface == NULL)
|
if (surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -788,7 +792,7 @@ void RenderBackend_UnlockSurface(Backend_Surface *surface, unsigned int width, u
|
||||||
// Drawing
|
// Drawing
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
void RenderBackend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
||||||
{
|
{
|
||||||
if (source_surface == NULL || destination_surface == NULL)
|
if (source_surface == NULL || destination_surface == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -864,7 +868,7 @@ void RenderBackend_Blit(Backend_Surface *source_surface, const RECT *rect, Backe
|
||||||
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
vertex_buffer_slot->vertices[1][2].vertex_coordinate.y = vertex_bottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
||||||
{
|
{
|
||||||
static unsigned char last_red;
|
static unsigned char last_red;
|
||||||
static unsigned char last_green;
|
static unsigned char last_green;
|
||||||
|
@ -929,7 +933,7 @@ void RenderBackend_ColourFill(Backend_Surface *surface, const RECT *rect, unsign
|
||||||
// Glyph management
|
// Glyph management
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
Backend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
||||||
{
|
{
|
||||||
Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
|
Backend_Glyph *glyph = (Backend_Glyph*)malloc(sizeof(Backend_Glyph));
|
||||||
|
|
||||||
|
@ -960,7 +964,7 @@ Backend_Glyph* RenderBackend_LoadGlyph(const unsigned char *pixels, unsigned int
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_UnloadGlyph(Backend_Glyph *glyph)
|
void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
||||||
{
|
{
|
||||||
if (glyph == NULL)
|
if (glyph == NULL)
|
||||||
return;
|
return;
|
||||||
|
@ -969,19 +973,19 @@ void RenderBackend_UnloadGlyph(Backend_Glyph *glyph)
|
||||||
free(glyph);
|
free(glyph);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
||||||
{
|
{
|
||||||
glyph_destination_surface = destination_surface;
|
glyph_destination_surface = destination_surface;
|
||||||
|
|
||||||
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
memcpy(glyph_colour_channels, colour_channels, sizeof(glyph_colour_channels));
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
||||||
{
|
{
|
||||||
spritebatch_push(&glyph_batcher, (SPRITEBATCH_U64)glyph, glyph->pitch, glyph->height, x, y, 1.0f, 1.0f, 0.0f, 0.0f, 0);
|
spritebatch_push(&glyph_batcher, (SPRITEBATCH_U64)glyph, glyph->pitch, glyph->height, x, y, 1.0f, 1.0f, 0.0f, 0.0f, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_FlushGlyphs(void)
|
void Backend_FlushGlyphs(void)
|
||||||
{
|
{
|
||||||
spritebatch_defrag(&glyph_batcher);
|
spritebatch_defrag(&glyph_batcher);
|
||||||
spritebatch_flush(&glyph_batcher);
|
spritebatch_flush(&glyph_batcher);
|
||||||
|
@ -991,12 +995,12 @@ void RenderBackend_FlushGlyphs(void)
|
||||||
// Misc.
|
// Misc.
|
||||||
// ====================
|
// ====================
|
||||||
|
|
||||||
void RenderBackend_HandleRenderTargetLoss(void)
|
void Backend_HandleRenderTargetLoss(void)
|
||||||
{
|
{
|
||||||
// No problem for us
|
// No problem for us
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderBackend_HandleWindowResize(void)
|
void Backend_HandleWindowResize(void)
|
||||||
{
|
{
|
||||||
// No problem for us
|
// No problem for us
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,6 @@
|
||||||
|
|
||||||
#include "../WindowsWrapper.h"
|
#include "../WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Rendering.h"
|
BOOL WindowBackend_OpenGL_CreateWindow(const char *window_title, int screen_width, int screen_height, BOOL fullscreen);
|
||||||
|
void WindowBackend_OpenGL_DestroyWindow(void);
|
||||||
Backend_Surface* Backend_Init(const char *window_title, int screen_width, int screen_height, BOOL fullscreen);
|
void WindowBackend_OpenGL_Display(void);
|
||||||
void Backend_Deinit(void);
|
|
||||||
void Backend_DrawScreen(void);
|
|
||||||
void Backend_ClearScreen(void);
|
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height);
|
|
||||||
void Backend_FreeSurface(Backend_Surface *surface);
|
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface);
|
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface);
|
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height);
|
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height);
|
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key);
|
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue);
|
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch);
|
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph);
|
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels);
|
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y);
|
|
||||||
void Backend_FlushGlyphs(void);
|
|
||||||
void Backend_HandleRenderTargetLoss(void);
|
|
||||||
void Backend_HandleWindowResize(void);
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ void KeyCallback(GLFWwindow *window, int key, int scancode, int action, int mods
|
||||||
void WindowFocusCallback(GLFWwindow *window, int focused);
|
void WindowFocusCallback(GLFWwindow *window, int focused);
|
||||||
void WindowSizeCallback(GLFWwindow *window, int width, int height);
|
void WindowSizeCallback(GLFWwindow *window, int width, int height);
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(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)
|
||||||
{
|
{
|
||||||
#ifdef USE_OPENGLES2
|
#ifdef USE_OPENGLES2
|
||||||
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API);
|
||||||
|
@ -49,8 +49,16 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
SDL_FreeSurface(icon_surface);
|
SDL_FreeSurface(icon_surface);
|
||||||
#endif
|
#endif
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
glfwSetWindowMonitor(window, glfwGetPrimaryMonitor(), 0, 0, screen_width, screen_height, GLFW_DONT_CARE);
|
{
|
||||||
|
GLFWmonitor* monitor = glfwGetPrimaryMonitor();
|
||||||
|
if (monitor)
|
||||||
|
{
|
||||||
|
const GLFWvidmode* mode = glfwGetVideoMode(monitor);
|
||||||
|
glfwSetWindowMonitor(window, monitor, 0, 0, mode->width, mode->height, mode->refreshRate);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
|
@ -65,7 +73,7 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
glfwSetWindowFocusCallback(window, WindowFocusCallback);
|
glfwSetWindowFocusCallback(window, WindowFocusCallback);
|
||||||
glfwSetWindowSizeCallback(window, WindowSizeCallback);
|
glfwSetWindowSizeCallback(window, WindowSizeCallback);
|
||||||
|
|
||||||
return RenderBackend_Init(screen_width, screen_height);
|
return TRUE;
|
||||||
#ifndef USE_OPENGLES2
|
#ifndef USE_OPENGLES2
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -86,97 +94,15 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
|
PlatformBackend_ShowMessageBox("Fatal error (OpenGL rendering backend)", "Could not create window");
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Deinit(void)
|
void WindowBackend_OpenGL_DestroyWindow(void)
|
||||||
{
|
{
|
||||||
RenderBackend_Deinit();
|
|
||||||
|
|
||||||
glfwDestroyWindow(window);
|
glfwDestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawScreen(void)
|
void WindowBackend_OpenGL_Display(void)
|
||||||
{
|
{
|
||||||
RenderBackend_DrawScreen();
|
|
||||||
|
|
||||||
glfwSwapBuffers(window);
|
glfwSwapBuffers(window);
|
||||||
|
|
||||||
RenderBackend_ClearScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
|
||||||
{
|
|
||||||
return RenderBackend_CreateSurface(width, height);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_FreeSurface(Backend_Surface *surface)
|
|
||||||
{
|
|
||||||
RenderBackend_FreeSurface(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface)
|
|
||||||
{
|
|
||||||
return RenderBackend_IsSurfaceLost(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface)
|
|
||||||
{
|
|
||||||
RenderBackend_RestoreSurface(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
|
||||||
{
|
|
||||||
return RenderBackend_LockSurface(surface, pitch, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
|
||||||
{
|
|
||||||
RenderBackend_UnlockSurface(surface, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
|
||||||
{
|
|
||||||
RenderBackend_Blit(source_surface, rect, destination_surface, x, y, colour_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
|
||||||
{
|
|
||||||
RenderBackend_ColourFill(surface, rect, red, green, blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
|
||||||
{
|
|
||||||
return RenderBackend_LoadGlyph(pixels, width, height, pitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
|
||||||
{
|
|
||||||
RenderBackend_UnloadGlyph(glyph);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
|
||||||
{
|
|
||||||
RenderBackend_PrepareToDrawGlyphs(destination_surface, colour_channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
|
||||||
{
|
|
||||||
RenderBackend_DrawGlyph(glyph, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_FlushGlyphs(void)
|
|
||||||
{
|
|
||||||
RenderBackend_FlushGlyphs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_HandleRenderTargetLoss(void)
|
|
||||||
{
|
|
||||||
RenderBackend_HandleRenderTargetLoss();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_HandleWindowResize(void)
|
|
||||||
{
|
|
||||||
RenderBackend_HandleWindowResize();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,7 +17,7 @@
|
||||||
static SDL_Window *window;
|
static SDL_Window *window;
|
||||||
static SDL_GLContext context;
|
static SDL_GLContext context;
|
||||||
|
|
||||||
Backend_Surface* Backend_Init(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)
|
||||||
{
|
{
|
||||||
puts("Available SDL2 video drivers:");
|
puts("Available SDL2 video drivers:");
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
if (GLAD_GL_VERSION_3_2)
|
if (GLAD_GL_VERSION_3_2)
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
return RenderBackend_Init(screen_width, screen_height);
|
return TRUE;
|
||||||
#ifndef USE_OPENGLES2
|
#ifndef USE_OPENGLES2
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -100,98 +100,16 @@ Backend_Surface* Backend_Init(const char *window_title, int screen_width, int sc
|
||||||
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error (OpenGL rendering backend)", "Could not create window", NULL);
|
SDL_ShowSimpleMessageBox(SDL_MESSAGEBOX_ERROR, "Fatal error (OpenGL rendering backend)", "Could not create window", NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_Deinit(void)
|
void WindowBackend_OpenGL_DestroyWindow(void)
|
||||||
{
|
{
|
||||||
RenderBackend_Deinit();
|
|
||||||
|
|
||||||
SDL_GL_DeleteContext(context);
|
SDL_GL_DeleteContext(context);
|
||||||
SDL_DestroyWindow(window);
|
SDL_DestroyWindow(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Backend_DrawScreen(void)
|
void WindowBackend_OpenGL_Display(void)
|
||||||
{
|
{
|
||||||
RenderBackend_DrawScreen();
|
|
||||||
|
|
||||||
SDL_GL_SwapWindow(window);
|
SDL_GL_SwapWindow(window);
|
||||||
|
|
||||||
RenderBackend_ClearScreen();
|
|
||||||
}
|
|
||||||
|
|
||||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height)
|
|
||||||
{
|
|
||||||
return RenderBackend_CreateSurface(width, height);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_FreeSurface(Backend_Surface *surface)
|
|
||||||
{
|
|
||||||
RenderBackend_FreeSurface(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
BOOL Backend_IsSurfaceLost(Backend_Surface *surface)
|
|
||||||
{
|
|
||||||
return RenderBackend_IsSurfaceLost(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_RestoreSurface(Backend_Surface *surface)
|
|
||||||
{
|
|
||||||
RenderBackend_RestoreSurface(surface);
|
|
||||||
}
|
|
||||||
|
|
||||||
unsigned char* Backend_LockSurface(Backend_Surface *surface, unsigned int *pitch, unsigned int width, unsigned int height)
|
|
||||||
{
|
|
||||||
return RenderBackend_LockSurface(surface, pitch, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_UnlockSurface(Backend_Surface *surface, unsigned int width, unsigned int height)
|
|
||||||
{
|
|
||||||
RenderBackend_UnlockSurface(surface, width, height);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_Blit(Backend_Surface *source_surface, const RECT *rect, Backend_Surface *destination_surface, long x, long y, BOOL colour_key)
|
|
||||||
{
|
|
||||||
RenderBackend_Blit(source_surface, rect, destination_surface, x, y, colour_key);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_ColourFill(Backend_Surface *surface, const RECT *rect, unsigned char red, unsigned char green, unsigned char blue)
|
|
||||||
{
|
|
||||||
RenderBackend_ColourFill(surface, rect, red, green, blue);
|
|
||||||
}
|
|
||||||
|
|
||||||
Backend_Glyph* Backend_LoadGlyph(const unsigned char *pixels, unsigned int width, unsigned int height, int pitch)
|
|
||||||
{
|
|
||||||
return RenderBackend_LoadGlyph(pixels, width, height, pitch);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_UnloadGlyph(Backend_Glyph *glyph)
|
|
||||||
{
|
|
||||||
RenderBackend_UnloadGlyph(glyph);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_PrepareToDrawGlyphs(Backend_Surface *destination_surface, const unsigned char *colour_channels)
|
|
||||||
{
|
|
||||||
RenderBackend_PrepareToDrawGlyphs(destination_surface, colour_channels);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_DrawGlyph(Backend_Glyph *glyph, long x, long y)
|
|
||||||
{
|
|
||||||
RenderBackend_DrawGlyph(glyph, x, y);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_FlushGlyphs(void)
|
|
||||||
{
|
|
||||||
RenderBackend_FlushGlyphs();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_HandleRenderTargetLoss(void)
|
|
||||||
{
|
|
||||||
RenderBackend_HandleRenderTargetLoss();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Backend_HandleWindowResize(void)
|
|
||||||
{
|
|
||||||
RenderBackend_HandleWindowResize();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
#include "WindowsWrapper.h"
|
#include "WindowsWrapper.h"
|
||||||
|
|
||||||
#include "Backends/Platform.h"
|
#include "Backends/Platform.h"
|
||||||
#include "Backends/Window.h"
|
#include "Backends/Rendering.h"
|
||||||
#include "Bitmap.h"
|
#include "Bitmap.h"
|
||||||
#include "CommonDefines.h"
|
#include "CommonDefines.h"
|
||||||
#include "Ending.h"
|
#include "Ending.h"
|
||||||
|
|
|
@ -13,7 +13,7 @@
|
||||||
|
|
||||||
#include "Draw.h"
|
#include "Draw.h"
|
||||||
#include "File.h"
|
#include "File.h"
|
||||||
#include "Backends/Window.h"
|
#include "Backends/Rendering.h"
|
||||||
|
|
||||||
// Cave Story wasn't intended to use font anti-aliasing. It's only because Microsoft enabled it
|
// Cave Story wasn't intended to use font anti-aliasing. It's only because Microsoft enabled it
|
||||||
// by default from Windows Vista onwards that the game started using it.
|
// by default from Windows Vista onwards that the game started using it.
|
||||||
|
|
20
src/Main.cpp
20
src/Main.cpp
|
@ -220,12 +220,22 @@ int main(int argc, char *argv[])
|
||||||
if (conf.display_mode == 1)
|
if (conf.display_mode == 1)
|
||||||
{
|
{
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 0))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 0))
|
||||||
|
{
|
||||||
|
//SDL_FreeCursor(cursor);
|
||||||
|
//SDL_FreeSurface(cursor_surface);
|
||||||
|
PlatformBackend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 1))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 1))
|
||||||
|
{
|
||||||
|
//SDL_FreeCursor(cursor);
|
||||||
|
//SDL_FreeSurface(cursor_surface);
|
||||||
|
PlatformBackend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
// Doesn't handle StartDirectDraw failing
|
// Doesn't handle StartDirectDraw failing
|
||||||
|
@ -246,7 +256,12 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
#ifdef FIX_BUGS
|
#ifdef FIX_BUGS
|
||||||
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2))
|
if (!StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2))
|
||||||
|
{
|
||||||
|
//SDL_FreeCursor(cursor);
|
||||||
|
//SDL_FreeSurface(cursor_surface);
|
||||||
|
PlatformBackend_Deinit();
|
||||||
return EXIT_FAILURE;
|
return EXIT_FAILURE;
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
// Doesn't handle StartDirectDraw failing
|
// Doesn't handle StartDirectDraw failing
|
||||||
StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2);
|
StartDirectDraw(lpWindowName, windowWidth, windowHeight, 2);
|
||||||
|
@ -290,8 +305,9 @@ int main(int argc, char *argv[])
|
||||||
// Draw to screen
|
// Draw to screen
|
||||||
if (!Flip_SystemTask())
|
if (!Flip_SystemTask())
|
||||||
{
|
{
|
||||||
// SDL_FreeCursor(cursor);
|
//SDL_FreeCursor(cursor);
|
||||||
// SDL_FreeSurface(cursor_surface);
|
//SDL_FreeSurface(cursor_surface);
|
||||||
|
PlatformBackend_Deinit();
|
||||||
return EXIT_SUCCESS;
|
return EXIT_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue