Mercurial > sdl-ios-xcode
changeset 1952:420716272158
Implemented X11 OpenGL support.
Added support for the SDL_VIDEO_OPENGL environment variable.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 28 Jul 2006 08:43:17 +0000 |
parents | 7177581dc9fa |
children | 214880ed48c3 |
files | configure.in include/SDL_config.h.in src/video/SDL_renderer_gl.c src/video/SDL_video.c src/video/cocoa/SDL_cocoaopengl.h src/video/cocoa/SDL_cocoaopengl.m src/video/cocoa/SDL_cocoavideo.m src/video/cocoa/SDL_cocoawindow.m src/video/win32/SDL_win32opengl.c src/video/win32/SDL_win32opengl.h src/video/win32/SDL_win32video.c src/video/win32/SDL_win32window.c src/video/x11/SDL_x11opengl.c src/video/x11/SDL_x11opengl.h src/video/x11/SDL_x11sym.h src/video/x11/SDL_x11video.c src/video/x11/SDL_x11video.h src/video/x11/SDL_x11window.c |
diffstat | 18 files changed, 847 insertions(+), 541 deletions(-) [+] |
line wrap: on
line diff
--- a/configure.in Thu Jul 27 06:53:23 2006 +0000 +++ b/configure.in Fri Jul 28 08:43:17 2006 +0000 @@ -1359,7 +1359,7 @@ dnl Check to see if OpenGL support is desired AC_ARG_ENABLE(video-opengl, -AC_HELP_STRING([--enable-video-opengl], [include OpenGL context creation [[default=yes]]]), +AC_HELP_STRING([--enable-video-opengl], [include OpenGL support [[default=yes]]]), , enable_video_opengl=yes) dnl Find OpenGL @@ -1379,6 +1379,7 @@ if test x$video_opengl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL_GLX) + AC_DEFINE(SDL_VIDEO_RENDER_OGL) fi fi } @@ -1398,6 +1399,7 @@ AC_MSG_RESULT($video_opengl) if test x$video_opengl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL) + AC_DEFINE(SDL_VIDEO_RENDER_OGL) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL" fi fi @@ -1409,6 +1411,7 @@ if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL_WGL) + AC_DEFINE(SDL_VIDEO_RENDER_OGL) fi } @@ -1417,6 +1420,8 @@ { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL) + AC_DEFINE(SDL_VIDEO_OPENGL_BGL) + AC_DEFINE(SDL_VIDEO_RENDER_OGL) EXTRA_LDFLAGS="$EXTRA_LDFLAGS -lGL" fi } @@ -1426,6 +1431,8 @@ { if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then AC_DEFINE(SDL_VIDEO_OPENGL) + AC_DEFINE(SDL_VIDEO_OPENGL_CGL) + AC_DEFINE(SDL_VIDEO_RENDER_OGL) case "$host" in *-*-darwin*) if test x$enable_video_cocoa = xyes; then @@ -1456,6 +1463,7 @@ fi AC_DEFINE(SDL_VIDEO_OPENGL) AC_DEFINE(SDL_VIDEO_OPENGL_OSMESA) + AC_DEFINE(SDL_VIDEO_RENDER_OGL) SDL_CFLAGS="$SDL_CFLAGS $OSMESA_CFLAGS" SDL_LIBS="$SDL_LIBS $OSMESA_LIBS"
--- a/include/SDL_config.h.in Thu Jul 27 06:53:23 2006 +0000 +++ b/include/SDL_config.h.in Fri Jul 28 08:43:17 2006 +0000 @@ -292,6 +292,8 @@ /* Enable OpenGL support */ #undef SDL_VIDEO_OPENGL +#undef SDL_VIDEO_OPENGL_BGL +#undef SDL_VIDEO_OPENGL_CGL #undef SDL_VIDEO_OPENGL_GLX #undef SDL_VIDEO_OPENGL_WGL #undef SDL_VIDEO_OPENGL_OSMESA
--- a/src/video/SDL_renderer_gl.c Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/SDL_renderer_gl.c Fri Jul 28 08:43:17 2006 +0000 @@ -21,7 +21,7 @@ */ #include "SDL_config.h" -#if SDL_VIDEO_OPENGL +#if SDL_VIDEO_RENDER_OGL #include "SDL_video.h" #include "SDL_opengl.h" @@ -197,6 +197,7 @@ { SDL_Renderer *renderer; GL_RenderData *data; + GLint value; if (!(window->flags & SDL_WINDOW_OPENGL)) { if (SDL_RecreateWindow(window, window->flags | SDL_WINDOW_OPENGL) < 0) { @@ -261,10 +262,10 @@ renderer->info.flags |= SDL_Renderer_PresentVSync; } - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, - &renderer->info.max_texture_width); - data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, - &renderer->info.max_texture_height); + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_width = value; + data->glGetIntegerv(GL_MAX_TEXTURE_SIZE, &value); + renderer->info.max_texture_height = value; if (SDL_GL_ExtensionSupported("GL_ARB_texture_rectangle") || SDL_GL_ExtensionSupported("GL_EXT_texture_rectangle")) { @@ -706,6 +707,6 @@ SDL_free(renderer); } -#endif /* SDL_VIDEO_OPENGL */ +#endif /* SDL_VIDEO_RENDER_OGL */ /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/SDL_video.c Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/SDL_video.c Fri Jul 28 08:43:17 2006 +0000 @@ -276,7 +276,7 @@ /* The software renderer is always available */ for (i = 0; i < _this->num_displays; ++i) { -#if SDL_VIDEO_OPENGL +#if SDL_VIDEO_RENDER_OGL SDL_AddRenderDriver(i, &GL_RenderDriver); #endif if (_this->displays[i].num_render_drivers > 0) {
--- a/src/video/cocoa/SDL_cocoaopengl.h Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/cocoa/SDL_cocoaopengl.h Fri Jul 28 08:43:17 2006 +0000 @@ -24,7 +24,7 @@ #ifndef _SDL_cocoaopengl_h #define _SDL_cocoaopengl_h -#if SDL_VIDEO_OPENGL +#if SDL_VIDEO_OPENGL_CGL struct SDL_GLDriverData { @@ -44,7 +44,7 @@ extern void Cocoa_GL_SwapWindow(_THIS, SDL_Window * window); extern void Cocoa_GL_DeleteContext(_THIS, SDL_GLContext context); -#endif /* SDL_VIDEO_OPENGL */ +#endif /* SDL_VIDEO_OPENGL_CGL */ #endif /* _SDL_cocoaopengl_h */
--- a/src/video/cocoa/SDL_cocoaopengl.m Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/cocoa/SDL_cocoaopengl.m Fri Jul 28 08:43:17 2006 +0000 @@ -25,14 +25,14 @@ /* NSOpenGL implementation of SDL OpenGL support */ -#if SDL_VIDEO_OPENGL +#if SDL_VIDEO_OPENGL_CGL #include <OpenGL/CGLTypes.h> #include "SDL_loadso.h" #include "SDL_opengl.h" -#define DEFAULT_OPENGL_PATH "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" +#define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" /* This is implemented in Mac OS X 10.3 and above */ #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 @@ -57,7 +57,10 @@ } } if (path == NULL) { - path = DEFAULT_OPENGL_PATH; + path = SDL_getenv("SDL_OPENGL_LIBRARY"); + } + if (path == NULL) { + path = DEFAULT_OPENGL; } _this->gl_config.dll_handle = SDL_LoadObject(path); if (!_this->gl_config.dll_handle) { @@ -87,19 +90,6 @@ } } -static void -Cocoa_GL_Shutdown(_THIS) -{ - if (!_this->gl_data || (--_this->gl_data->initialized > 0)) { - return; - } - - Cocoa_GL_UnloadLibrary(_this); - - SDL_free(_this->gl_data); - _this->gl_data = NULL; -} - static int Cocoa_GL_Initialize(_THIS) { @@ -124,6 +114,19 @@ return 0; } +static void +Cocoa_GL_Shutdown(_THIS) +{ + if (!_this->gl_data || (--_this->gl_data->initialized > 0)) { + return; + } + + Cocoa_GL_UnloadLibrary(_this); + + SDL_free(_this->gl_data); + _this->gl_data = NULL; +} + int Cocoa_GL_SetupWindow(_THIS, SDL_Window * window) { @@ -352,6 +355,6 @@ [pool release]; } -#endif /* SDL_VIDEO_OPENGL */ +#endif /* SDL_VIDEO_OPENGL_CGL */ /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/cocoa/SDL_cocoavideo.m Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/cocoa/SDL_cocoavideo.m Fri Jul 28 08:43:17 2006 +0000 @@ -87,7 +87,7 @@ device->SetWindowGrab = Cocoa_SetWindowGrab; device->DestroyWindow = Cocoa_DestroyWindow; device->GetWindowWMInfo = Cocoa_GetWindowWMInfo; -#ifdef SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL_CGL device->GL_LoadLibrary = Cocoa_GL_LoadLibrary; device->GL_GetProcAddress = Cocoa_GL_GetProcAddress; device->GL_CreateContext = Cocoa_GL_CreateContext;
--- a/src/video/cocoa/SDL_cocoawindow.m Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/cocoa/SDL_cocoawindow.m Fri Jul 28 08:43:17 2006 +0000 @@ -385,7 +385,7 @@ [nswindow release]; return -1; } -#ifdef SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL_CGL if (window->flags & SDL_WINDOW_OPENGL) { if (Cocoa_GL_SetupWindow(_this, window) < 0) { Cocoa_DestroyWindow(_this, window); @@ -535,7 +535,7 @@ SDL_WindowData *data = (SDL_WindowData *) window->driverdata; if (data) { -#ifdef SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL_CGL if (window->flags & SDL_WINDOW_OPENGL) { Cocoa_GL_CleanupWindow(_this, window); }
--- a/src/video/win32/SDL_win32opengl.c Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/win32/SDL_win32opengl.c Fri Jul 28 08:43:17 2006 +0000 @@ -25,10 +25,10 @@ /* WGL implementation of SDL OpenGL support */ -#if SDL_VIDEO_OPENGL +#if SDL_VIDEO_OPENGL_WGL #include "SDL_opengl.h" -#define DEFAULT_OPENGL_PATH "OPENGL32.DLL" +#define DEFAULT_OPENGL "OPENGL32.DLL" int @@ -47,7 +47,10 @@ } } if (path == NULL) { - path = DEFAULT_OPENGL_PATH; + path = SDL_getenv("SDL_OPENGL_LIBRARY"); + } + if (path == NULL) { + path = DEFAULT_OPENGL; } wpath = WIN_UTF8ToString(path); handle = LoadLibrary(wpath); @@ -257,19 +260,6 @@ WIN_PumpEvents(_this); } -static void -WIN_GL_Shutdown(_THIS) -{ - if (!_this->gl_data || (--_this->gl_data->initialized > 0)) { - return; - } - - WIN_GL_UnloadLibrary(_this); - - SDL_free(_this->gl_data); - _this->gl_data = NULL; -} - static int WIN_GL_Initialize(_THIS) { @@ -298,6 +288,19 @@ return 0; } +static void +WIN_GL_Shutdown(_THIS) +{ + if (!_this->gl_data || (--_this->gl_data->initialized > 0)) { + return; + } + + WIN_GL_UnloadLibrary(_this); + + SDL_free(_this->gl_data); + _this->gl_data = NULL; +} + int WIN_GL_SetupWindow(_THIS, SDL_Window * window) { @@ -479,7 +482,6 @@ _this->gl_data->wglDeleteContext((HGLRC) context); } -#endif /* SDL_VIDEO_OPENGL */ - +#endif /* SDL_VIDEO_OPENGL_WGL */ /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/win32/SDL_win32opengl.h Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/win32/SDL_win32opengl.h Fri Jul 28 08:43:17 2006 +0000 @@ -24,7 +24,7 @@ #ifndef _SDL_win32opengl_h #define _SDL_win32opengl_h -#if SDL_VIDEO_OPENGL +#if SDL_VIDEO_OPENGL_WGL struct SDL_GLDriverData { @@ -120,7 +120,7 @@ #define WGL_SAMPLES_ARB 0x2042 #endif -#endif /* SDL_VIDEO_OPENGL */ +#endif /* SDL_VIDEO_OPENGL_WGL */ #endif /* _SDL_win32opengl_h */
--- a/src/video/win32/SDL_win32video.c Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/win32/SDL_win32video.c Fri Jul 28 08:43:17 2006 +0000 @@ -123,7 +123,7 @@ device->SetWindowGrab = WIN_SetWindowGrab; device->DestroyWindow = WIN_DestroyWindow; device->GetWindowWMInfo = WIN_GetWindowWMInfo; -#ifdef SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL_WGL device->GL_LoadLibrary = WIN_GL_LoadLibrary; device->GL_GetProcAddress = WIN_GL_GetProcAddress; device->GL_CreateContext = WIN_GL_CreateContext;
--- a/src/video/win32/SDL_win32window.c Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/win32/SDL_win32window.c Fri Jul 28 08:43:17 2006 +0000 @@ -213,7 +213,7 @@ DestroyWindow(hwnd); return -1; } -#ifdef SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL_WGL if (window->flags & SDL_WINDOW_OPENGL) { if (WIN_GL_SetupWindow(_this, window) < 0) { WIN_DestroyWindow(_this, window); @@ -419,7 +419,7 @@ SDL_WindowData *data = (SDL_WindowData *) window->driverdata; if (data) { -#ifdef SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL_WGL if (window->flags & SDL_WINDOW_OPENGL) { WIN_GL_CleanupWindow(_this, window); }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/x11/SDL_x11opengl.c Fri Jul 28 08:43:17 2006 +0000 @@ -0,0 +1,507 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with _this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#include "SDL_x11video.h" + +/* GLX implementation of SDL OpenGL support */ + +#if SDL_VIDEO_OPENGL_GLX +#include "SDL_loadso.h" + +#if defined(__IRIX__) +/* IRIX doesn't have a GL library versioning system */ +#define DEFAULT_OPENGL "libGL.so" +#elif defined(__MACOSX__) +#define DEFAULT_OPENGL "/usr/X11R6/lib/libGL.1.dylib" +#elif defined(__QNXNTO__) +#define DEFAULT_OPENGL "libGL.so.3" +#else +#define DEFAULT_OPENGL "libGL.so.1" +#endif + +#ifndef GLX_ARB_multisample +#define GLX_ARB_multisample +#define GLX_SAMPLE_BUFFERS_ARB 100000 +#define GLX_SAMPLES_ARB 100001 +#endif + +#ifndef GLX_EXT_visual_rating +#define GLX_EXT_visual_rating +#define GLX_VISUAL_CAVEAT_EXT 0x20 +#define GLX_NONE_EXT 0x8000 +#define GLX_SLOW_VISUAL_EXT 0x8001 +#define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D +#endif + +#define OPENGL_REQUIRS_DLOPEN +#if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN) +#include <dlfcn.h> +#define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) +#define GL_LoadFunction dlsym +#define GL_UnloadObject dlclose +#else +#define GL_LoadObject SDL_LoadObject +#define GL_LoadFunction SDL_LoadFunction +#define GL_UnloadObject SDL_UnloadObject +#endif + +int +X11_GL_LoadLibrary(_THIS, const char *path) +{ + void *handle; + + if (_this->gl_config.driver_loaded) { + if (path) { + SDL_SetError("OpenGL library already loaded"); + return -1; + } else { + ++_this->gl_config.driver_loaded; + return 0; + } + } + if (path == NULL) { + path = SDL_getenv("SDL_OPENGL_LIBRARY"); + } + if (path == NULL) { + path = DEFAULT_OPENGL; + } + handle = GL_LoadObject(path); + if (!handle) { + return -1; + } + + /* Load new function pointers */ + _this->gl_data->glXGetProcAddress = + (void *(*)(const GLubyte *)) GL_LoadFunction(handle, + "glXGetProcAddressARB"); + _this->gl_data->glXChooseVisual = + (XVisualInfo * (*)(Display *, int, int *)) GL_LoadFunction(handle, + "glXChooseVisual"); + _this->gl_data->glXCreateContext = + (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int)) + GL_LoadFunction(handle, "glXCreateContext"); + _this->gl_data->glXDestroyContext = + (void (*)(Display *, GLXContext)) GL_LoadFunction(handle, + "glXDestroyContext"); + _this->gl_data->glXMakeCurrent = + (int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle, + "glXMakeCurrent"); + _this->gl_data->glXSwapBuffers = + (void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle, + "glXSwapBuffers"); + _this->gl_data->glXGetConfig = + (int (*)(Display *, XVisualInfo *, int, int *)) + GL_LoadFunction(handle, "glXGetConfig"); + + if (!_this->gl_data->glXChooseVisual || + !_this->gl_data->glXCreateContext || + !_this->gl_data->glXDestroyContext || + !_this->gl_data->glXMakeCurrent || + !_this->gl_data->glXSwapBuffers || !_this->gl_data->glXGetConfig) { + SDL_SetError("Could not retrieve OpenGL functions"); + return -1; + } + + _this->gl_config.dll_handle = handle; + SDL_strlcpy(_this->gl_config.driver_path, path, + SDL_arraysize(_this->gl_config.driver_path)); + _this->gl_config.driver_loaded = 1; + return 0; +} + +void * +X11_GL_GetProcAddress(_THIS, const char *proc) +{ + void *handle; + + handle = _this->gl_config.dll_handle; + if (_this->gl_data->glXGetProcAddress) { + return _this->gl_data->glXGetProcAddress((const GLubyte *) proc); + } + return GL_LoadFunction(handle, proc); +} + +static void +X11_GL_UnloadLibrary(_THIS) +{ + if (_this->gl_config.driver_loaded > 0) { + if (--_this->gl_config.driver_loaded > 0) { + return; + } + GL_UnloadObject(_this->gl_config.dll_handle); + _this->gl_config.dll_handle = NULL; + } +} + +static SDL_bool +HasExtension(const char *extension, const char *extensions) +{ + const char *start; + const char *where, *terminator; + + /* Extension names should not have spaces. */ + where = SDL_strchr(extension, ' '); + if (where || *extension == '\0') + return SDL_FALSE; + + if (!extensions) + return SDL_FALSE; + + /* It takes a bit of care to be fool-proof about parsing the + * OpenGL extensions string. Don't be fooled by sub-strings, + * etc. */ + + start = extensions; + + for (;;) { + where = SDL_strstr(start, extension); + if (!where) + break; + + terminator = where + SDL_strlen(extension); + if (where == start || *(where - 1) == ' ') + if (*terminator == ' ' || *terminator == '\0') + return SDL_TRUE; + + start = terminator; + } + return SDL_FALSE; +} + +static void +X11_GL_InitExtensions(_THIS) +{ + Display *display = ((SDL_VideoData *) _this->driverdata)->display; + int screen = ((SDL_DisplayData *) SDL_CurrentDisplay.driverdata)->screen; + XVisualInfo *vinfo; + XSetWindowAttributes xattr; + Window w; + GLXContext context; + const char *(*glXQueryExtensionsStringFunc) (Display *, int); + const char *extensions; + + vinfo = X11_GL_GetVisual(_this, display, screen); + if (!vinfo) { + return; + } + xattr.background_pixel = 0; + xattr.border_pixel = 0; + xattr.colormap = + XCreateColormap(display, RootWindow(display, screen), vinfo->visual, + AllocNone); + w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, + vinfo->depth, InputOutput, vinfo->visual, + (CWBackPixel | CWBorderPixel | CWColormap), &xattr); + context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); + if (context) { + _this->gl_data->glXMakeCurrent(display, w, context); + } + XFree(vinfo); + + glXQueryExtensionsStringFunc = + (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, + "glXQueryExtensionsString"); + if (glXQueryExtensionsStringFunc) { + extensions = glXQueryExtensionsStringFunc(display, screen); + } else { + extensions = NULL; + } + + /* Check for SGI_swap_control */ + if (HasExtension("SGI_swap_control", extensions)) { + _this->gl_data->glXSwapIntervalSGI = + (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); + } + + /* Check for GLX_MESA_swap_control */ + if (HasExtension("GLX_MESA_swap_control", extensions)) { + _this->gl_data->glXSwapIntervalMESA = + (GLint(*)(unsigned)) X11_GL_GetProcAddress(_this, + "glXSwapIntervalMESA"); + _this->gl_data->glXGetSwapIntervalMESA = + (GLint(*)(void)) X11_GL_GetProcAddress(_this, + "glXGetSwapIntervalMESA"); + } + + /* Check for GLX_EXT_visual_rating */ + if (HasExtension("GLX_EXT_visual_rating", extensions)) { + _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; + } + + if (context) { + _this->gl_data->glXMakeCurrent(display, None, NULL); + _this->gl_data->glXDestroyContext(display, context); + } + XDestroyWindow(display, w); + X11_PumpEvents(_this); +} + +int +X11_GL_Initialize(_THIS) +{ + if (_this->gl_data) { + ++_this->gl_data->initialized; + return 0; + } + + _this->gl_data = + (struct SDL_GLDriverData *) SDL_calloc(1, + sizeof(struct + SDL_GLDriverData)); + if (!_this->gl_data) { + SDL_OutOfMemory(); + return -1; + } + _this->gl_data->initialized = 1; + + if (X11_GL_LoadLibrary(_this, NULL) < 0) { + return -1; + } + + /* Initialize extensions */ + X11_GL_InitExtensions(_this); + + return 0; +} + +void +X11_GL_Shutdown(_THIS) +{ + if (!_this->gl_data || (--_this->gl_data->initialized > 0)) { + return; + } + + X11_GL_UnloadLibrary(_this); + + SDL_free(_this->gl_data); + _this->gl_data = NULL; +} + +XVisualInfo * +X11_GL_GetVisual(_THIS, Display * display, int screen) +{ + XVisualInfo *vinfo; + + /* 64 seems nice. */ + int attribs[64]; + int i; + + /* Setup our GLX attributes according to the gl_config. */ + i = 0; + attribs[i++] = GLX_RGBA; + attribs[i++] = GLX_RED_SIZE; + attribs[i++] = _this->gl_config.red_size; + attribs[i++] = GLX_GREEN_SIZE; + attribs[i++] = _this->gl_config.green_size; + attribs[i++] = GLX_BLUE_SIZE; + attribs[i++] = _this->gl_config.blue_size; + + if (_this->gl_config.alpha_size) { + attribs[i++] = GLX_ALPHA_SIZE; + attribs[i++] = _this->gl_config.alpha_size; + } + + if (_this->gl_config.buffer_size) { + attribs[i++] = GLX_BUFFER_SIZE; + attribs[i++] = _this->gl_config.buffer_size; + } + + if (_this->gl_config.double_buffer) { + attribs[i++] = GLX_DOUBLEBUFFER; + } + + attribs[i++] = GLX_DEPTH_SIZE; + attribs[i++] = _this->gl_config.depth_size; + + if (_this->gl_config.stencil_size) { + attribs[i++] = GLX_STENCIL_SIZE; + attribs[i++] = _this->gl_config.stencil_size; + } + + if (_this->gl_config.accum_red_size) { + attribs[i++] = GLX_ACCUM_RED_SIZE; + attribs[i++] = _this->gl_config.accum_red_size; + } + + if (_this->gl_config.accum_green_size) { + attribs[i++] = GLX_ACCUM_GREEN_SIZE; + attribs[i++] = _this->gl_config.accum_green_size; + } + + if (_this->gl_config.accum_blue_size) { + attribs[i++] = GLX_ACCUM_BLUE_SIZE; + attribs[i++] = _this->gl_config.accum_blue_size; + } + + if (_this->gl_config.accum_alpha_size) { + attribs[i++] = GLX_ACCUM_ALPHA_SIZE; + attribs[i++] = _this->gl_config.accum_alpha_size; + } + + if (_this->gl_config.stereo) { + attribs[i++] = GLX_STEREO; + } + + if (_this->gl_config.multisamplebuffers) { + attribs[i++] = GLX_SAMPLE_BUFFERS_ARB; + attribs[i++] = _this->gl_config.multisamplebuffers; + } + + if (_this->gl_config.multisamplesamples) { + attribs[i++] = GLX_SAMPLES_ARB; + attribs[i++] = _this->gl_config.multisamplesamples; + } + + if (_this->gl_config.accelerated >= 0 + && _this->gl_data->HAS_GLX_EXT_visual_rating) { + attribs[i++] = GLX_VISUAL_CAVEAT_EXT; + attribs[i++] = GLX_NONE_EXT; + } +#ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ + if (!SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) { + attribs[i++] = GLX_X_VISUAL_TYPE; + attribs[i++] = GLX_DIRECT_COLOR; + } +#endif + attribs[i++] = None; + + vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); +#ifdef GLX_DIRECT_COLOR + if (!vinfo && !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) { /* No DirectColor visual? Try again.. */ + attribs[i - 3] = None; + vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); + } +#endif + if (!vinfo) { + SDL_SetError("Couldn't find matching GLX visual"); + } + return vinfo; +} + +SDL_GLContext +X11_GL_CreateContext(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + int screen = + ((SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata)-> + screen; + XWindowAttributes xattr; + XVisualInfo v, *vinfo; + int n; + GLXContext context = NULL; + + /* We do _this to create a clean separation between X and GLX errors. */ + XSync(display, False); + XGetWindowAttributes(display, data->window, &xattr); + v.screen = screen; + v.visualid = XVisualIDFromVisual(xattr.visual); + vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); + if (vinfo) { + context = + _this->gl_data->glXCreateContext(display, vinfo, NULL, True); + XFree(vinfo); + } + XSync(display, False); + + if (!context) { + SDL_SetError("Could not create GL context"); + } + return (SDL_GLContext) context; +} + +int +X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) +{ + Display *display = ((SDL_VideoData *) _this->driverdata)->display; + Window drawable = + (window ? ((SDL_WindowData *) window->driverdata)->window : None); + GLXContext glx_context = (GLXContext) context; + int status; + + status = 0; + if (!_this->gl_data->glXMakeCurrent(display, drawable, glx_context)) { + SDL_SetError("Unable to make GL context current"); + status = -1; + } + XSync(display, False); + + return (status); +} + +int +X11_GL_SetSwapInterval(_THIS, int interval) +{ + int status; + + if (_this->gl_data->glXSwapIntervalMESA) { + status = _this->gl_data->glXSwapIntervalMESA(interval); + if (status != 0) { + SDL_SetError("glxSwapIntervalMESA failed"); + status = -1; + } + } else if (_this->gl_data->glXSwapIntervalSGI) { + status = _this->gl_data->glXSwapIntervalSGI(interval); + if (status != 0) { + SDL_SetError("glxSwapIntervalSGI failed"); + status = -1; + } + } else { + SDL_Unsupported(); + status = -1; + } + return status; +} + +int +X11_GL_GetSwapInterval(_THIS) +{ + if (_this->gl_data->glXGetSwapIntervalMESA) { + return _this->gl_data->glXGetSwapIntervalMESA(); + } else { + SDL_Unsupported(); + return -1; + } +} + +void +X11_GL_SwapWindow(_THIS, SDL_Window * window) +{ + SDL_WindowData *data = (SDL_WindowData *) window->driverdata; + Display *display = data->videodata->display; + + _this->gl_data->glXSwapBuffers(display, data->window); +} + +void +X11_GL_DeleteContext(_THIS, SDL_GLContext context) +{ + Display *display = ((SDL_VideoData *) _this->driverdata)->display; + GLXContext glx_context = (GLXContext) context; + + _this->gl_data->glXDestroyContext(display, glx_context); +} + +#endif /* SDL_VIDEO_OPENGL_GLX */ + +/* vi: set ts=4 sw=4 expandtab: */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/video/x11/SDL_x11opengl.h Fri Jul 28 08:43:17 2006 +0000 @@ -0,0 +1,79 @@ +/* + SDL - Simple DirectMedia Layer + Copyright (C) 1997-2006 Sam Lantinga + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library; if not, write to the Free Software + Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + + Sam Lantinga + slouken@libsdl.org +*/ +#include "SDL_config.h" + +#ifndef _SDL_x11opengl_h +#define _SDL_x11opengl_h + +#if SDL_VIDEO_OPENGL_GLX +#include "SDL_opengl.h" +#include <GL/glx.h> + +struct SDL_GLDriverData +{ + int initialized; + SDL_bool HAS_GLX_EXT_visual_rating; + + void *(*glXGetProcAddress) (const GLubyte * procName); + + XVisualInfo *(*glXChooseVisual) + (Display * dpy, int screen, int *attribList); + + GLXContext(*glXCreateContext) + (Display * dpy, XVisualInfo * vis, GLXContext shareList, Bool direct); + + void (*glXDestroyContext) + (Display * dpy, GLXContext ctx); + + Bool(*glXMakeCurrent) + (Display * dpy, GLXDrawable drawable, GLXContext ctx); + + void (*glXSwapBuffers) + (Display * dpy, GLXDrawable drawable); + + int (*glXGetConfig) + (Display * dpy, XVisualInfo * visual_info, int attrib, int *value); + + int (*glXSwapIntervalSGI) (int interval); + GLint(*glXSwapIntervalMESA) (unsigned interval); + GLint(*glXGetSwapIntervalMESA) (void); +}; + +/* OpenGL functions */ +extern int X11_GL_LoadLibrary(_THIS, const char *path); +extern void *X11_GL_GetProcAddress(_THIS, const char *proc); +extern int X11_GL_Initialize(_THIS); +extern void X11_GL_Shutdown(_THIS); +extern XVisualInfo *X11_GL_GetVisual(_THIS, Display * display, int screen); +extern SDL_GLContext X11_GL_CreateContext(_THIS, SDL_Window * window); +extern int X11_GL_MakeCurrent(_THIS, SDL_Window * window, + SDL_GLContext context); +extern int X11_GL_SetSwapInterval(_THIS, int interval); +extern int X11_GL_GetSwapInterval(_THIS); +extern void X11_GL_SwapWindow(_THIS, SDL_Window * window); +extern void X11_GL_DeleteContext(_THIS, SDL_GLContext context); + +#endif /* SDL_VIDEO_OPENGL_GLX */ + +#endif /* _SDL_x11opengl_h */ + +/* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11sym.h Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/x11/SDL_x11sym.h Fri Jul 28 08:43:17 2006 +0000 @@ -20,499 +20,185 @@ slouken@libsdl.org */ +/* *INDENT-OFF* */ + SDL_X11_MODULE(BASEXLIB) - SDL_X11_SYM(XClassHint *, XAllocClassHint, (void), (), return) - SDL_X11_SYM(Status, XAllocColor, (Display * a, Colormap b, XColor * c), - (a, b, c), return) SDL_X11_SYM(XSizeHints *, XAllocSizeHints, - (void), (), - return) SDL_X11_SYM(XWMHints *, - XAllocWMHints, - (void), (), - return) - SDL_X11_SYM(int, XChangePointerControl, - (Display * a, Bool b, Bool c, int d, int e, int f), (a, b, c, d, - e, f), - return) SDL_X11_SYM(int, XChangeProperty, (Display * a, - Window b, Atom c, - Atom d, int e, int f, - _Xconst unsigned char - *g, int h), (a, b, c, - d, e, f, - g, h), - return) SDL_X11_SYM(int, - XChangeWindowAttributes, - (Display * a, Window b, - unsigned long c, - XSetWindowAttributes * - d), (a, b, c, d), return) - SDL_X11_SYM(Bool, XCheckTypedEvent, (Display * a, int b, XEvent * c), - (a, b, c), return) SDL_X11_SYM(int, XClearWindow, (Display * a, - Window b), - (a, b), return) SDL_X11_SYM(int, - XCloseDisplay, - (Display - * - a), - (a), - return) - SDL_X11_SYM(Colormap, XCreateColormap, - (Display * a, Window b, Visual * c, int d), (a, b, c, d), - return) SDL_X11_SYM(Cursor, XCreatePixmapCursor, (Display * a, - Pixmap b, - Pixmap c, - XColor * d, - XColor * e, - unsigned int - f, - unsigned int - g), (a, b, c, - d, e, f, - g), - return) SDL_X11_SYM(GC, XCreateGC, - (Display * a, - Drawable b, - unsigned long c, - XGCValues * d), (a, b, - c, - d), - return) - SDL_X11_SYM(XImage *, XCreateImage, - (Display * a, Visual * b, unsigned int c, int d, int e, char *f, - unsigned int g, unsigned int h, int i, int j), (a, b, c, d, e, - f, g, h, i, j), -return) SDL_X11_SYM(Pixmap, XCreatePixmap, (Display * a, -Drawable b, -unsigned int c, -unsigned int d, -unsigned int e), (a, - b, - c, - d, - e), -return) SDL_X11_SYM(Pixmap, -XCreatePixmapFromBitmapData, -(Display * a, -Drawable b, char *c, -unsigned int d, -unsigned int e, -unsigned long f, unsigned long g, unsigned int h), (a, b, c, d, e, f, g, h), return) - SDL_X11_SYM(Window, XCreateSimpleWindow, - (Display * a, Window b, int c, int d, unsigned int e, - unsigned int f, unsigned int g, unsigned long h, - unsigned long i), (a, b, c, d, e, f, g, h, i), -return) SDL_X11_SYM(Window, XCreateWindow, (Display * a, -Window b, int c, -int d, -unsigned int e, -unsigned int f, -unsigned int g, -int h, -unsigned int i, -Visual * j, -unsigned long k, -XSetWindowAttributes -* l), (a, b, c, d, - e, f, g, h, - i, j, k, l), -return) SDL_X11_SYM(int, XDefineCursor, (Display * a, Window b, Cursor c), (a, b, c), return) - SDL_X11_SYM(int, XDeleteProperty, (Display * a, Window b, Atom c), (a, b, c), - return) SDL_X11_SYM(int, XDestroyWindow, (Display * a, - Window b), (a, b), - return) SDL_X11_SYM(char *, XDisplayName, - (_Xconst char *a), (a), - return) - SDL_X11_SYM(int, XEventsQueued, (Display * a, int b), (a, b), - return) SDL_X11_SYM(Bool, XFilterEvent, (XEvent * event, - Window w), (event, w), - return) SDL_X11_SYM(int, XFlush, - (Display * a), (a), - return) - SDL_X11_SYM(int, XFree, (void *a), (a), return) SDL_X11_SYM(int, - XFreeColormap, - (Display * - a, - Colormap - b), (a, b), - return) - SDL_X11_SYM(int, XFreeColors, - (Display * a, Colormap b, unsigned long *c, int d, unsigned long e), - (a, b, c, d, e), return) SDL_X11_SYM(int, XFreeCursor, - (Display * a, Cursor b), - (a, b), return) - SDL_X11_SYM(int, XFreeGC, (Display * a, GC b), (a, b), - return) SDL_X11_SYM(int, XFreeModifiermap, - (XModifierKeymap * a), (a), - return) SDL_X11_SYM(int, XFreePixmap, - (Display * a, - Pixmap b), (a, b), - return) - SDL_X11_SYM(int, XGetErrorDatabaseText, - (Display * a, _Xconst char *b, _Xconst char *c, _Xconst char *d, - char *e, int f), (a, b, c, d, e, f), -return) SDL_X11_SYM(XModifierKeymap *, XGetModifierMapping, (Display * a), (a), return) SDL_X11_SYM(int, XGetPointerControl, - (Display * a, int *b, int *c, - int *d), (a, b, c, d), return) - SDL_X11_SYM(int, XGetScreenSaver, - (Display * a, int *b, int *c, int *d, int *e), (a, b, c, d, e), - return) SDL_X11_SYM(XVisualInfo *, XGetVisualInfo, (Display * a, - long b, - XVisualInfo - * c, - int *d), (a, - b, - c, - d), - return) SDL_X11_SYM(XWMHints *, - XGetWMHints, - (Display * a, - Window b), (a, b), - return) - SDL_X11_SYM(Status, XGetWindowAttributes, - (Display * a, Window b, XWindowAttributes * c), (a, b, c), - return) SDL_X11_SYM(int, XGrabKeyboard, (Display * a, Window b, - Bool c, int d, int e, - Time f), (a, b, c, d, - e, f), - return) SDL_X11_SYM(int, XGrabPointer, - (Display * a, Window b, - Bool c, - unsigned int d, int e, - int f, Window g, - Cursor h, Time i), (a, - b, - c, - d, - e, - f, - g, - h, - i), - return) - SDL_X11_SYM(Status, XIconifyWindow, (Display * a, Window b, int c), - (a, b, c), return) SDL_X11_SYM(int, XInstallColormap, - (Display * a, Colormap b), (a, - b), - return) SDL_X11_SYM(KeyCode, - XKeysymToKeycode, - (Display * - a, - KeySym b), - (a, b), return) - SDL_X11_SYM(Atom, XInternAtom, (Display * a, _Xconst char *b, Bool c), - (a, b, c), return) SDL_X11_SYM(XPixmapFormatValues *, - XListPixmapFormats, (Display * a, - int *b), (a, - b), - return) SDL_X11_SYM(int, - XLookupString, - (XKeyEvent * - a, char *b, - int c, - KeySym * d, - XComposeStatus - * e), (a, - b, - c, - d, - e), - return) - SDL_X11_SYM(int, XMapRaised, (Display * a, Window b), (a, b), - return) SDL_X11_SYM(int, XMapWindow, (Display * a, Window b), - (a, b), return) SDL_X11_SYM(int, - XMaskEvent, - (Display * a, - long b, - XEvent * c), - (a, b, c), return) - SDL_X11_SYM(Status, XMatchVisualInfo, - (Display * a, int b, int c, int d, XVisualInfo * e), (a, b, c, d, e), - return) SDL_X11_SYM(int, XMissingExtension, (Display * a, - _Xconst char *b), - (a, b), return) SDL_X11_SYM(int, - XMoveResizeWindow, - (Display * a, - Window b, - int c, int d, - unsigned int - e, - unsigned int - f), (a, b, c, - d, e, f), - return) - SDL_X11_SYM(int, XMoveWindow, (Display * a, Window b, int c, int d), - (a, b, c, d), return) SDL_X11_SYM(int, XNextEvent, (Display * a, - XEvent * b), - (a, b), - return) SDL_X11_SYM(Display - *, - XOpenDisplay, - (_Xconst - char - *a), - (a), return) - SDL_X11_SYM(int, XPeekEvent, (Display * a, XEvent * b), (a, b), - return) SDL_X11_SYM(int, XPending, (Display * a), (a), - return) SDL_X11_SYM(int, XPutImage, - (Display * a, - Drawable b, GC c, - XImage * d, int e, - int f, int g, int h, - unsigned int i, - unsigned int j), (a, - b, - c, - d, - e, - f, - g, - h, - i, - j), - return) - SDL_X11_SYM(int, XQueryColors, (Display * a, Colormap b, XColor * c, int d), - (a, b, c, d), return) SDL_X11_SYM(int, XQueryKeymap, - (Display * a, char *b), (a, - b), - return) SDL_X11_SYM(Bool, - XQueryPointer, - (Display - * a, - Window - b, - Window * - c, - Window * - d, - int *e, - int *f, - int *g, - int *h, - unsigned - int *i), - (a, b, c, - d, e, f, - g, h, - i), return) - SDL_X11_SYM(int, XRaiseWindow, (Display * a, Window b), (a, b), - return) SDL_X11_SYM(int, XReparentWindow, (Display * a, - Window b, Window c, - int d, int e), (a, b, - c, d, - e), - return) SDL_X11_SYM(int, XResizeWindow, - (Display * a, Window b, - unsigned int c, - unsigned int d), (a, - b, - c, - d), - return) - SDL_X11_SYM(int, XSelectInput, (Display * a, Window b, long c), (a, b, c), - return) SDL_X11_SYM(Status, XSendEvent, (Display * a, Window b, - Bool c, long d, - XEvent * e), (a, b, c, - d, e), - return) SDL_X11_SYM(int, XSetClassHint, - (Display * a, Window b, - XClassHint * c), (a, - b, - c), - return) - SDL_X11_SYM(XErrorHandler, XSetErrorHandler, (XErrorHandler a), (a), - return) SDL_X11_SYM(XIOErrorHandler, XSetIOErrorHandler, - (XIOErrorHandler a), (a), - return) SDL_X11_SYM(int, XSetScreenSaver, - (Display * a, int b, - int c, int d, int e), - (a, b, c, d, e), return) - SDL_X11_SYM(int, XSetTransientForHint, (Display * a, Window b, Window c), - (a, b, c), return) SDL_X11_SYM(int, XSetWMHints, (Display * a, - Window b, - XWMHints * c), - (a, b, c), - return) SDL_X11_SYM(void, - XSetTextProperty, - (Display * - a, - Window b, - XTextProperty - * c, - Atom d), - (a, b, c, d),) -SDL_X11_SYM(void, XSetWMNormalHints, (Display * a, Window b, XSizeHints * c), - (a, b, c),) -SDL_X11_SYM(Status, XSetWMProtocols, - (Display * a, Window b, Atom * c, int d), (a, b, c, d), return) -SDL_X11_SYM(int, XSetWindowBackground, - (Display * a, Window b, unsigned long c), (a, b, c), return) -SDL_X11_SYM(int, XSetWindowBackgroundPixmap, - (Display * a, Window b, Pixmap c), (a, b, c), return) -SDL_X11_SYM(int, XSetWindowColormap, (Display * a, Window b, Colormap c), - (a, b, c), return) -SDL_X11_SYM(int, XStoreColors, (Display * a, Colormap b, XColor * c, int d), - (a, b, c, d), return) -SDL_X11_SYM(Status, XStringListToTextProperty, - (char **a, int b, XTextProperty * c), (a, b, c), return) -SDL_X11_SYM(int, XSync, (Display * a, Bool b), (a, b), return) -SDL_X11_SYM(int, XUngrabKeyboard, (Display * a, Time b), (a, b), return) -SDL_X11_SYM(int, XUngrabPointer, (Display * a, Time b), (a, b), return) -SDL_X11_SYM(int, XUnmapWindow, (Display * a, Window b), (a, b), return) -SDL_X11_SYM(int, XWarpPointer, - (Display * a, Window b, Window c, int d, int e, unsigned int f, - unsigned int g, int h, int i), (a, b, c, d, e, f, g, h, i), - return) -SDL_X11_SYM(VisualID, XVisualIDFromVisual, (Visual * a), (a), return) -SDL_X11_SYM(XExtDisplayInfo *, XextAddDisplay, - (XExtensionInfo * a, Display * b, char *c, XExtensionHooks * d, - int e, XPointer f), (a, b, c, d, e, f), return) -SDL_X11_SYM(XExtensionInfo *, XextCreateExtension, (void), (), return) -SDL_X11_SYM(void, XextDestroyExtension, (XExtensionInfo * a), (a),) -SDL_X11_SYM(XExtDisplayInfo *, XextFindDisplay, - (XExtensionInfo * a, Display * b), (a, b), return) -SDL_X11_SYM(int, XextRemoveDisplay, (XExtensionInfo * a, Display * b), - (a, b), return) -SDL_X11_SYM(Bool, XQueryExtension, - (Display * a, _Xconst char *b, int *c, int *d, int *e), (a, b, c, - d, e), - return) -SDL_X11_SYM(char *, XDisplayString, (Display * a), (a), return) -SDL_X11_SYM(int, XGetErrorText, (Display * a, int b, char *c, int d), - (a, b, c, d), return) -SDL_X11_SYM(void, _XEatData, (Display * a, unsigned long b), (a, b),) -SDL_X11_SYM(void, _XFlush, (Display * a), (a),) -SDL_X11_SYM(void, _XFlushGCCache, (Display * a, GC b), (a, b),) -SDL_X11_SYM(int, _XRead, (Display * a, char *b, long c), (a, b, c), return) -SDL_X11_SYM(void, _XReadPad, (Display * a, char *b, long c), (a, b, c),) -SDL_X11_SYM(void, _XSend, (Display * a, _Xconst char *b, long c), (a, b, c),) -SDL_X11_SYM(Status, _XReply, (Display * a, xReply * b, int c, Bool d), - (a, b, c, d), return) -SDL_X11_SYM(unsigned long, _XSetLastRequestRead, - (Display * a, xGenericReply * b), (a, b), return) -SDL_X11_SYM(SDL_X11_XSynchronizeRetType, XSynchronize, (Display * a, Bool b), - (a, b), return) -SDL_X11_SYM(SDL_X11_XESetWireToEventRetType, XESetWireToEvent, - (Display * a, int b, SDL_X11_XESetWireToEventRetType c), (a, b, - c), - return) -SDL_X11_SYM(SDL_X11_XESetEventToWireRetType, XESetEventToWire, - (Display * a, int b, SDL_X11_XESetEventToWireRetType c), (a, b, - c), - return) -SDL_X11_SYM(XExtensionErrorHandler, XSetExtensionErrorHandler, - (XExtensionErrorHandler a), (a), return) +SDL_X11_SYM(XClassHint*,XAllocClassHint,(void),(),return) +SDL_X11_SYM(Status,XAllocColor,(Display* a,Colormap b,XColor* c),(a,b,c),return) +SDL_X11_SYM(XSizeHints*,XAllocSizeHints,(void),(),return) +SDL_X11_SYM(XWMHints*,XAllocWMHints,(void),(),return) +SDL_X11_SYM(int,XChangePointerControl,(Display* a,Bool b,Bool c,int d,int e,int f),(a,b,c,d,e,f),return) +SDL_X11_SYM(int,XChangeProperty,(Display* a,Window b,Atom c,Atom d,int e,int f,_Xconst unsigned char* g,int h),(a,b,c,d,e,f,g,h),return) +SDL_X11_SYM(int,XChangeWindowAttributes,(Display* a,Window b,unsigned long c,XSetWindowAttributes* d),(a,b,c,d),return) +SDL_X11_SYM(Bool,XCheckWindowEvent,(Display* a,Window b,long c,XEvent* d),(a,b,c,d),return) +SDL_X11_SYM(int,XClearWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XCloseDisplay,(Display* a),(a),return) +SDL_X11_SYM(Colormap,XCreateColormap,(Display* a,Window b,Visual* c,int d),(a,b,c,d),return) +SDL_X11_SYM(Cursor,XCreatePixmapCursor,(Display* a,Pixmap b,Pixmap c,XColor* d,XColor* e,unsigned int f,unsigned int g),(a,b,c,d,e,f,g),return) +SDL_X11_SYM(GC,XCreateGC,(Display* a,Drawable b,unsigned long c,XGCValues* d),(a,b,c,d),return) +SDL_X11_SYM(XImage*,XCreateImage,(Display* a,Visual* b,unsigned int c,int d,int e,char* f,unsigned int g,unsigned int h,int i,int j),(a,b,c,d,e,f,g,h,i,j),return) +SDL_X11_SYM(Pixmap,XCreatePixmap,(Display* a,Drawable b,unsigned int c,unsigned int d,unsigned int e),(a,b,c,d,e),return) +SDL_X11_SYM(Pixmap,XCreatePixmapFromBitmapData,(Display* a,Drawable b,char* c,unsigned int d,unsigned int e,unsigned long f,unsigned long g,unsigned int h),(a,b,c,d,e,f,g,h),return) +SDL_X11_SYM(Window,XCreateSimpleWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,unsigned long h,unsigned long i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(Window,XCreateWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f,unsigned int g,int h,unsigned int i,Visual* j,unsigned long k,XSetWindowAttributes* l),(a,b,c,d,e,f,g,h,i,j,k,l),return) +SDL_X11_SYM(int,XDefineCursor,(Display* a,Window b,Cursor c),(a,b,c),return) +SDL_X11_SYM(int,XDeleteProperty,(Display* a,Window b,Atom c),(a,b,c),return) +SDL_X11_SYM(int,XDestroyWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(char*,XDisplayName,(_Xconst char* a),(a),return) +SDL_X11_SYM(int,XEventsQueued,(Display* a,int b),(a,b),return) +SDL_X11_SYM(Bool,XFilterEvent,(XEvent *event, Window w),(event,w),return) +SDL_X11_SYM(int,XFlush,(Display* a),(a),return) +SDL_X11_SYM(int,XFree,(void*a),(a),return) +SDL_X11_SYM(int,XFreeColormap,(Display* a,Colormap b),(a,b),return) +SDL_X11_SYM(int,XFreeColors,(Display* a,Colormap b,unsigned long* c,int d,unsigned long e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XFreeCursor,(Display* a,Cursor b),(a,b),return) +SDL_X11_SYM(int,XFreeGC,(Display* a,GC b),(a,b),return) +SDL_X11_SYM(int,XFreeModifiermap,(XModifierKeymap* a),(a),return) +SDL_X11_SYM(int,XFreePixmap,(Display* a,Pixmap b),(a,b),return) +SDL_X11_SYM(int,XGetErrorDatabaseText,(Display* a,_Xconst char* b,_Xconst char* c,_Xconst char* d,char* e,int f),(a,b,c,d,e,f),return) +SDL_X11_SYM(XModifierKeymap*,XGetModifierMapping,(Display* a),(a),return) +SDL_X11_SYM(int,XGetPointerControl,(Display* a,int* b,int* c,int* d),(a,b,c,d),return) +SDL_X11_SYM(int,XGetScreenSaver,(Display* a,int* b,int* c,int* d, int* e),(a,b,c,d,e),return) +SDL_X11_SYM(XVisualInfo*,XGetVisualInfo,(Display* a,long b,XVisualInfo* c,int* d),(a,b,c,d),return) +SDL_X11_SYM(XWMHints*,XGetWMHints,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(Status,XGetWindowAttributes,(Display* a,Window b,XWindowAttributes* c),(a,b,c),return) +SDL_X11_SYM(int,XGrabKeyboard,(Display* a,Window b,Bool c,int d,int e,Time f),(a,b,c,d,e,f),return) +SDL_X11_SYM(int,XGrabPointer,(Display* a,Window b,Bool c,unsigned int d,int e,int f,Window g,Cursor h,Time i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(Status,XIconifyWindow,(Display* a,Window b,int c),(a,b,c),return) +SDL_X11_SYM(int,XInstallColormap,(Display* a,Colormap b),(a,b),return) +SDL_X11_SYM(KeyCode,XKeysymToKeycode,(Display* a,KeySym b),(a,b),return) +SDL_X11_SYM(Atom,XInternAtom,(Display* a,_Xconst char* b,Bool c),(a,b,c),return) +SDL_X11_SYM(XPixmapFormatValues*,XListPixmapFormats,(Display* a,int* b),(a,b),return) +SDL_X11_SYM(int,XLookupString,(XKeyEvent* a,char* b,int c,KeySym* d,XComposeStatus* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XMapRaised,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XMapWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XMaskEvent,(Display* a,long b,XEvent* c),(a,b,c),return) +SDL_X11_SYM(Status,XMatchVisualInfo,(Display* a,int b,int c,int d,XVisualInfo* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XMissingExtension,(Display* a,_Xconst char* b),(a,b),return) +SDL_X11_SYM(int,XMoveResizeWindow,(Display* a,Window b,int c,int d,unsigned int e,unsigned int f),(a,b,c,d,e,f),return) +SDL_X11_SYM(int,XMoveWindow,(Display* a,Window b,int c,int d),(a,b,c,d),return) +SDL_X11_SYM(int,XNextEvent,(Display* a,XEvent* b),(a,b),return) +SDL_X11_SYM(Display*,XOpenDisplay,(_Xconst char* a),(a),return) +SDL_X11_SYM(int,XPeekEvent,(Display* a,XEvent* b),(a,b),return) +SDL_X11_SYM(int,XPending,(Display* a),(a),return) +SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return) +SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return) +SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return) +SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(int,XRaiseWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XReparentWindow,(Display* a,Window b,Window c,int d,int e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XResizeWindow,(Display* a,Window b,unsigned int c,unsigned int d),(a,b,c,d),return) +SDL_X11_SYM(int,XSelectInput,(Display* a,Window b,long c),(a,b,c),return) +SDL_X11_SYM(Status,XSendEvent,(Display* a,Window b,Bool c,long d,XEvent* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XSetClassHint,(Display* a,Window b,XClassHint* c),(a,b,c),return) +SDL_X11_SYM(XErrorHandler,XSetErrorHandler,(XErrorHandler a),(a),return) +SDL_X11_SYM(XIOErrorHandler,XSetIOErrorHandler,(XIOErrorHandler a),(a),return) +SDL_X11_SYM(int,XSetScreenSaver,(Display* a,int b,int c,int d,int e),(a,b,c,d,e),return) +SDL_X11_SYM(int,XSetTransientForHint,(Display* a,Window b,Window c),(a,b,c),return) +SDL_X11_SYM(int,XSetWMHints,(Display* a,Window b,XWMHints* c),(a,b,c),return) +SDL_X11_SYM(void,XSetTextProperty,(Display* a,Window b,XTextProperty* c,Atom d),(a,b,c,d),) +SDL_X11_SYM(void,XSetWMNormalHints,(Display* a,Window b,XSizeHints* c),(a,b,c),) +SDL_X11_SYM(Status,XSetWMProtocols,(Display* a,Window b,Atom* c,int d),(a,b,c,d),return) +SDL_X11_SYM(int,XSetWindowBackground,(Display* a,Window b,unsigned long c),(a,b,c),return) +SDL_X11_SYM(int,XSetWindowBackgroundPixmap,(Display* a,Window b,Pixmap c),(a,b,c),return) +SDL_X11_SYM(int,XSetWindowColormap,(Display* a,Window b,Colormap c),(a,b,c),return) +SDL_X11_SYM(int,XStoreColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return) +SDL_X11_SYM(Status,XStringListToTextProperty,(char** a,int b,XTextProperty* c),(a,b,c),return) +SDL_X11_SYM(int,XSync,(Display* a,Bool b),(a,b),return) +SDL_X11_SYM(int,XUngrabKeyboard,(Display* a,Time b),(a,b),return) +SDL_X11_SYM(int,XUngrabPointer,(Display* a,Time b),(a,b),return) +SDL_X11_SYM(int,XUnmapWindow,(Display* a,Window b),(a,b),return) +SDL_X11_SYM(int,XWarpPointer,(Display* a,Window b,Window c,int d,int e,unsigned int f,unsigned int g,int h, int i),(a,b,c,d,e,f,g,h,i),return) +SDL_X11_SYM(VisualID,XVisualIDFromVisual,(Visual* a),(a),return) +SDL_X11_SYM(XExtDisplayInfo*,XextAddDisplay,(XExtensionInfo* a,Display* b,char* c,XExtensionHooks* d,int e,XPointer f),(a,b,c,d,e,f),return) +SDL_X11_SYM(XExtensionInfo*,XextCreateExtension,(void),(),return) +SDL_X11_SYM(void,XextDestroyExtension,(XExtensionInfo* a),(a),) +SDL_X11_SYM(XExtDisplayInfo*,XextFindDisplay,(XExtensionInfo* a,Display* b),(a,b),return) +SDL_X11_SYM(int,XextRemoveDisplay,(XExtensionInfo* a,Display* b),(a,b),return) +SDL_X11_SYM(Bool,XQueryExtension,(Display* a,_Xconst char* b,int* c,int* d,int* e),(a,b,c,d,e),return) +SDL_X11_SYM(char *,XDisplayString,(Display* a),(a),return) +SDL_X11_SYM(int,XGetErrorText,(Display* a,int b,char* c,int d),(a,b,c,d),return) +SDL_X11_SYM(void,_XEatData,(Display* a,unsigned long b),(a,b),) +SDL_X11_SYM(void,_XFlush,(Display* a),(a),) +SDL_X11_SYM(void,_XFlushGCCache,(Display* a,GC b),(a,b),) +SDL_X11_SYM(int,_XRead,(Display* a,char* b,long c),(a,b,c),return) +SDL_X11_SYM(void,_XReadPad,(Display* a,char* b,long c),(a,b,c),) +SDL_X11_SYM(void,_XSend,(Display* a,_Xconst char* b,long c),(a,b,c),) +SDL_X11_SYM(Status,_XReply,(Display* a,xReply* b,int c,Bool d),(a,b,c,d),return) +SDL_X11_SYM(unsigned long,_XSetLastRequestRead,(Display* a,xGenericReply* b),(a,b),return) +SDL_X11_SYM(SDL_X11_XSynchronizeRetType,XSynchronize,(Display* a,Bool b),(a,b),return) +SDL_X11_SYM(SDL_X11_XESetWireToEventRetType,XESetWireToEvent,(Display* a,int b,SDL_X11_XESetWireToEventRetType c),(a,b,c),return) +SDL_X11_SYM(SDL_X11_XESetEventToWireRetType,XESetEventToWire,(Display* a,int b,SDL_X11_XESetEventToWireRetType c),(a,b,c),return) +SDL_X11_SYM(XExtensionErrorHandler,XSetExtensionErrorHandler,(XExtensionErrorHandler a),(a),return) + #if NeedWidePrototypes -SDL_X11_SYM(KeySym, XKeycodeToKeysym, (Display * a, unsigned int b, int c), - (a, b, c), return) +SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,unsigned int b,int c),(a,b,c),return) #else -SDL_X11_SYM(KeySym, XKeycodeToKeysym, (Display * a, KeyCode b, int c), - (a, b, c), return) +SDL_X11_SYM(KeySym,XKeycodeToKeysym,(Display* a,KeyCode b,int c),(a,b,c),return) #endif + #ifdef X_HAVE_UTF8_STRING SDL_X11_MODULE(UTF8) -SDL_X11_SYM(int, Xutf8TextListToTextProperty, - (Display * a, char **b, int c, XICCEncodingStyle d, - XTextProperty * e), (a, b, c, d, e), return) -SDL_X11_SYM(int, Xutf8LookupString, - (XIC a, XKeyPressedEvent * b, char *c, int d, KeySym * e, - Status * f), (a, b, c, d, e, f), return) +SDL_X11_SYM(int,Xutf8TextListToTextProperty,(Display* a,char** b,int c,XICCEncodingStyle d,XTextProperty* e),(a,b,c,d,e),return) +SDL_X11_SYM(int,Xutf8LookupString,(XIC a,XKeyPressedEvent* b,char* c,int d,KeySym* e,Status* f),(a,b,c,d,e,f),return) /*SDL_X11_SYM(XIC,XCreateIC,(XIM, ...),return) !!! ARGH! */ -SDL_X11_SYM(void, XDestroyIC, (XIC a), (a),) -SDL_X11_SYM(void, XSetICFocus, (XIC a), (a),) -SDL_X11_SYM(void, XUnsetICFocus, (XIC a), (a),) -SDL_X11_SYM(XIM, XOpenIM, - (Display * a, struct _XrmHashBucketRec * b, char *c, char *d), - (a, b, c, d), return) -SDL_X11_SYM(Status, XCloseIM, (XIM a), (a), return) +SDL_X11_SYM(void,XDestroyIC,(XIC a),(a),) +SDL_X11_SYM(void,XSetICFocus,(XIC a),(a),) +SDL_X11_SYM(void,XUnsetICFocus,(XIC a),(a),) +SDL_X11_SYM(XIM,XOpenIM,(Display* a,struct _XrmHashBucketRec* b,char* c,char* d),(a,b,c,d),return) +SDL_X11_SYM(Status,XCloseIM,(XIM a),(a),return) #endif + #ifndef NO_SHARED_MEMORY SDL_X11_MODULE(SHM) -SDL_X11_SYM(Status, XShmAttach, (Display * a, XShmSegmentInfo * b), (a, b), - return) -SDL_X11_SYM(Status, XShmDetach, (Display * a, XShmSegmentInfo * b), (a, b), - return) -SDL_X11_SYM(Status, XShmPutImage, - (Display * a, Drawable b, GC c, XImage * d, int e, int f, int g, - int h, unsigned int i, unsigned int j, Bool k), (a, b, c, d, e, - f, g, h, i, j, - k), return) -SDL_X11_SYM(XImage *, XShmCreateImage, - (Display * a, Visual * b, unsigned int c, int d, char *e, - XShmSegmentInfo * f, unsigned int g, unsigned int h), (a, b, c, - d, e, f, - g, h), - return) -SDL_X11_SYM(Bool, XShmQueryExtension, (Display * a), (a), return) +SDL_X11_SYM(Status,XShmAttach,(Display* a,XShmSegmentInfo* b),(a,b),return) +SDL_X11_SYM(Status,XShmDetach,(Display* a,XShmSegmentInfo* b),(a,b),return) +SDL_X11_SYM(Status,XShmPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j,Bool k),(a,b,c,d,e,f,g,h,i,j,k),return) +SDL_X11_SYM(XImage*,XShmCreateImage,(Display* a,Visual* b,unsigned int c,int d,char* e,XShmSegmentInfo* f,unsigned int g,unsigned int h),(a,b,c,d,e,f,g,h),return) +SDL_X11_SYM(Bool,XShmQueryExtension,(Display* a),(a),return) #endif + /* * Not required...these only exist in code in headers on some 64-bit platforms, * and are removed via macros elsewhere, so it's safe for them to be missing. */ #ifdef LONG64 SDL_X11_MODULE(IO_32BIT) -SDL_X11_SYM(int, _XData32, - (Display * dpy, register long *data, unsigned len), (dpy, data, - len), return) -SDL_X11_SYM(void, _XRead32, (Display * dpy, register long *data, long len), - (dpy, data, len),) +SDL_X11_SYM(int,_XData32,(Display *dpy,register long *data,unsigned len),(dpy,data,len),return) +SDL_X11_SYM(void,_XRead32,(Display *dpy,register long *data,long len),(dpy,data,len),) #endif + /* * These only show up on some variants of Unix. */ #if defined(__osf__) SDL_X11_MODULE(OSF_ENTRY_POINTS) -SDL_X11_SYM(void, _SmtBufferOverflow, - (Display * dpy, register smtDisplayPtr p), (dpy, p),) -SDL_X11_SYM(void, _SmtIpError, - (Display * dpy, register smtDisplayPtr p, int i), (dpy, p, i),) -SDL_X11_SYM(int, ipAllocateData, (ChannelPtr a, IPCard b, IPDataPtr * c), - (a, b, c), return) -SDL_X11_SYM(int, ipUnallocateAndSendData, (ChannelPtr a, IPCard b), (a, b), - return) +SDL_X11_SYM(void,_SmtBufferOverflow,(Display *dpy,register smtDisplayPtr p),(dpy,p),) +SDL_X11_SYM(void,_SmtIpError,(Display *dpy,register smtDisplayPtr p, int i),(dpy,p,i),) +SDL_X11_SYM(int,ipAllocateData,(ChannelPtr a, IPCard b, IPDataPtr * c),(a,b,c),return) +SDL_X11_SYM(int,ipUnallocateAndSendData,(ChannelPtr a, IPCard b),(a,b),return) #endif + /* Xrandr support. */ #if SDL_VIDEO_DRIVER_X11_XRANDR SDL_X11_MODULE(XRANDR) -SDL_X11_SYM(Status, XRRQueryVersion, - (Display * dpy, int *major_versionp, int *minor_versionp), (dpy, - major_versionp, - minor_versionp), - return) -SDL_X11_SYM(XRRScreenConfiguration *, XRRGetScreenInfo, - (Display * dpy, Drawable draw), (dpy, draw), return) -SDL_X11_SYM(SizeID, XRRConfigCurrentConfiguration, - (XRRScreenConfiguration * config, Rotation * rotation), (config, - rotation), - return) -SDL_X11_SYM(XRRScreenSize *, XRRConfigSizes, - (XRRScreenConfiguration * config, int *nsizes), (config, nsizes), - return) -SDL_X11_SYM(short *, XRRConfigRates, - (XRRScreenConfiguration * config, int sizeID, int *nrates), - (config, sizeID, nrates), return) -SDL_X11_SYM(Status, XRRSetScreenConfig, - (Display * dpy, XRRScreenConfiguration * config, Drawable draw, - int size_index, Rotation rotation, Time timestamp), (dpy, - config, - draw, - size_index, - rotation, - timestamp), - return) -SDL_X11_SYM(void, XRRFreeScreenConfigInfo, (XRRScreenConfiguration * config), - (config),) +SDL_X11_SYM(Status,XRRQueryVersion,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) +SDL_X11_SYM(XRRScreenConfiguration *,XRRGetScreenInfo,(Display *dpy,Drawable draw),(dpy,draw),return) +SDL_X11_SYM(SizeID,XRRConfigCurrentConfiguration,(XRRScreenConfiguration *config,Rotation *rotation),(config,rotation),return) +SDL_X11_SYM(XRRScreenSize *,XRRConfigSizes,(XRRScreenConfiguration *config, int *nsizes),(config,nsizes),return) +SDL_X11_SYM(Status,XRRSetScreenConfig,(Display *dpy, XRRScreenConfiguration *config, Drawable draw, int size_index, Rotation rotation, Time timestamp),(dpy,config,draw,size_index,rotation,timestamp),return) +SDL_X11_SYM(void,XRRFreeScreenConfigInfo,(XRRScreenConfiguration *config),(config),) #endif + /* DPMS support */ #if SDL_VIDEO_DRIVER_X11_DPMS SDL_X11_MODULE(DPMS) -SDL_X11_SYM(Status, DPMSQueryExtension, - (Display * dpy, int *major_versionp, int *minor_versionp), (dpy, - major_versionp, - minor_versionp), - return) -SDL_X11_SYM(Status, DPMSInfo, (Display * dpy, CARD16 * state, BOOL * onoff), - (dpy, state, onoff), return) -SDL_X11_SYM(Status, DPMSEnable, (Display * dpy), (dpy), return) -SDL_X11_SYM(Status, DPMSDisable, (Display * dpy), (dpy), return) +SDL_X11_SYM(Status,DPMSQueryExtension,(Display *dpy,int *major_versionp,int *minor_versionp),(dpy,major_versionp,minor_versionp),return) +SDL_X11_SYM(Status,DPMSInfo,(Display *dpy,CARD16 *state,BOOL *onoff),(dpy,state,onoff),return) +SDL_X11_SYM(Status,DPMSEnable,(Display *dpy),(dpy),return) +SDL_X11_SYM(Status,DPMSDisable,(Display *dpy),(dpy),return) #endif -/* end of SDL_x11sym.h ... */ + +/* *INDENT-ON* */ + /* vi: set ts=4 sw=4 expandtab: */
--- a/src/video/x11/SDL_x11video.c Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/x11/SDL_x11video.c Fri Jul 28 08:43:17 2006 +0000 @@ -186,8 +186,7 @@ device->SetWindowGrab = X11_SetWindowGrab; device->DestroyWindow = X11_DestroyWindow; device->GetWindowWMInfo = X11_GetWindowWMInfo; -/* -#ifdef SDL_VIDEO_OPENGL +#ifdef SDL_VIDEO_OPENGL_GLX device->GL_LoadLibrary = X11_GL_LoadLibrary; device->GL_GetProcAddress = X11_GL_GetProcAddress; device->GL_CreateContext = X11_GL_CreateContext; @@ -197,7 +196,6 @@ device->GL_SwapWindow = X11_GL_SwapWindow; device->GL_DeleteContext = X11_GL_DeleteContext; #endif -*/ device->free = X11_DeleteDevice;
--- a/src/video/x11/SDL_x11video.h Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/x11/SDL_x11video.h Fri Jul 28 08:43:17 2006 +0000 @@ -53,7 +53,7 @@ #include "SDL_x11keyboard.h" #include "SDL_x11modes.h" #include "SDL_x11mouse.h" -//#include "SDL_x11opengl.h" +#include "SDL_x11opengl.h" #include "SDL_x11window.h" /* Private display data */
--- a/src/video/x11/SDL_x11window.c Thu Jul 27 06:53:23 2006 +0000 +++ b/src/video/x11/SDL_x11window.c Fri Jul 28 08:43:17 2006 +0000 @@ -135,7 +135,7 @@ { SDL_VideoData *data = (SDL_VideoData *) _this->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; + (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; Visual *visual; int depth; XSetWindowAttributes xattr; @@ -153,9 +153,23 @@ } */ #endif +#ifdef SDL_VIDEO_OPENGL_GLX if (window->flags & SDL_WINDOW_OPENGL) { - /* FIXME: get the glx visual */ - } else { + XVisualInfo *vinfo; + + if (X11_GL_Initialize(_this) < 0) { + return -1; + } + vinfo = X11_GL_GetVisual(_this, data->display, displaydata->screen); + if (!vinfo) { + return -1; + } + visual = vinfo->visual; + depth = vinfo->depth; + XFree(vinfo); + } else +#endif + { visual = displaydata->visual; depth = displaydata->depth; } @@ -203,6 +217,15 @@ window->w, window->h, 0, depth, InputOutput, visual, (CWOverrideRedirect | CWBackPixel | CWBorderPixel | CWColormap), &xattr); + if (!w) { +#ifdef SDL_VIDEO_OPENGL_GLX + if (window->flags & SDL_WINDOW_OPENGL) { + X11_GL_Shutdown(_this); + } +#endif + SDL_SetError("Couldn't create window"); + return -1; + } sizehints = XAllocSizeHints(); if (sizehints) { @@ -370,27 +393,26 @@ /* Finally, show the window */ if (window->flags & SDL_WINDOW_SHOWN) { + XEvent event; + XMapRaised(data->display, w); + do { + XCheckWindowEvent(data->display, w, StructureNotifyMask, &event); + } while (event.type != MapNotify); } - XSync(data->display, False); if (SetupWindowData(_this, window, w, SDL_TRUE) < 0) { +#ifdef SDL_VIDEO_OPENGL_GLX + if (window->flags & SDL_WINDOW_OPENGL) { + X11_GL_Shutdown(_this); + } +#endif XDestroyWindow(data->display, w); return -1; } X11_SetWindowTitle(_this, window); -#ifdef SDL_VIDEO_OPENGL - /* - if (window->flags & SDL_WINDOW_OPENGL) { - if (X11_GL_SetupWindow(_this, window) < 0) { - X11_DestroyWindow(_this, window); - return -1; - } - } - */ -#endif return 0; } @@ -486,7 +508,7 @@ { SDL_WindowData *data = (SDL_WindowData *) window->driverdata; SDL_DisplayData *displaydata = - (SDL_DisplayData *) SDL_CurrentDisplay.driverdata; + (SDL_DisplayData *) SDL_GetDisplayFromWindow(window)->driverdata; Display *display = data->videodata->display; int x, y; @@ -576,12 +598,10 @@ if (data) { Display *display = data->videodata->display; -#ifdef SDL_VIDEO_OPENGL - /* - if (window->flags & SDL_WINDOW_OPENGL) { - X11_GL_CleanupWindow(_this, window); - } - */ +#ifdef SDL_VIDEO_OPENGL_GLX + if (window->flags & SDL_WINDOW_OPENGL) { + X11_GL_Shutdown(_this); + } #endif #ifdef X_HAVE_UTF8_STRING if (data->ic) {