Mercurial > sdl-ios-xcode
comparison src/video/x11/SDL_x11gl.c @ 1668:4da1ee79c9af SDL-1.3
more tweaking indent options
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 29 May 2006 04:04:35 +0000 |
parents | 782fd950bd46 |
children | 109bdfe06b31 |
comparison
equal
deleted
inserted
replaced
1667:1fddae038bc8 | 1668:4da1ee79c9af |
---|---|
51 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D | 51 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D |
52 #endif | 52 #endif |
53 | 53 |
54 #if SDL_VIDEO_OPENGL_GLX | 54 #if SDL_VIDEO_OPENGL_GLX |
55 static int | 55 static int |
56 glXExtensionSupported (_THIS, const char *extension) | 56 glXExtensionSupported(_THIS, const char *extension) |
57 { | 57 { |
58 const char *extensions; | 58 const char *extensions; |
59 const char *start; | 59 const char *start; |
60 const char *where, *terminator; | 60 const char *where, *terminator; |
61 | 61 |
62 /* Extension names should not have spaces. */ | 62 /* Extension names should not have spaces. */ |
63 where = SDL_strchr (extension, ' '); | 63 where = SDL_strchr(extension, ' '); |
64 if (where || *extension == '\0') { | 64 if (where || *extension == '\0') { |
65 return 0; | 65 return 0; |
66 } | 66 } |
67 | 67 |
68 extensions = | 68 extensions = |
69 this->gl_data->glXQueryExtensionsString (GFX_Display, SDL_Screen); | 69 this->gl_data->glXQueryExtensionsString(GFX_Display, SDL_Screen); |
70 /* It takes a bit of care to be fool-proof about parsing the | 70 /* It takes a bit of care to be fool-proof about parsing the |
71 * OpenGL extensions string. Don't be fooled by sub-strings, etc. | 71 * OpenGL extensions string. Don't be fooled by sub-strings, etc. |
72 */ | 72 */ |
73 | 73 |
74 start = extensions; | 74 start = extensions; |
75 | 75 |
76 for (;;) { | 76 for (;;) { |
77 where = SDL_strstr (start, extension); | 77 where = SDL_strstr(start, extension); |
78 if (!where) | 78 if (!where) |
79 break; | 79 break; |
80 | 80 |
81 terminator = where + strlen (extension); | 81 terminator = where + strlen(extension); |
82 if (where == start || *(where - 1) == ' ') | 82 if (where == start || *(where - 1) == ' ') |
83 if (*terminator == ' ' || *terminator == '\0') | 83 if (*terminator == ' ' || *terminator == '\0') |
84 return 1; | 84 return 1; |
85 | 85 |
86 start = terminator; | 86 start = terminator; |
88 return 0; | 88 return 0; |
89 } | 89 } |
90 #endif /* SDL_VIDEO_OPENGL_GLX */ | 90 #endif /* SDL_VIDEO_OPENGL_GLX */ |
91 | 91 |
92 XVisualInfo * | 92 XVisualInfo * |
93 X11_GL_GetVisual (_THIS) | 93 X11_GL_GetVisual(_THIS) |
94 { | 94 { |
95 #if SDL_VIDEO_OPENGL_GLX | 95 #if SDL_VIDEO_OPENGL_GLX |
96 /* 64 seems nice. */ | 96 /* 64 seems nice. */ |
97 int attribs[64]; | 97 int attribs[64]; |
98 int i; | 98 int i; |
99 | 99 |
100 /* load the gl driver from a default path */ | 100 /* load the gl driver from a default path */ |
101 if (!this->gl_config.driver_loaded) { | 101 if (!this->gl_config.driver_loaded) { |
102 /* no driver has been loaded, use default (ourselves) */ | 102 /* no driver has been loaded, use default (ourselves) */ |
103 if (X11_GL_LoadLibrary (this, NULL) < 0) { | 103 if (X11_GL_LoadLibrary(this, NULL) < 0) { |
104 return NULL; | 104 return NULL; |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 /* See if we already have a window which we must use */ | 108 /* See if we already have a window which we must use */ |
109 if (SDL_windowid) { | 109 if (SDL_windowid) { |
110 XWindowAttributes a; | 110 XWindowAttributes a; |
111 XVisualInfo vi_in; | 111 XVisualInfo vi_in; |
112 int out_count; | 112 int out_count; |
113 | 113 |
114 XGetWindowAttributes (SDL_Display, SDL_Window, &a); | 114 XGetWindowAttributes(SDL_Display, SDL_Window, &a); |
115 vi_in.screen = SDL_Screen; | 115 vi_in.screen = SDL_Screen; |
116 vi_in.visualid = XVisualIDFromVisual (a.visual); | 116 vi_in.visualid = XVisualIDFromVisual(a.visual); |
117 glx_visualinfo = XGetVisualInfo (SDL_Display, | 117 glx_visualinfo = XGetVisualInfo(SDL_Display, |
118 VisualScreenMask | VisualIDMask, | 118 VisualScreenMask | VisualIDMask, |
119 &vi_in, &out_count); | 119 &vi_in, &out_count); |
120 return glx_visualinfo; | 120 return glx_visualinfo; |
121 } | 121 } |
122 | 122 |
123 /* Setup our GLX attributes according to the gl_config. */ | 123 /* Setup our GLX attributes according to the gl_config. */ |
124 i = 0; | 124 i = 0; |
185 attribs[i++] = GLX_SAMPLES_ARB; | 185 attribs[i++] = GLX_SAMPLES_ARB; |
186 attribs[i++] = this->gl_config.multisamplesamples; | 186 attribs[i++] = this->gl_config.multisamplesamples; |
187 } | 187 } |
188 | 188 |
189 if (this->gl_config.accelerated >= 0 && | 189 if (this->gl_config.accelerated >= 0 && |
190 glXExtensionSupported (this, "GLX_EXT_visual_rating")) { | 190 glXExtensionSupported(this, "GLX_EXT_visual_rating")) { |
191 attribs[i++] = GLX_VISUAL_CAVEAT_EXT; | 191 attribs[i++] = GLX_VISUAL_CAVEAT_EXT; |
192 attribs[i++] = GLX_NONE_EXT; | 192 attribs[i++] = GLX_NONE_EXT; |
193 } | 193 } |
194 #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ | 194 #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ |
195 if (!SDL_getenv ("SDL_VIDEO_X11_NODIRECTCOLOR")) { | 195 if (!SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) { |
196 attribs[i++] = GLX_X_VISUAL_TYPE; | 196 attribs[i++] = GLX_X_VISUAL_TYPE; |
197 attribs[i++] = GLX_DIRECT_COLOR; | 197 attribs[i++] = GLX_DIRECT_COLOR; |
198 } | 198 } |
199 #endif | 199 #endif |
200 attribs[i++] = None; | 200 attribs[i++] = None; |
201 | 201 |
202 glx_visualinfo = this->gl_data->glXChooseVisual (GFX_Display, | 202 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, |
203 SDL_Screen, attribs); | 203 SDL_Screen, attribs); |
204 #ifdef GLX_DIRECT_COLOR | 204 #ifdef GLX_DIRECT_COLOR |
205 if (!glx_visualinfo && !SDL_getenv ("SDL_VIDEO_X11_NODIRECTCOLOR")) { /* No DirectColor visual? Try again.. */ | 205 if (!glx_visualinfo && !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR")) { /* No DirectColor visual? Try again.. */ |
206 attribs[i - 3] = None; | 206 attribs[i - 3] = None; |
207 glx_visualinfo = this->gl_data->glXChooseVisual (GFX_Display, | 207 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, |
208 SDL_Screen, attribs); | 208 SDL_Screen, attribs); |
209 } | 209 } |
210 #endif | 210 #endif |
211 if (!glx_visualinfo) { | 211 if (!glx_visualinfo) { |
212 SDL_SetError ("Couldn't find matching GLX visual"); | 212 SDL_SetError("Couldn't find matching GLX visual"); |
213 return NULL; | 213 return NULL; |
214 } | 214 } |
215 /* | 215 /* |
216 printf("Found GLX visual 0x%x\n", glx_visualinfo->visualid); | 216 printf("Found GLX visual 0x%x\n", glx_visualinfo->visualid); |
217 */ | 217 */ |
218 return glx_visualinfo; | 218 return glx_visualinfo; |
219 #else | 219 #else |
220 SDL_SetError ("X11 driver not configured with OpenGL"); | 220 SDL_SetError("X11 driver not configured with OpenGL"); |
221 return NULL; | 221 return NULL; |
222 #endif | 222 #endif |
223 } | 223 } |
224 | 224 |
225 int | 225 int |
226 X11_GL_CreateWindow (_THIS, int w, int h) | 226 X11_GL_CreateWindow(_THIS, int w, int h) |
227 { | 227 { |
228 int retval; | 228 int retval; |
229 #if SDL_VIDEO_OPENGL_GLX | 229 #if SDL_VIDEO_OPENGL_GLX |
230 XSetWindowAttributes attributes; | 230 XSetWindowAttributes attributes; |
231 unsigned long mask; | 231 unsigned long mask; |
232 unsigned long black; | 232 unsigned long black; |
233 | 233 |
234 black = (glx_visualinfo->visual == DefaultVisual (SDL_Display, | 234 black = (glx_visualinfo->visual == DefaultVisual(SDL_Display, SDL_Screen)) |
235 SDL_Screen)) | 235 ? BlackPixel(SDL_Display, SDL_Screen) : 0; |
236 ? BlackPixel (SDL_Display, SDL_Screen) : 0; | |
237 attributes.background_pixel = black; | 236 attributes.background_pixel = black; |
238 attributes.border_pixel = black; | 237 attributes.border_pixel = black; |
239 attributes.colormap = SDL_XColorMap; | 238 attributes.colormap = SDL_XColorMap; |
240 mask = CWBackPixel | CWBorderPixel | CWColormap; | 239 mask = CWBackPixel | CWBorderPixel | CWColormap; |
241 | 240 |
242 SDL_Window = XCreateWindow (SDL_Display, WMwindow, | 241 SDL_Window = XCreateWindow(SDL_Display, WMwindow, |
243 0, 0, w, h, 0, glx_visualinfo->depth, | 242 0, 0, w, h, 0, glx_visualinfo->depth, |
244 InputOutput, glx_visualinfo->visual, | 243 InputOutput, glx_visualinfo->visual, |
245 mask, &attributes); | 244 mask, &attributes); |
246 if (!SDL_Window) { | 245 if (!SDL_Window) { |
247 SDL_SetError ("Could not create window"); | 246 SDL_SetError("Could not create window"); |
248 return -1; | 247 return -1; |
249 } | 248 } |
250 retval = 0; | 249 retval = 0; |
251 #else | 250 #else |
252 SDL_SetError ("X11 driver not configured with OpenGL"); | 251 SDL_SetError("X11 driver not configured with OpenGL"); |
253 retval = -1; | 252 retval = -1; |
254 #endif | 253 #endif |
255 return (retval); | 254 return (retval); |
256 } | 255 } |
257 | 256 |
258 int | 257 int |
259 X11_GL_CreateContext (_THIS) | 258 X11_GL_CreateContext(_THIS) |
260 { | 259 { |
261 int retval; | 260 int retval; |
262 #if SDL_VIDEO_OPENGL_GLX | 261 #if SDL_VIDEO_OPENGL_GLX |
263 | 262 |
264 /* We do this to create a clean separation between X and GLX errors. */ | 263 /* We do this to create a clean separation between X and GLX errors. */ |
265 XSync (SDL_Display, False); | 264 XSync(SDL_Display, False); |
266 glx_context = this->gl_data->glXCreateContext (GFX_Display, | 265 glx_context = this->gl_data->glXCreateContext(GFX_Display, |
267 glx_visualinfo, NULL, | 266 glx_visualinfo, NULL, True); |
268 True); | 267 XSync(GFX_Display, False); |
269 XSync (GFX_Display, False); | |
270 | 268 |
271 if (glx_context == NULL) { | 269 if (glx_context == NULL) { |
272 SDL_SetError ("Could not create GL context"); | 270 SDL_SetError("Could not create GL context"); |
273 return (-1); | 271 return (-1); |
274 } | 272 } |
275 if (X11_GL_MakeCurrent (this) < 0) { | 273 if (X11_GL_MakeCurrent(this) < 0) { |
276 return (-1); | 274 return (-1); |
277 } | 275 } |
278 gl_active = 1; | 276 gl_active = 1; |
279 | 277 |
280 if (!glXExtensionSupported (this, "SGI_swap_control")) { | 278 if (!glXExtensionSupported(this, "SGI_swap_control")) { |
281 this->gl_data->glXSwapIntervalSGI = NULL; | 279 this->gl_data->glXSwapIntervalSGI = NULL; |
282 } | 280 } |
283 if (!glXExtensionSupported (this, "GLX_MESA_swap_control")) { | 281 if (!glXExtensionSupported(this, "GLX_MESA_swap_control")) { |
284 this->gl_data->glXSwapIntervalMESA = NULL; | 282 this->gl_data->glXSwapIntervalMESA = NULL; |
285 this->gl_data->glXGetSwapIntervalMESA = NULL; | 283 this->gl_data->glXGetSwapIntervalMESA = NULL; |
286 } | 284 } |
287 if (this->gl_config.swap_control >= 0) { | 285 if (this->gl_config.swap_control >= 0) { |
288 if (this->gl_data->glXSwapIntervalMESA) { | 286 if (this->gl_data->glXSwapIntervalMESA) { |
289 this->gl_data->glXSwapIntervalMESA (this->gl_config.swap_control); | 287 this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); |
290 } else if (this->gl_data->glXSwapIntervalSGI) { | 288 } else if (this->gl_data->glXSwapIntervalSGI) { |
291 this->gl_data->glXSwapIntervalSGI (this->gl_config.swap_control); | 289 this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control); |
292 } | 290 } |
293 } | 291 } |
294 #else | 292 #else |
295 SDL_SetError ("X11 driver not configured with OpenGL"); | 293 SDL_SetError("X11 driver not configured with OpenGL"); |
296 #endif | 294 #endif |
297 if (gl_active) { | 295 if (gl_active) { |
298 retval = 0; | 296 retval = 0; |
299 } else { | 297 } else { |
300 retval = -1; | 298 retval = -1; |
301 } | 299 } |
302 return (retval); | 300 return (retval); |
303 } | 301 } |
304 | 302 |
305 void | 303 void |
306 X11_GL_Shutdown (_THIS) | 304 X11_GL_Shutdown(_THIS) |
307 { | 305 { |
308 #if SDL_VIDEO_OPENGL_GLX | 306 #if SDL_VIDEO_OPENGL_GLX |
309 /* Clean up OpenGL */ | 307 /* Clean up OpenGL */ |
310 if (glx_context) { | 308 if (glx_context) { |
311 this->gl_data->glXMakeCurrent (GFX_Display, None, NULL); | 309 this->gl_data->glXMakeCurrent(GFX_Display, None, NULL); |
312 | 310 |
313 if (glx_context != NULL) | 311 if (glx_context != NULL) |
314 this->gl_data->glXDestroyContext (GFX_Display, glx_context); | 312 this->gl_data->glXDestroyContext(GFX_Display, glx_context); |
315 | 313 |
316 glx_context = NULL; | 314 glx_context = NULL; |
317 } | 315 } |
318 gl_active = 0; | 316 gl_active = 0; |
319 #endif /* SDL_VIDEO_OPENGL_GLX */ | 317 #endif /* SDL_VIDEO_OPENGL_GLX */ |
321 | 319 |
322 #if SDL_VIDEO_OPENGL_GLX | 320 #if SDL_VIDEO_OPENGL_GLX |
323 | 321 |
324 /* Make the current context active */ | 322 /* Make the current context active */ |
325 int | 323 int |
326 X11_GL_MakeCurrent (_THIS) | 324 X11_GL_MakeCurrent(_THIS) |
327 { | 325 { |
328 int retval; | 326 int retval; |
329 | 327 |
330 retval = 0; | 328 retval = 0; |
331 if (!this->gl_data->glXMakeCurrent (GFX_Display, SDL_Window, glx_context)) { | 329 if (!this->gl_data->glXMakeCurrent(GFX_Display, SDL_Window, glx_context)) { |
332 SDL_SetError ("Unable to make GL context current"); | 330 SDL_SetError("Unable to make GL context current"); |
333 retval = -1; | 331 retval = -1; |
334 } | 332 } |
335 XSync (GFX_Display, False); | 333 XSync(GFX_Display, False); |
336 | 334 |
337 /* More Voodoo X server workarounds... Grr... */ | 335 /* More Voodoo X server workarounds... Grr... */ |
338 SDL_Lock_EventThread (); | 336 SDL_Lock_EventThread(); |
339 X11_CheckDGAMouse (this); | 337 X11_CheckDGAMouse(this); |
340 SDL_Unlock_EventThread (); | 338 SDL_Unlock_EventThread(); |
341 | 339 |
342 return (retval); | 340 return (retval); |
343 } | 341 } |
344 | 342 |
345 /* Get attribute data from glX. */ | 343 /* Get attribute data from glX. */ |
346 int | 344 int |
347 X11_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) | 345 X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) |
348 { | 346 { |
349 int retval; | 347 int retval; |
350 int glx_attrib = None; | 348 int glx_attrib = None; |
351 | 349 |
352 switch (attrib) { | 350 switch (attrib) { |
394 break; | 392 break; |
395 case SDL_GL_MULTISAMPLESAMPLES: | 393 case SDL_GL_MULTISAMPLESAMPLES: |
396 glx_attrib = GLX_SAMPLES_ARB; | 394 glx_attrib = GLX_SAMPLES_ARB; |
397 break; | 395 break; |
398 case SDL_GL_ACCELERATED_VISUAL: | 396 case SDL_GL_ACCELERATED_VISUAL: |
399 if (glXExtensionSupported (this, "GLX_EXT_visual_rating")) { | 397 if (glXExtensionSupported(this, "GLX_EXT_visual_rating")) { |
400 glx_attrib = GLX_VISUAL_CAVEAT_EXT; | 398 glx_attrib = GLX_VISUAL_CAVEAT_EXT; |
401 retval = | 399 retval = |
402 this->gl_data->glXGetConfig (GFX_Display, glx_visualinfo, | 400 this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, |
403 glx_attrib, value); | 401 glx_attrib, value); |
404 if (*value == GLX_SLOW_VISUAL_EXT) { | 402 if (*value == GLX_SLOW_VISUAL_EXT) { |
405 *value = SDL_FALSE; | 403 *value = SDL_FALSE; |
406 } else { | 404 } else { |
407 *value = SDL_TRUE; | 405 *value = SDL_TRUE; |
408 } | 406 } |
411 return (-1); | 409 return (-1); |
412 } | 410 } |
413 break; | 411 break; |
414 case SDL_GL_SWAP_CONTROL: | 412 case SDL_GL_SWAP_CONTROL: |
415 if (this->gl_data->glXGetSwapIntervalMESA) { | 413 if (this->gl_data->glXGetSwapIntervalMESA) { |
416 return this->gl_data->glXGetSwapIntervalMESA (); | 414 return this->gl_data->glXGetSwapIntervalMESA(); |
417 } else { | 415 } else { |
418 return (-1) /*(this->gl_config.swap_control > 0) */ ; | 416 return (-1) /*(this->gl_config.swap_control > 0) */ ; |
419 } | 417 } |
420 break; | 418 break; |
421 default: | 419 default: |
422 return (-1); | 420 return (-1); |
423 } | 421 } |
424 | 422 |
425 retval = | 423 retval = |
426 this->gl_data->glXGetConfig (GFX_Display, glx_visualinfo, glx_attrib, | 424 this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, |
427 value); | 425 value); |
428 | 426 |
429 return retval; | 427 return retval; |
430 } | 428 } |
431 | 429 |
432 void | 430 void |
433 X11_GL_SwapBuffers (_THIS) | 431 X11_GL_SwapBuffers(_THIS) |
434 { | 432 { |
435 this->gl_data->glXSwapBuffers (GFX_Display, SDL_Window); | 433 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window); |
436 } | 434 } |
437 | 435 |
438 #endif /* SDL_VIDEO_OPENGL_GLX */ | 436 #endif /* SDL_VIDEO_OPENGL_GLX */ |
439 | 437 |
440 void | 438 void |
441 X11_GL_UnloadLibrary (_THIS) | 439 X11_GL_UnloadLibrary(_THIS) |
442 { | 440 { |
443 #if SDL_VIDEO_OPENGL_GLX | 441 #if SDL_VIDEO_OPENGL_GLX |
444 if (this->gl_config.driver_loaded) { | 442 if (this->gl_config.driver_loaded) { |
445 | 443 |
446 SDL_UnloadObject (this->gl_config.dll_handle); | 444 SDL_UnloadObject(this->gl_config.dll_handle); |
447 | 445 |
448 this->gl_data->glXGetProcAddress = NULL; | 446 this->gl_data->glXGetProcAddress = NULL; |
449 this->gl_data->glXChooseVisual = NULL; | 447 this->gl_data->glXChooseVisual = NULL; |
450 this->gl_data->glXCreateContext = NULL; | 448 this->gl_data->glXCreateContext = NULL; |
451 this->gl_data->glXDestroyContext = NULL; | 449 this->gl_data->glXDestroyContext = NULL; |
463 | 461 |
464 #if SDL_VIDEO_OPENGL_GLX | 462 #if SDL_VIDEO_OPENGL_GLX |
465 | 463 |
466 /* Passing a NULL path means load pointers from the application */ | 464 /* Passing a NULL path means load pointers from the application */ |
467 int | 465 int |
468 X11_GL_LoadLibrary (_THIS, const char *path) | 466 X11_GL_LoadLibrary(_THIS, const char *path) |
469 { | 467 { |
470 void *handle = NULL; | 468 void *handle = NULL; |
471 | 469 |
472 if (gl_active) { | 470 if (gl_active) { |
473 SDL_SetError ("OpenGL context already created"); | 471 SDL_SetError("OpenGL context already created"); |
474 return -1; | 472 return -1; |
475 } | 473 } |
476 | 474 |
477 if (path == NULL) { | 475 if (path == NULL) { |
478 path = SDL_getenv ("SDL_VIDEO_GL_DRIVER"); | 476 path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); |
479 if (path == NULL) { | 477 if (path == NULL) { |
480 path = DEFAULT_OPENGL; | 478 path = DEFAULT_OPENGL; |
481 } | 479 } |
482 } | 480 } |
483 | 481 |
484 handle = SDL_LoadObject (path); | 482 handle = SDL_LoadObject(path); |
485 if (handle == NULL) { | 483 if (handle == NULL) { |
486 /* SDL_LoadObject() will call SDL_SetError() for us. */ | 484 /* SDL_LoadObject() will call SDL_SetError() for us. */ |
487 return -1; | 485 return -1; |
488 } | 486 } |
489 | 487 |
490 /* Unload the old driver and reset the pointers */ | 488 /* Unload the old driver and reset the pointers */ |
491 X11_GL_UnloadLibrary (this); | 489 X11_GL_UnloadLibrary(this); |
492 | 490 |
493 /* Load new function pointers */ | 491 /* Load new function pointers */ |
494 this->gl_data->glXGetProcAddress = | 492 this->gl_data->glXGetProcAddress = |
495 (void *(*)(const GLubyte *)) SDL_LoadFunction (handle, | 493 (void *(*)(const GLubyte *)) SDL_LoadFunction(handle, |
496 "glXGetProcAddressARB"); | 494 "glXGetProcAddressARB"); |
497 this->gl_data->glXChooseVisual = | 495 this->gl_data->glXChooseVisual = |
498 (XVisualInfo * (*)(Display *, int, int *)) SDL_LoadFunction (handle, | 496 (XVisualInfo * (*)(Display *, int, int *)) SDL_LoadFunction(handle, |
499 "glXChooseVisual"); | 497 "glXChooseVisual"); |
500 this->gl_data->glXCreateContext = | 498 this->gl_data->glXCreateContext = |
501 (GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) | 499 (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int)) |
502 SDL_LoadFunction (handle, "glXCreateContext"); | 500 SDL_LoadFunction(handle, "glXCreateContext"); |
503 this->gl_data->glXDestroyContext = | 501 this->gl_data->glXDestroyContext = |
504 (void (*)(Display *, GLXContext)) SDL_LoadFunction (handle, | 502 (void (*)(Display *, GLXContext)) SDL_LoadFunction(handle, |
505 "glXDestroyContext"); | 503 "glXDestroyContext"); |
506 this->gl_data->glXMakeCurrent = | 504 this->gl_data->glXMakeCurrent = |
507 (int (*)(Display *, GLXDrawable, GLXContext)) | 505 (int (*)(Display *, GLXDrawable, GLXContext)) |
508 SDL_LoadFunction (handle, "glXMakeCurrent"); | 506 SDL_LoadFunction(handle, "glXMakeCurrent"); |
509 this->gl_data->glXSwapBuffers = | 507 this->gl_data->glXSwapBuffers = |
510 (void (*)(Display *, GLXDrawable)) SDL_LoadFunction (handle, | 508 (void (*)(Display *, GLXDrawable)) SDL_LoadFunction(handle, |
511 "glXSwapBuffers"); | 509 "glXSwapBuffers"); |
512 this->gl_data->glXGetConfig = | 510 this->gl_data->glXGetConfig = |
513 (int (*)(Display *, XVisualInfo *, int, int *)) | 511 (int (*)(Display *, XVisualInfo *, int, int *)) |
514 SDL_LoadFunction (handle, "glXGetConfig"); | 512 SDL_LoadFunction(handle, "glXGetConfig"); |
515 this->gl_data->glXQueryExtensionsString = | 513 this->gl_data->glXQueryExtensionsString = |
516 (const char *(*)(Display *, int)) SDL_LoadFunction (handle, | 514 (const char *(*)(Display *, int)) SDL_LoadFunction(handle, |
517 "glXQueryExtensionsString"); | 515 "glXQueryExtensionsString"); |
518 this->gl_data->glXSwapIntervalSGI = | 516 this->gl_data->glXSwapIntervalSGI = |
519 (int (*)(int)) SDL_LoadFunction (handle, "glXSwapIntervalSGI"); | 517 (int (*)(int)) SDL_LoadFunction(handle, "glXSwapIntervalSGI"); |
520 this->gl_data->glXSwapIntervalMESA = | 518 this->gl_data->glXSwapIntervalMESA = |
521 (GLint (*)(unsigned)) SDL_LoadFunction (handle, | 519 (GLint(*)(unsigned)) SDL_LoadFunction(handle, "glXSwapIntervalMESA"); |
522 "glXSwapIntervalMESA"); | |
523 this->gl_data->glXGetSwapIntervalMESA = | 520 this->gl_data->glXGetSwapIntervalMESA = |
524 (GLint (*)(void)) SDL_LoadFunction (handle, "glXGetSwapIntervalMESA"); | 521 (GLint(*)(void)) SDL_LoadFunction(handle, "glXGetSwapIntervalMESA"); |
525 | 522 |
526 if ((this->gl_data->glXChooseVisual == NULL) || | 523 if ((this->gl_data->glXChooseVisual == NULL) || |
527 (this->gl_data->glXCreateContext == NULL) || | 524 (this->gl_data->glXCreateContext == NULL) || |
528 (this->gl_data->glXDestroyContext == NULL) || | 525 (this->gl_data->glXDestroyContext == NULL) || |
529 (this->gl_data->glXMakeCurrent == NULL) || | 526 (this->gl_data->glXMakeCurrent == NULL) || |
530 (this->gl_data->glXSwapBuffers == NULL) || | 527 (this->gl_data->glXSwapBuffers == NULL) || |
531 (this->gl_data->glXGetConfig == NULL) || | 528 (this->gl_data->glXGetConfig == NULL) || |
532 (this->gl_data->glXQueryExtensionsString == NULL)) { | 529 (this->gl_data->glXQueryExtensionsString == NULL)) { |
533 SDL_SetError ("Could not retrieve OpenGL functions"); | 530 SDL_SetError("Could not retrieve OpenGL functions"); |
534 return -1; | 531 return -1; |
535 } | 532 } |
536 | 533 |
537 this->gl_config.dll_handle = handle; | 534 this->gl_config.dll_handle = handle; |
538 this->gl_config.driver_loaded = 1; | 535 this->gl_config.driver_loaded = 1; |
539 if (path) { | 536 if (path) { |
540 SDL_strlcpy (this->gl_config.driver_path, path, | 537 SDL_strlcpy(this->gl_config.driver_path, path, |
541 SDL_arraysize (this->gl_config.driver_path)); | 538 SDL_arraysize(this->gl_config.driver_path)); |
542 } else { | 539 } else { |
543 *this->gl_config.driver_path = '\0'; | 540 *this->gl_config.driver_path = '\0'; |
544 } | 541 } |
545 return 0; | 542 return 0; |
546 } | 543 } |
547 | 544 |
548 void * | 545 void * |
549 X11_GL_GetProcAddress (_THIS, const char *proc) | 546 X11_GL_GetProcAddress(_THIS, const char *proc) |
550 { | 547 { |
551 void *handle; | 548 void *handle; |
552 | 549 |
553 handle = this->gl_config.dll_handle; | 550 handle = this->gl_config.dll_handle; |
554 if (this->gl_data->glXGetProcAddress) { | 551 if (this->gl_data->glXGetProcAddress) { |
555 return this->gl_data->glXGetProcAddress ((const GLubyte *) proc); | 552 return this->gl_data->glXGetProcAddress((const GLubyte *) proc); |
556 } | 553 } |
557 return SDL_LoadFunction (handle, proc); | 554 return SDL_LoadFunction(handle, proc); |
558 } | 555 } |
559 | 556 |
560 #endif /* SDL_VIDEO_OPENGL_GLX */ | 557 #endif /* SDL_VIDEO_OPENGL_GLX */ |
561 /* vi: set ts=4 sw=4 expandtab: */ | 558 /* vi: set ts=4 sw=4 expandtab: */ |