Fix GL1 and GL3 stencil buffer setup

This broke during refactoring (in b8a062e36), reported in #391

(SDL_GL_[SG]etAttribute() return 0 on success and -1 on failure)
This commit is contained in:
Daniel Gibson 2019-04-22 04:05:04 +02:00
parent f9108db668
commit 0ef064b21d
2 changed files with 5 additions and 5 deletions

View file

@ -81,7 +81,7 @@ int RI_PrepareForWindow(void)
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
if (SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8) < 0)
if (SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8) == 0)
{
gl_state.stencil = true;
}
@ -209,7 +209,7 @@ int RI_InitContext(void* win)
if (gl_state.stencil)
{
if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) != 8)
if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) < 0 || stencil_bits < 8)
{
gl_state.stencil = false;
}

View file

@ -170,7 +170,7 @@ int GL3_PrepareForWindow(void)
SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
if (SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8) < 0)
if (SDL_GL_SetAttribute(SDL_GL_STENCIL_SIZE, 8) == 0)
{
gl3config.stencil = true;
}
@ -270,12 +270,12 @@ int GL3_InitContext(void* win)
}
}
// Check if we've got 8 stencil bits
// Check if we've got at least 8 stencil bits
int stencil_bits = 0;
if (gl3config.stencil)
{
if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) != 8)
if (SDL_GL_GetAttribute(SDL_GL_STENCIL_SIZE, &stencil_bits) < 0 || stencil_bits < 8)
{
gl3config.stencil = false;
}