Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11gl.c @ 1168:045f186426e1
Dynamically load X11 libraries like we currently do for alsa, esd, etc.
This allows you to run an SDL program on a system without Xlib, since it'll
just report the x11 target unavailable at runtime.
author | Ryan C. Gordon <icculus@icculus.org> |
---|---|
date | Sat, 05 Nov 2005 19:53:37 +0000 |
parents | 86885b40a53b |
children | e8e8dcb68e7a |
comparison
equal
deleted
inserted
replaced
1167:435c2e481299 | 1168:045f186426e1 |
---|---|
67 if ( SDL_windowid ) { | 67 if ( SDL_windowid ) { |
68 XWindowAttributes a; | 68 XWindowAttributes a; |
69 XVisualInfo vi_in; | 69 XVisualInfo vi_in; |
70 int out_count; | 70 int out_count; |
71 | 71 |
72 XGetWindowAttributes(SDL_Display, SDL_Window, &a); | 72 pXGetWindowAttributes(SDL_Display, SDL_Window, &a); |
73 vi_in.screen = SDL_Screen; | 73 vi_in.screen = SDL_Screen; |
74 vi_in.visualid = XVisualIDFromVisual(a.visual); | 74 vi_in.visualid = pXVisualIDFromVisual(a.visual); |
75 glx_visualinfo = XGetVisualInfo(SDL_Display, | 75 glx_visualinfo = pXGetVisualInfo(SDL_Display, |
76 VisualScreenMask|VisualIDMask, &vi_in, &out_count); | 76 VisualScreenMask|VisualIDMask, &vi_in, &out_count); |
77 return glx_visualinfo; | 77 return glx_visualinfo; |
78 } | 78 } |
79 | 79 |
80 /* Setup our GLX attributes according to the gl_config. */ | 80 /* Setup our GLX attributes according to the gl_config. */ |
186 attributes.background_pixel = black; | 186 attributes.background_pixel = black; |
187 attributes.border_pixel = black; | 187 attributes.border_pixel = black; |
188 attributes.colormap = SDL_XColorMap; | 188 attributes.colormap = SDL_XColorMap; |
189 mask = CWBackPixel | CWBorderPixel | CWColormap; | 189 mask = CWBackPixel | CWBorderPixel | CWColormap; |
190 | 190 |
191 SDL_Window = XCreateWindow(SDL_Display, WMwindow, | 191 SDL_Window = pXCreateWindow(SDL_Display, WMwindow, |
192 0, 0, w, h, 0, glx_visualinfo->depth, | 192 0, 0, w, h, 0, glx_visualinfo->depth, |
193 InputOutput, glx_visualinfo->visual, | 193 InputOutput, glx_visualinfo->visual, |
194 mask, &attributes); | 194 mask, &attributes); |
195 if ( !SDL_Window ) { | 195 if ( !SDL_Window ) { |
196 SDL_SetError("Could not create window"); | 196 SDL_SetError("Could not create window"); |
207 int X11_GL_CreateContext(_THIS) | 207 int X11_GL_CreateContext(_THIS) |
208 { | 208 { |
209 int retval; | 209 int retval; |
210 #ifdef HAVE_OPENGL | 210 #ifdef HAVE_OPENGL |
211 /* We do this to create a clean separation between X and GLX errors. */ | 211 /* We do this to create a clean separation between X and GLX errors. */ |
212 XSync( SDL_Display, False ); | 212 pXSync( SDL_Display, False ); |
213 glx_context = this->gl_data->glXCreateContext(GFX_Display, | 213 glx_context = this->gl_data->glXCreateContext(GFX_Display, |
214 glx_visualinfo, NULL, True); | 214 glx_visualinfo, NULL, True); |
215 XSync( GFX_Display, False ); | 215 pXSync( GFX_Display, False ); |
216 | 216 |
217 if (glx_context == NULL) { | 217 if (glx_context == NULL) { |
218 SDL_SetError("Could not create GL context"); | 218 SDL_SetError("Could not create GL context"); |
219 return -1; | 219 return -1; |
220 } | 220 } |
294 if ( ! this->gl_data->glXMakeCurrent(GFX_Display, | 294 if ( ! this->gl_data->glXMakeCurrent(GFX_Display, |
295 SDL_Window, glx_context) ) { | 295 SDL_Window, glx_context) ) { |
296 SDL_SetError("Unable to make GL context current"); | 296 SDL_SetError("Unable to make GL context current"); |
297 retval = -1; | 297 retval = -1; |
298 } | 298 } |
299 XSync( GFX_Display, False ); | 299 pXSync( GFX_Display, False ); |
300 | 300 |
301 /* | 301 /* |
302 * The context is now current, check for glXReleaseBuffersMESA() | 302 * The context is now current, check for glXReleaseBuffersMESA() |
303 * extension. If extension is _not_ supported, destroy the pointer | 303 * extension. If extension is _not_ supported, destroy the pointer |
304 * (to make sure it will not be called in X11_GL_Shutdown() ). | 304 * (to make sure it will not be called in X11_GL_Shutdown() ). |