* General Public License for more details.
*/
+#include <SDL_syswm.h>
#include "glext.h"
/*---------------------------------------------------------------------------*/
-#ifndef __APPLE__
+#if defined(_WIN32)
+
+void sync_init(void)
+{
+ return;
+}
+
+/*---------------------------------------------------------------------------*/
+#elif defined(__APPLE__)
+
+#include <OpenGL/OpenGL.h>
+
+void sync_init(void)
+{
+ long swap = 1;
+ CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &swap);
+}
+
+/*---------------------------------------------------------------------------*/
+#elif SDL_VIDEO_DRIVER_X11
+
+#include <GL/glx.h>
static int search(const char *haystack, const char *needle)
{
return 0;
}
-#endif
-/*---------------------------------------------------------------------------*/
-#ifdef __linux__
-
-#include <GL/glx.h>
-
void sync_init(void)
{
- Display *dpy = glXGetCurrentDisplay();
- int scr = DefaultScreen(dpy);
+ SDL_SysWMinfo info;
+ Display *dpy;
- PFNGLXSWAPINTERVALSGIPROC _glXSwapInvervalSGI = NULL;
+ SDL_VERSION(&info.version);
- if (search(glXQueryExtensionsString(dpy, scr), "GLX_SGI_swap_control"))
- {
- if ((_glXSwapInvervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
- glXGetProcAddress((const GLubyte *) "glXSwapIntervalSGI")))
- _glXSwapInvervalSGI(1);
- }
-}
+ if (SDL_GetWMInfo(&info) != 1)
+ return;
-#endif
-/*---------------------------------------------------------------------------*/
-#ifdef _WIN32
+ if (info.subsystem != SDL_SYSWM_X11)
+ return;
-void sync_init(void)
-{
-/* TODO: Sit down at a Windows machine and make this work.
- PFNWGLSWAPINTERVALEXTPROC _wglSwapInvervalEXT = NULL;
+ dpy = info.info.x11.display;
- if (search(wglGetExtensionsString(), "WGL_EXT_swap_control"))
+ info.info.x11.lock_func();
{
- if ((_wglSwapInvervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
- wglGetProcAddress((const GLubyte *) "wglSwapIntervalEXT")))
- _wglSwapInvervalEXT(1);
- }
-*/
-}
+ int scr = DefaultScreen(dpy);
-#endif
-/*---------------------------------------------------------------------------*/
-#ifdef __APPLE__
+ PFNGLXSWAPINTERVALSGIPROC _glXSwapIntervalSGI = NULL;
-#include <OpenGL/OpenGL.h>
-
-void sync_init(void)
-{
- long swap = 1;
- CGLSetParameter(CGLGetCurrentContext(), kCGLCPSwapInterval, &swap);
+ if (search(glXQueryExtensionsString(dpy, scr), "GLX_SGI_swap_control"))
+ {
+ if ((_glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
+ glXGetProcAddress((const GLubyte *) "glXSwapIntervalSGI")))
+ _glXSwapIntervalSGI(1);
+ }
+ }
+ info.info.x11.unlock_func();
}
#endif
+
/*---------------------------------------------------------------------------*/