Move the SDL_Window creation to the rendering backends
Whoops, didn't mean to commit the Main.cpp edit way back when I made the OpenGL 2.1 backend.
This commit is contained in:
parent
b998719ff1
commit
9948fa8b07
9 changed files with 36 additions and 6 deletions
|
@ -14,6 +14,7 @@ enum
|
|||
typedef struct Backend_Surface Backend_Surface;
|
||||
typedef struct Backend_Glyph Backend_Glyph;
|
||||
|
||||
SDL_Window* Backend_CreateWindow(const char *title, int width, int height);
|
||||
BOOL Backend_Init(SDL_Window *window);
|
||||
void Backend_Deinit(void);
|
||||
void Backend_DrawScreen(void);
|
||||
|
|
|
@ -71,6 +71,15 @@ static GLuint CompileShader(const char *fragment_shader_source)
|
|||
return program_id;
|
||||
}
|
||||
|
||||
SDL_Window* Backend_CreateWindow(const char *title, int width, int height)
|
||||
{
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
|
||||
return SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, SDL_WINDOW_OPENGL);
|
||||
}
|
||||
|
||||
BOOL Backend_Init(SDL_Window *p_window)
|
||||
{
|
||||
window = p_window;
|
||||
|
|
|
@ -38,6 +38,11 @@ static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect)
|
|||
sdl_rect->h = 0;
|
||||
}
|
||||
|
||||
SDL_Window* Backend_CreateWindow(const char *title, int width, int height)
|
||||
{
|
||||
return SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
||||
}
|
||||
|
||||
BOOL Backend_Init(SDL_Window *p_window)
|
||||
{
|
||||
window = p_window;
|
||||
|
|
|
@ -81,6 +81,11 @@ static void RectToSDLRect(const RECT *rect, SDL_Rect *sdl_rect)
|
|||
sdl_rect->h = 0;
|
||||
}
|
||||
|
||||
SDL_Window* Backend_CreateWindow(const char *title, int width, int height)
|
||||
{
|
||||
return SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
||||
}
|
||||
|
||||
BOOL Backend_Init(SDL_Window *window)
|
||||
{
|
||||
renderer = SDL_CreateRenderer(window, -1, SDL_RENDERER_ACCELERATED | SDL_RENDERER_TARGETTEXTURE);
|
||||
|
|
|
@ -34,6 +34,11 @@ static SDL_Surface *screen_surface;
|
|||
|
||||
static Backend_Surface framebuffer;
|
||||
|
||||
SDL_Window* Backend_CreateWindow(const char *title, int width, int height)
|
||||
{
|
||||
return SDL_CreateWindow(title, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, width, height, 0);
|
||||
}
|
||||
|
||||
BOOL Backend_Init(SDL_Window *p_window)
|
||||
{
|
||||
window = p_window;
|
||||
|
|
|
@ -69,6 +69,11 @@ BOOL Flip_SystemTask(HWND hWnd)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
SDL_Window* CreateWindow(const char *title, int width, int height)
|
||||
{
|
||||
return Backend_CreateWindow(title, width, height);
|
||||
}
|
||||
|
||||
BOOL StartDirectDraw(int lMagnification, int lColourDepth)
|
||||
{
|
||||
(void)lColourDepth; // There's no way I'm supporting a bunch of different colour depths
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "SDL.h"
|
||||
|
||||
#include "WindowsWrapper.h"
|
||||
|
||||
#ifndef RGB
|
||||
|
@ -53,6 +55,7 @@ struct SURFACE;
|
|||
extern SURFACE surf[SURFACE_ID_MAX];
|
||||
|
||||
BOOL Flip_SystemTask(HWND hWnd);
|
||||
SDL_Window* CreateWindow(const char *title, int width, int height);
|
||||
BOOL StartDirectDraw(int lMagnification, int lColourDepth);
|
||||
void EndDirectDraw();
|
||||
void ReleaseSurface(int s);
|
||||
|
|
|
@ -256,12 +256,8 @@ int main(int argc, char *argv[])
|
|||
windowHeight = WINDOW_HEIGHT * 2;
|
||||
}
|
||||
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_COMPATIBILITY);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1);
|
||||
|
||||
// Create window
|
||||
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, SDL_WINDOW_OPENGL);
|
||||
gWindow = CreateWindow(lpWindowName, windowWidth, windowHeight);
|
||||
|
||||
if (gWindow)
|
||||
{
|
||||
|
@ -281,7 +277,7 @@ int main(int argc, char *argv[])
|
|||
windowHeight = WINDOW_HEIGHT * 2;
|
||||
|
||||
// Create window
|
||||
gWindow = SDL_CreateWindow(lpWindowName, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED, windowWidth, windowHeight, 0);
|
||||
gWindow = CreateWindow(lpWindowName, windowWidth, windowHeight);
|
||||
|
||||
if (gWindow)
|
||||
{
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
// Avoid name collisions
|
||||
#undef DrawText
|
||||
#undef FindResource
|
||||
#undef CreateWindow
|
||||
#else
|
||||
|
||||
typedef int HWND;
|
||||
|
|
Loading…
Add table
Reference in a new issue