Index: source/ps/VideoMode.h =================================================================== --- source/ps/VideoMode.h +++ source/ps/VideoMode.h @@ -23,6 +23,7 @@ #include typedef struct SDL_Window SDL_Window; +typedef void* SDL_GLContext; class CVideoMode { @@ -116,6 +117,7 @@ bool m_IsInitialised = false; SDL_Window* m_Window = nullptr; + SDL_GLContext m_Context = nullptr; // Initial desktop settings. // Frequency is in Hz, and BPP means bits per pixels (not bytes per pixels). Index: source/ps/VideoMode.cpp =================================================================== --- source/ps/VideoMode.cpp +++ source/ps/VideoMode.cpp @@ -279,13 +279,14 @@ return false; } - SDL_GLContext context = SDL_GL_CreateContext(m_Window); - if (!context) + m_Context = SDL_GL_CreateContext(m_Window); + if (!m_Context) { LOGERROR("SetVideoMode failed in SDL_GL_CreateContext: %dx%d:%d %d (\"%s\")", w, h, bpp, fullscreen ? 1 : 0, SDL_GetError()); return false; } + SDL_GL_MakeCurrent(m_Window, m_Context); } else { @@ -385,17 +386,11 @@ int bpp = GetBestBPP(); + SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24); SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1); -#if CONFIG2_GLES - // Require GLES 2.0 - SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); - SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); -#endif - bool forceGLVersion = false; CFG_GET_VAL("forceglversion", forceGLVersion); if (forceGLVersion) @@ -426,6 +421,19 @@ SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, forceGLMinorVersion); } } + else + { +#if CONFIG2_GLES + // Require GLES 2.0 + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_ES); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0); +#else + SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 2); + SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 1); +#endif + } if (!SetVideoMode(w, h, bpp, m_ConfigFullscreen)) { @@ -486,10 +494,15 @@ m_IsFullscreen = false; m_IsInitialised = false; + if (m_Context) + { + SDL_GL_DeleteContext(m_Context); + m_Context = nullptr; + } if (m_Window) { SDL_DestroyWindow(m_Window); - m_Window = NULL; + m_Window = nullptr; } }