mirror of
https://github.com/ClassiCube/ClassiCube.git
synced 2025-08-03 18:57:27 -04:00
Merge pull request #1406 from DrinkyBird/sdl-gl-attributes
SDL: Set GL attributes before creating the window
This commit is contained in:
commit
8b11e8b5c8
@ -38,6 +38,8 @@ typedef struct _WINDATA {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
static void SetGLAttributes();
|
||||||
|
|
||||||
static void RefreshWindowBounds(void) {
|
static void RefreshWindowBounds(void) {
|
||||||
SDL_GetWindowSize(win_handle, &Window_Main.Width, &Window_Main.Height);
|
SDL_GetWindowSize(win_handle, &Window_Main.Width, &Window_Main.Height);
|
||||||
}
|
}
|
||||||
@ -99,7 +101,10 @@ static void DoCreateWindow(int width, int height, int flags) {
|
|||||||
|
|
||||||
void Window_Create2D(int width, int height) { DoCreateWindow(width, height, 0); }
|
void Window_Create2D(int width, int height) { DoCreateWindow(width, height, 0); }
|
||||||
#if CC_GFX_BACKEND_IS_GL()
|
#if CC_GFX_BACKEND_IS_GL()
|
||||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, SDL_WINDOW_OPENGL); }
|
void Window_Create3D(int width, int height) {
|
||||||
|
SetGLAttributes();
|
||||||
|
DoCreateWindow(width, height, SDL_WINDOW_OPENGL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, 0); }
|
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, 0); }
|
||||||
#endif
|
#endif
|
||||||
@ -537,7 +542,7 @@ void Gamepads_Process(float delta) {
|
|||||||
#if CC_GFX_BACKEND_IS_GL()
|
#if CC_GFX_BACKEND_IS_GL()
|
||||||
static SDL_GLContext win_ctx;
|
static SDL_GLContext win_ctx;
|
||||||
|
|
||||||
void GLContext_Create(void) {
|
void SetGLAttributes(void) {
|
||||||
struct GraphicsMode mode;
|
struct GraphicsMode mode;
|
||||||
InitGraphicsMode(&mode);
|
InitGraphicsMode(&mode);
|
||||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, mode.R);
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, mode.R);
|
||||||
@ -553,7 +558,9 @@ void GLContext_Create(void) {
|
|||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLContext_Create(void) {
|
||||||
win_ctx = SDL_GL_CreateContext(win_handle);
|
win_ctx = SDL_GL_CreateContext(win_handle);
|
||||||
if (!win_ctx) Window_SDLFail("creating OpenGL context");
|
if (!win_ctx) Window_SDLFail("creating OpenGL context");
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
static SDL_Window* win_handle;
|
static SDL_Window* win_handle;
|
||||||
static Uint32 dlg_event;
|
static Uint32 dlg_event;
|
||||||
|
|
||||||
|
static void SetGLAttributes();
|
||||||
|
|
||||||
static void RefreshWindowBounds(void) {
|
static void RefreshWindowBounds(void) {
|
||||||
SDL_GetWindowSize(win_handle, &Window_Main.Width, &Window_Main.Height);
|
SDL_GetWindowSize(win_handle, &Window_Main.Width, &Window_Main.Height);
|
||||||
}
|
}
|
||||||
@ -84,7 +86,10 @@ static void DoCreateWindow(int width, int height, int flags) {
|
|||||||
|
|
||||||
void Window_Create2D(int width, int height) { DoCreateWindow(width, height, 0); }
|
void Window_Create2D(int width, int height) { DoCreateWindow(width, height, 0); }
|
||||||
#if CC_GFX_BACKEND_IS_GL()
|
#if CC_GFX_BACKEND_IS_GL()
|
||||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, SDL_WINDOW_OPENGL); }
|
void Window_Create3D(int width, int height) {
|
||||||
|
SetGLAttributes();
|
||||||
|
DoCreateWindow(width, height, SDL_WINDOW_OPENGL);
|
||||||
|
}
|
||||||
#else
|
#else
|
||||||
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, 0); }
|
void Window_Create3D(int width, int height) { DoCreateWindow(width, height, 0); }
|
||||||
#endif
|
#endif
|
||||||
@ -567,7 +572,7 @@ void Gamepads_Process(float delta) {
|
|||||||
#if CC_GFX_BACKEND_IS_GL()
|
#if CC_GFX_BACKEND_IS_GL()
|
||||||
static SDL_GLContext win_ctx;
|
static SDL_GLContext win_ctx;
|
||||||
|
|
||||||
void GLContext_Create(void) {
|
void SetGLAttributes(void) {
|
||||||
struct GraphicsMode mode;
|
struct GraphicsMode mode;
|
||||||
InitGraphicsMode(&mode);
|
InitGraphicsMode(&mode);
|
||||||
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, mode.R);
|
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, mode.R);
|
||||||
@ -583,7 +588,9 @@ void GLContext_Create(void) {
|
|||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2);
|
||||||
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
void GLContext_Create(void) {
|
||||||
win_ctx = SDL_GL_CreateContext(win_handle);
|
win_ctx = SDL_GL_CreateContext(win_handle);
|
||||||
if (!win_ctx) Window_SDLFail("creating OpenGL context");
|
if (!win_ctx) Window_SDLFail("creating OpenGL context");
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user