Skip to content
This repository has been archived by the owner on Feb 11, 2021. It is now read-only.

Commit

Permalink
Merged SDL_GL_SWAP_CONTROL fix from SDL 1.2
Browse files Browse the repository at this point in the history
  • Loading branch information
slouken committed Jun 24, 2006
1 parent f06c49d commit 2e62254
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 12 deletions.
33 changes: 24 additions & 9 deletions src/video/wincommon/SDL_wingl.c
Expand Up @@ -150,8 +150,8 @@ Init_WGL_ARB_extensions(_THIS)
this->gl_data->wglChoosePixelFormatARB = (BOOL(WINAPI *)
(HDC, const int *,
const FLOAT *, UINT, int *,
UINT *)) this->gl_data->
wglGetProcAddress("wglChoosePixelFormatARB");
UINT *))
this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB");
this->gl_data->wglGetPixelFormatAttribivARB =
(BOOL(WINAPI *) (HDC, int, int, UINT, const int *, int *))
this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB");
Expand Down Expand Up @@ -357,7 +357,12 @@ WIN_GL_SetupWindow(_THIS)
/* Uh oh, something is seriously wrong here... */
wglext = NULL;
}
if (!wglext || !SDL_strstr(wglext, "WGL_EXT_swap_control")) {
if (wglext && SDL_strstr(wglext, "WGL_EXT_swap_control")) {
this->gl_data->wglSwapIntervalEXT =
WIN_GL_GetProcAddress(this, "wglSwapIntervalEXT");
this->gl_data->wglGetSwapIntervalEXT =
WIN_GL_GetProcAddress(this, "wglGetSwapIntervalEXT");
} else {
this->gl_data->wglSwapIntervalEXT = NULL;
this->gl_data->wglGetSwapIntervalEXT = NULL;
}
Expand Down Expand Up @@ -470,9 +475,8 @@ WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
break;
case SDL_GL_ACCELERATED_VISUAL:
wgl_attrib = WGL_ACCELERATION_ARB;
this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc,
pixel_format, 0,
1, &wgl_attrib,
this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format,
0, 1, &wgl_attrib,
value);
if (*value == WGL_NO_ACCELERATION_ARB) {
*value = SDL_FALSE;
Expand All @@ -483,15 +487,17 @@ WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
break;
case SDL_GL_SWAP_CONTROL:
if (this->gl_data->wglGetSwapIntervalEXT) {
return this->gl_data->wglGetSwapIntervalEXT();
*value = this->gl_data->wglGetSwapIntervalEXT();
return 0;
} else {
return -1;
}
break;
default:
return (-1);
}
this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format,
0, 1, &wgl_attrib, value);
this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0,
1, &wgl_attrib, value);

return 0;
}
Expand Down Expand Up @@ -551,6 +557,14 @@ WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
case SDL_GL_MULTISAMPLESAMPLES:
*value = 1;
break;
case SDL_GL_SWAP_CONTROL:
if (this->gl_data->wglGetSwapIntervalEXT) {
*value = this->gl_data->wglGetSwapIntervalEXT();
return 0;
} else {
return -1;
}
break;
default:
retval = -1;
break;
Expand Down Expand Up @@ -653,4 +667,5 @@ WIN_GL_GetProcAddress(_THIS, const char *proc)
}

#endif /* SDL_VIDEO_OPENGL */

/* vi: set ts=4 sw=4 expandtab: */
7 changes: 5 additions & 2 deletions src/video/x11/SDL_x11gl.c
Expand Up @@ -411,9 +411,10 @@ X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value)
break;
case SDL_GL_SWAP_CONTROL:
if (this->gl_data->glXGetSwapIntervalMESA) {
return this->gl_data->glXGetSwapIntervalMESA();
*value = this->gl_data->glXGetSwapIntervalMESA();
return (0);
} else {
return (-1) /*(this->gl_config.swap_control > 0) */ ;
return (-1);
}
break;
default:
Expand Down Expand Up @@ -567,3 +568,5 @@ X11_GL_GetProcAddress(_THIS, const char *proc)
}

#endif /* SDL_VIDEO_OPENGL_GLX */

/* vi: set ts=4 sw=4 expandtab: */
2 changes: 1 addition & 1 deletion test/testgl.c
Expand Up @@ -746,7 +746,7 @@ main(int argc, char *argv[])
}
if (strncmp(argv[i], "-h", 2) == 0) {
printf
("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-fullscreen]\n",
("Usage: %s [-twice] [-logo] [-logocursor] [-slow] [-bpp n] [-gamma n] [-noframe] [-fsaa] [-accel] [-sync] [-fullscreen]\n",
argv[0]);
exit(0);
}
Expand Down

0 comments on commit 2e62254

Please sign in to comment.