Clean-up renderer backend initialisation
This commit is contained in:
parent
ba6d711d3a
commit
1140ab0916
5 changed files with 12 additions and 17 deletions
|
@ -7,7 +7,7 @@
|
|||
typedef struct Backend_Surface Backend_Surface;
|
||||
typedef struct Backend_Glyph Backend_Glyph;
|
||||
|
||||
Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL fullscreen);
|
||||
Backend_Surface* Backend_Init(const char *window_title, int window_width, int window_height, BOOL fullscreen);
|
||||
void Backend_Deinit(void);
|
||||
void Backend_DrawScreen(void);
|
||||
Backend_Surface* Backend_CreateSurface(unsigned int width, unsigned int height);
|
||||
|
|
|
@ -519,7 +519,7 @@ static void GlyphBatch_DestroyTexture(SPRITEBATCH_U64 texture_id, void *udata)
|
|||
// Render-backend initialisation
|
||||
// ====================
|
||||
|
||||
Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL fullscreen)
|
||||
Backend_Surface* Backend_Init(const char *window_title, int window_width, int window_height, BOOL fullscreen)
|
||||
{
|
||||
#ifdef USE_OPENGLES2
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES);
|
||||
|
@ -533,7 +533,7 @@ Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL ful
|
|||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 2);
|
||||
#endif
|
||||
|
||||
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
|
||||
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, window_width, window_height, SDL_WINDOW_OPENGL);
|
||||
|
||||
if (window != NULL)
|
||||
{
|
||||
|
@ -549,9 +549,6 @@ Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL ful
|
|||
if (fullscreen)
|
||||
SDL_SetWindowFullscreen(window, SDL_WINDOW_FULLSCREEN);
|
||||
|
||||
int window_width, window_height;
|
||||
SDL_GetWindowSize(window, &window_width, &window_height);
|
||||
|
||||
context = SDL_GL_CreateContext(window);
|
||||
|
||||
if (context != NULL)
|
||||
|
|
|
@ -41,9 +41,9 @@ static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect)
|
|||
sdl_rect->h = 0;
|
||||
}
|
||||
|
||||
Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL fullscreen)
|
||||
Backend_Surface* Backend_Init(const char *window_title, int window_width, int window_height, BOOL fullscreen)
|
||||
{
|
||||
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
||||
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, window_width, window_height, 0);
|
||||
|
||||
if (window != NULL)
|
||||
{
|
||||
|
|
|
@ -115,7 +115,7 @@ static void GlyphBatch_DestroyTexture(SPRITEBATCH_U64 texture_id, void *udata)
|
|||
SDL_DestroyTexture((SDL_Texture*)texture_id);
|
||||
}
|
||||
|
||||
Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL fullscreen)
|
||||
Backend_Surface* Backend_Init(const char *window_title, int window_width, int window_height, BOOL fullscreen)
|
||||
{
|
||||
puts("Available SDL2 render drivers:");
|
||||
|
||||
|
@ -126,7 +126,7 @@ Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL ful
|
|||
puts(info.name);
|
||||
}
|
||||
|
||||
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
||||
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, window_width, window_height, 0);
|
||||
|
||||
if (window != NULL)
|
||||
{
|
||||
|
@ -154,14 +154,12 @@ Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL ful
|
|||
SDL_GetRendererInfo(renderer, &info);
|
||||
printf("Selected SDL2 render driver: %s\n", info.name);
|
||||
|
||||
int width, height;
|
||||
SDL_GetRendererOutputSize(renderer, &width, &height);
|
||||
framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, width, height);
|
||||
framebuffer.texture = SDL_CreateTexture(renderer, SDL_PIXELFORMAT_RGBA32, SDL_TEXTUREACCESS_TARGET, window_width, window_height);
|
||||
|
||||
if (framebuffer.texture != NULL)
|
||||
{
|
||||
framebuffer.width = width;
|
||||
framebuffer.height = height;
|
||||
framebuffer.width = window_width;
|
||||
framebuffer.height = window_height;
|
||||
|
||||
// Set-up glyph-batcher
|
||||
spritebatch_config_t config;
|
||||
|
|
|
@ -36,9 +36,9 @@ static Backend_Surface framebuffer;
|
|||
static unsigned char glyph_colour_channels[3];
|
||||
static Backend_Surface *glyph_destination_surface;
|
||||
|
||||
Backend_Surface* Backend_Init(const char *title, int width, int height, BOOL fullscreen)
|
||||
Backend_Surface* Backend_Init(const char *window_title, int window_width, int window_height, BOOL fullscreen)
|
||||
{
|
||||
window = SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
||||
window = SDL_CreateWindow(window_title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, window_width, window_height, 0);
|
||||
|
||||
if (window != NULL)
|
||||
{
|
||||
|
|
Loading…
Add table
Reference in a new issue