mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
Merge #1242
1242: Properly reset context attributes, if OpenGL3 context failed to create r=def- a=Jupeyy Automatically creates the older context, if OGL3 isn't supported Co-authored-by: Jupeyy <jupjopjap@gmail.com>
This commit is contained in:
commit
459002c5e5
|
@ -2210,12 +2210,11 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
||||||
SDL_ClearError();
|
SDL_ClearError();
|
||||||
const char *pErr = NULL;
|
const char *pErr = NULL;
|
||||||
|
|
||||||
//query default values, since they are platform dependent
|
// Query default values, since they are platform dependent
|
||||||
static bool s_InitDefaultParams = false;
|
static bool s_InitDefaultParams = false;
|
||||||
static int s_SDLGLContextProfileMask, s_SDLGLContextMajorVersion, s_SDLGLContextMinorVersion;
|
static int s_SDLGLContextProfileMask, s_SDLGLContextMajorVersion, s_SDLGLContextMinorVersion;
|
||||||
m_UseOpenGL3_3 = false;
|
static bool s_TriedOpenGL3Context = false;
|
||||||
if(g_Config.m_GfxOpenGL3)
|
|
||||||
{
|
|
||||||
if(!s_InitDefaultParams)
|
if(!s_InitDefaultParams)
|
||||||
{
|
{
|
||||||
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &s_SDLGLContextProfileMask);
|
SDL_GL_GetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, &s_SDLGLContextProfileMask);
|
||||||
|
@ -2224,6 +2223,21 @@ int CGraphicsBackend_SDL_OpenGL::Init(const char *pName, int *Screen, int *pWidt
|
||||||
s_InitDefaultParams = true;
|
s_InitDefaultParams = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// if OpenGL3 context was tried to be created, but failed, we have to restore the old context attributes
|
||||||
|
if(s_TriedOpenGL3Context && !g_Config.m_GfxOpenGL3)
|
||||||
|
{
|
||||||
|
s_TriedOpenGL3Context = false;
|
||||||
|
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, s_SDLGLContextProfileMask);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, s_SDLGLContextMajorVersion);
|
||||||
|
SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, s_SDLGLContextMinorVersion);
|
||||||
|
}
|
||||||
|
|
||||||
|
m_UseOpenGL3_3 = false;
|
||||||
|
if(g_Config.m_GfxOpenGL3)
|
||||||
|
{
|
||||||
|
s_TriedOpenGL3Context = true;
|
||||||
|
|
||||||
if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE) == 0)
|
if(SDL_GL_SetAttribute(SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE) == 0)
|
||||||
{
|
{
|
||||||
pErr = SDL_GetError();
|
pErr = SDL_GetError();
|
||||||
|
|
|
@ -2075,7 +2075,6 @@ int CGraphics_Threaded::InitWindow()
|
||||||
g_Config.m_GfxOpenGL3 = 0;
|
g_Config.m_GfxOpenGL3 = 0;
|
||||||
if(IssueInit() == 0)
|
if(IssueInit() == 0)
|
||||||
{
|
{
|
||||||
g_Config.m_GfxOpenGL3 = 1;
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue