2 * Copyright (C) 2003 Robert Kooima
4 * NEVERBALL is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published
6 * by the Free Software Foundation; either version 2 of the License,
7 * or (at your option) any later version.
9 * This program is distributed in the hope that it will be useful, but
10 * WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * General Public License for more details.
15 #include <SDL_syswm.h>
18 /*---------------------------------------------------------------------------*/
19 #if defined(_WIN32) || defined(__MAEMO__)
26 /*---------------------------------------------------------------------------*/
27 #elif defined(__APPLE__)
29 #include <OpenGL/OpenGL.h>
34 CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &swap);
37 /*---------------------------------------------------------------------------*/
38 #elif SDL_VIDEO_DRIVER_X11
42 static int search(const char *haystack, const char *needle)
46 for (; *haystack; haystack++)
48 for (c = needle; *c && *haystack; c++, haystack++)
52 if ((*c == 0) && (*haystack == ' ' || *haystack == '\0'))
64 SDL_VERSION(&info.version);
66 if (SDL_GetWMInfo(&info) != 1)
69 if (info.subsystem != SDL_SYSWM_X11)
72 dpy = info.info.x11.display;
74 info.info.x11.lock_func();
76 int scr = DefaultScreen(dpy);
78 PFNGLXSWAPINTERVALSGIPROC _glXSwapIntervalSGI = NULL;
80 if (search(glXQueryExtensionsString(dpy, scr), "GLX_SGI_swap_control"))
82 if ((_glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
83 glXGetProcAddress((const GLubyte *) "glXSwapIntervalSGI")))
84 _glXSwapIntervalSGI(1);
87 info.info.x11.unlock_func();
92 /*---------------------------------------------------------------------------*/