Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11gl.c @ 4343:d380e7a6265b SDL-1.2
patch-ac (from mrg@NetBSD.org):
Look for libGL.so, not any particular libGL.so.<X>, on NetBSD.
(the comment inline explains why)
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Fri, 16 Oct 2009 05:06:17 +0000 |
parents | f2f8525e60c2 |
children | 5fe9b267cf55 |
rev | line source |
---|---|
0 | 1 /* |
2 SDL - Simple DirectMedia Layer | |
4159 | 3 Copyright (C) 1997-2009 Sam Lantinga |
0 | 4 |
5 This library is free software; you can redistribute it and/or | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1247
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
0 | 7 License as published by the Free Software Foundation; either |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1247
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
0 | 9 |
10 This library is distributed in the hope that it will be useful, | |
11 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1247
diff
changeset
|
13 Lesser General Public License for more details. |
0 | 14 |
1312
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1247
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1247
diff
changeset
|
16 License along with this library; if not, write to the Free Software |
c9b51268668f
Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents:
1247
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
0 | 18 |
19 Sam Lantinga | |
252
e8157fcb3114
Updated the source with the correct e-mail address
Sam Lantinga <slouken@libsdl.org>
parents:
180
diff
changeset
|
20 slouken@libsdl.org |
0 | 21 */ |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
22 #include "SDL_config.h" |
0 | 23 |
24 #include "SDL_x11video.h" | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
25 #include "../../events/SDL_events_c.h" |
0 | 26 #include "SDL_x11dga_c.h" |
27 #include "SDL_x11gl_c.h" | |
28 | |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
29 #if defined(__IRIX__) |
862
f7a8b0ca2ae3
IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
30 /* IRIX doesn't have a GL library versioning system */ |
f7a8b0ca2ae3
IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
31 #define DEFAULT_OPENGL "libGL.so" |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
32 #elif defined(__MACOSX__) |
1191
2bd4cec0de63
Seperate glX from HAVE_OPENGL, for platforms that have both an X server and
Ryan C. Gordon <icculus@icculus.org>
parents:
1182
diff
changeset
|
33 #define DEFAULT_OPENGL "/usr/X11R6/lib/libGL.1.dylib" |
1402
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
34 #elif defined(__QNXNTO__) |
d910939febfa
Use consistent identifiers for the various platforms we support.
Sam Lantinga <slouken@libsdl.org>
parents:
1379
diff
changeset
|
35 #define DEFAULT_OPENGL "libGL.so.3" |
4023
5ec68276e4de
Applied patch from OpenBSD ports package
Sam Lantinga <slouken@libsdl.org>
parents:
3940
diff
changeset
|
36 #elif defined(__OpenBSD__) |
5ec68276e4de
Applied patch from OpenBSD ports package
Sam Lantinga <slouken@libsdl.org>
parents:
3940
diff
changeset
|
37 #define DEFAULT_OPENGL "libGL.so.4.0" |
4343
d380e7a6265b
patch-ac (from mrg@NetBSD.org):
Sam Lantinga <slouken@libsdl.org>
parents:
4312
diff
changeset
|
38 #elif defined(__NetBSD__) |
d380e7a6265b
patch-ac (from mrg@NetBSD.org):
Sam Lantinga <slouken@libsdl.org>
parents:
4312
diff
changeset
|
39 /* pkgsrc is .1, base system is .2 */ |
d380e7a6265b
patch-ac (from mrg@NetBSD.org):
Sam Lantinga <slouken@libsdl.org>
parents:
4312
diff
changeset
|
40 #define DEFAULT_OPENGL "libGL.so" |
862
f7a8b0ca2ae3
IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
41 #else |
0 | 42 #define DEFAULT_OPENGL "libGL.so.1" |
862
f7a8b0ca2ae3
IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents:
769
diff
changeset
|
43 #endif |
0 | 44 |
667
adbed8d7a991
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
45 #ifndef GLX_ARB_multisample |
adbed8d7a991
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
46 #define GLX_ARB_multisample |
adbed8d7a991
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
47 #define GLX_SAMPLE_BUFFERS_ARB 100000 |
adbed8d7a991
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
48 #define GLX_SAMPLES_ARB 100001 |
adbed8d7a991
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
49 #endif |
adbed8d7a991
*** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents:
656
diff
changeset
|
50 |
4183
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
51 /* GLX_EXT_visual_rating stuff that might not be in the system headers... */ |
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
52 #ifndef GLX_VISUAL_CAVEAT_EXT |
1737 | 53 #define GLX_VISUAL_CAVEAT_EXT 0x20 |
4183
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
54 #endif |
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
55 #ifndef GLX_NONE_EXT |
1841
0495a8e98595
Use the correct parameter for GLX_VISUAL_CAVEAT_EXT
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
56 #define GLX_NONE_EXT 0x8000 |
4183
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
57 #endif |
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
58 #ifndef GLX_SLOW_VISUAL_EXT |
1737 | 59 #define GLX_SLOW_VISUAL_EXT 0x8001 |
4183
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
60 #endif |
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
61 #ifndef GLX_NON_CONFORMANT_VISUAL_EXT |
1737 | 62 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D |
63 #endif | |
64 | |
4183
39e748f251c6
Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents:
4159
diff
changeset
|
65 |
1737 | 66 #if SDL_VIDEO_OPENGL_GLX |
67 static int glXExtensionSupported(_THIS, const char *extension) | |
68 { | |
69 const char *extensions; | |
70 const char *start; | |
71 const char *where, *terminator; | |
72 | |
73 /* Extension names should not have spaces. */ | |
74 where = SDL_strchr(extension, ' '); | |
75 if ( where || *extension == '\0' ) { | |
76 return 0; | |
77 } | |
78 | |
79 extensions = this->gl_data->glXQueryExtensionsString(GFX_Display,SDL_Screen); | |
80 /* It takes a bit of care to be fool-proof about parsing the | |
81 * OpenGL extensions string. Don't be fooled by sub-strings, etc. | |
82 */ | |
4312
f2f8525e60c2
Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents:
4290
diff
changeset
|
83 |
f2f8525e60c2
Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents:
4290
diff
changeset
|
84 /* http://bugs.debian.org/537487 */ |
f2f8525e60c2
Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents:
4290
diff
changeset
|
85 if (extensions == NULL) { |
f2f8525e60c2
Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents:
4290
diff
changeset
|
86 return 0; |
f2f8525e60c2
Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents:
4290
diff
changeset
|
87 } |
1737 | 88 |
89 start = extensions; | |
90 | |
91 for (;;) { | |
92 where = SDL_strstr(start, extension); | |
93 if (!where) break; | |
94 | |
95 terminator = where + strlen(extension); | |
96 if (where == start || *(where - 1) == ' ') | |
97 if (*terminator == ' ' || *terminator == '\0') return 1; | |
98 | |
99 start = terminator; | |
100 } | |
101 return 0; | |
102 } | |
103 #endif /* SDL_VIDEO_OPENGL_GLX */ | |
104 | |
0 | 105 XVisualInfo *X11_GL_GetVisual(_THIS) |
106 { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
107 #if SDL_VIDEO_OPENGL_GLX |
0 | 108 /* 64 seems nice. */ |
109 int attribs[64]; | |
110 int i; | |
111 | |
112 /* load the gl driver from a default path */ | |
113 if ( ! this->gl_config.driver_loaded ) { | |
114 /* no driver has been loaded, use default (ourselves) */ | |
115 if ( X11_GL_LoadLibrary(this, NULL) < 0 ) { | |
116 return NULL; | |
117 } | |
118 } | |
119 | |
120 /* See if we already have a window which we must use */ | |
121 if ( SDL_windowid ) { | |
122 XWindowAttributes a; | |
123 XVisualInfo vi_in; | |
124 int out_count; | |
125 | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
126 XGetWindowAttributes(SDL_Display, SDL_Window, &a); |
0 | 127 vi_in.screen = SDL_Screen; |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
128 vi_in.visualid = XVisualIDFromVisual(a.visual); |
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
129 glx_visualinfo = XGetVisualInfo(SDL_Display, |
0 | 130 VisualScreenMask|VisualIDMask, &vi_in, &out_count); |
131 return glx_visualinfo; | |
132 } | |
133 | |
134 /* Setup our GLX attributes according to the gl_config. */ | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
135 i = 0; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
136 attribs[i++] = GLX_RGBA; |
0 | 137 attribs[i++] = GLX_RED_SIZE; |
138 attribs[i++] = this->gl_config.red_size; | |
139 attribs[i++] = GLX_GREEN_SIZE; | |
140 attribs[i++] = this->gl_config.green_size; | |
141 attribs[i++] = GLX_BLUE_SIZE; | |
142 attribs[i++] = this->gl_config.blue_size; | |
143 | |
144 if( this->gl_config.alpha_size ) { | |
145 attribs[i++] = GLX_ALPHA_SIZE; | |
146 attribs[i++] = this->gl_config.alpha_size; | |
147 } | |
148 | |
149 if( this->gl_config.buffer_size ) { | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
150 attribs[i++] = GLX_BUFFER_SIZE; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
151 attribs[i++] = this->gl_config.buffer_size; |
0 | 152 } |
153 | |
154 if( this->gl_config.double_buffer ) { | |
155 attribs[i++] = GLX_DOUBLEBUFFER; | |
156 } | |
157 | |
158 attribs[i++] = GLX_DEPTH_SIZE; | |
159 attribs[i++] = this->gl_config.depth_size; | |
160 | |
161 if( this->gl_config.stencil_size ) { | |
162 attribs[i++] = GLX_STENCIL_SIZE; | |
163 attribs[i++] = this->gl_config.stencil_size; | |
164 } | |
165 | |
166 if( this->gl_config.accum_red_size ) { | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
167 attribs[i++] = GLX_ACCUM_RED_SIZE; |
0 | 168 attribs[i++] = this->gl_config.accum_red_size; |
169 } | |
170 | |
171 if( this->gl_config.accum_green_size ) { | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
172 attribs[i++] = GLX_ACCUM_GREEN_SIZE; |
0 | 173 attribs[i++] = this->gl_config.accum_green_size; |
174 } | |
175 | |
176 if( this->gl_config.accum_blue_size ) { | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
177 attribs[i++] = GLX_ACCUM_BLUE_SIZE; |
0 | 178 attribs[i++] = this->gl_config.accum_blue_size; |
179 } | |
180 | |
181 if( this->gl_config.accum_alpha_size ) { | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
182 attribs[i++] = GLX_ACCUM_ALPHA_SIZE; |
0 | 183 attribs[i++] = this->gl_config.accum_alpha_size; |
184 } | |
185 | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
186 if( this->gl_config.stereo ) { |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
187 attribs[i++] = GLX_STEREO; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
188 } |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
189 |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
190 if( this->gl_config.multisamplebuffers ) { |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
191 attribs[i++] = GLX_SAMPLE_BUFFERS_ARB; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
192 attribs[i++] = this->gl_config.multisamplebuffers; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
193 } |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
194 |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
195 if( this->gl_config.multisamplesamples ) { |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
196 attribs[i++] = GLX_SAMPLES_ARB; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
197 attribs[i++] = this->gl_config.multisamplesamples; |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
198 } |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
199 |
1737 | 200 if( this->gl_config.accelerated >= 0 && |
201 glXExtensionSupported(this, "GLX_EXT_visual_rating") ) { | |
202 attribs[i++] = GLX_VISUAL_CAVEAT_EXT; | |
1841
0495a8e98595
Use the correct parameter for GLX_VISUAL_CAVEAT_EXT
Sam Lantinga <slouken@libsdl.org>
parents:
1737
diff
changeset
|
203 attribs[i++] = GLX_NONE_EXT; |
1737 | 204 } |
205 | |
0 | 206 #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1315
diff
changeset
|
207 if ( !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { |
1060
86885b40a53b
Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents:
862
diff
changeset
|
208 attribs[i++] = GLX_X_VISUAL_TYPE; |
86885b40a53b
Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents:
862
diff
changeset
|
209 attribs[i++] = GLX_DIRECT_COLOR; |
86885b40a53b
Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents:
862
diff
changeset
|
210 } |
0 | 211 #endif |
212 attribs[i++] = None; | |
213 | |
214 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, | |
215 SDL_Screen, attribs); | |
216 #ifdef GLX_DIRECT_COLOR | |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1315
diff
changeset
|
217 if( !glx_visualinfo && !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { /* No DirectColor visual? Try again.. */ |
0 | 218 attribs[i-3] = None; |
219 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display, | |
220 SDL_Screen, attribs); | |
221 } | |
222 #endif | |
223 if( !glx_visualinfo ) { | |
224 SDL_SetError( "Couldn't find matching GLX visual"); | |
225 return NULL; | |
226 } | |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
227 /* |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
228 printf("Found GLX visual 0x%x\n", glx_visualinfo->visualid); |
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
229 */ |
0 | 230 return glx_visualinfo; |
231 #else | |
232 SDL_SetError("X11 driver not configured with OpenGL"); | |
233 return NULL; | |
234 #endif | |
235 } | |
236 | |
237 int X11_GL_CreateWindow(_THIS, int w, int h) | |
238 { | |
239 int retval; | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
240 #if SDL_VIDEO_OPENGL_GLX |
0 | 241 XSetWindowAttributes attributes; |
242 unsigned long mask; | |
243 unsigned long black; | |
244 | |
245 black = (glx_visualinfo->visual == DefaultVisual(SDL_Display, | |
246 SDL_Screen)) | |
247 ? BlackPixel(SDL_Display, SDL_Screen) : 0; | |
248 attributes.background_pixel = black; | |
249 attributes.border_pixel = black; | |
250 attributes.colormap = SDL_XColorMap; | |
251 mask = CWBackPixel | CWBorderPixel | CWColormap; | |
252 | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
253 SDL_Window = XCreateWindow(SDL_Display, WMwindow, |
0 | 254 0, 0, w, h, 0, glx_visualinfo->depth, |
255 InputOutput, glx_visualinfo->visual, | |
256 mask, &attributes); | |
257 if ( !SDL_Window ) { | |
258 SDL_SetError("Could not create window"); | |
259 return -1; | |
260 } | |
261 retval = 0; | |
262 #else | |
263 SDL_SetError("X11 driver not configured with OpenGL"); | |
264 retval = -1; | |
265 #endif | |
266 return(retval); | |
267 } | |
268 | |
269 int X11_GL_CreateContext(_THIS) | |
270 { | |
271 int retval; | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
272 #if SDL_VIDEO_OPENGL_GLX |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
273 |
0 | 274 /* We do this to create a clean separation between X and GLX errors. */ |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
275 XSync( SDL_Display, False ); |
0 | 276 glx_context = this->gl_data->glXCreateContext(GFX_Display, |
277 glx_visualinfo, NULL, True); | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
278 XSync( GFX_Display, False ); |
0 | 279 |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
280 if ( glx_context == NULL ) { |
0 | 281 SDL_SetError("Could not create GL context"); |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
282 return(-1); |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
283 } |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
284 if ( X11_GL_MakeCurrent(this) < 0 ) { |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
285 return(-1); |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
286 } |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
287 gl_active = 1; |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
288 |
3940
cb04355ffec4
Check correct glX extension name for swap_control, but it doesn't look like
Ryan C. Gordon <icculus@icculus.org>
parents:
3905
diff
changeset
|
289 if ( !glXExtensionSupported(this, "GLX_SGI_swap_control") ) { |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
290 this->gl_data->glXSwapIntervalSGI = NULL; |
0 | 291 } |
1737 | 292 if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) { |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
293 this->gl_data->glXSwapIntervalMESA = NULL; |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
294 } |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
295 if ( this->gl_config.swap_control >= 0 ) { |
4290
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
296 int rc = -1; |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
297 if ( this->gl_data->glXSwapIntervalMESA ) { |
4290
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
298 rc = this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control); |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
299 } else if ( this->gl_data->glXSwapIntervalSGI ) { |
4290
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
300 rc = this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control); |
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
301 } |
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
302 if (rc == 0) { |
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
303 this->gl_data->swap_interval = this->gl_config.swap_control; |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
304 } |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
305 } |
0 | 306 #else |
307 SDL_SetError("X11 driver not configured with OpenGL"); | |
308 #endif | |
309 if ( gl_active ) { | |
310 retval = 0; | |
311 } else { | |
312 retval = -1; | |
313 } | |
314 return(retval); | |
315 } | |
316 | |
317 void X11_GL_Shutdown(_THIS) | |
318 { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
319 #if SDL_VIDEO_OPENGL_GLX |
0 | 320 /* Clean up OpenGL */ |
321 if( glx_context ) { | |
322 this->gl_data->glXMakeCurrent(GFX_Display, None, NULL); | |
323 | |
324 if (glx_context != NULL) | |
325 this->gl_data->glXDestroyContext(GFX_Display, glx_context); | |
326 | |
327 glx_context = NULL; | |
328 } | |
329 gl_active = 0; | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
330 #endif /* SDL_VIDEO_OPENGL_GLX */ |
0 | 331 } |
332 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
333 #if SDL_VIDEO_OPENGL_GLX |
0 | 334 |
335 /* Make the current context active */ | |
336 int X11_GL_MakeCurrent(_THIS) | |
337 { | |
338 int retval; | |
638
b0108e9dea53
Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
566
diff
changeset
|
339 |
0 | 340 retval = 0; |
341 if ( ! this->gl_data->glXMakeCurrent(GFX_Display, | |
342 SDL_Window, glx_context) ) { | |
343 SDL_SetError("Unable to make GL context current"); | |
344 retval = -1; | |
345 } | |
1575
3ba88cb7eb1b
Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents:
1402
diff
changeset
|
346 XSync( GFX_Display, False ); |
0 | 347 |
348 /* More Voodoo X server workarounds... Grr... */ | |
349 SDL_Lock_EventThread(); | |
350 X11_CheckDGAMouse(this); | |
351 SDL_Unlock_EventThread(); | |
352 | |
353 return(retval); | |
354 } | |
355 | |
356 /* Get attribute data from glX. */ | |
357 int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) | |
358 { | |
4092
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
359 int retval = -1; |
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
360 int unsupported = 0; |
0 | 361 int glx_attrib = None; |
362 | |
363 switch( attrib ) { | |
364 case SDL_GL_RED_SIZE: | |
365 glx_attrib = GLX_RED_SIZE; | |
366 break; | |
367 case SDL_GL_GREEN_SIZE: | |
368 glx_attrib = GLX_GREEN_SIZE; | |
369 break; | |
370 case SDL_GL_BLUE_SIZE: | |
371 glx_attrib = GLX_BLUE_SIZE; | |
372 break; | |
373 case SDL_GL_ALPHA_SIZE: | |
374 glx_attrib = GLX_ALPHA_SIZE; | |
375 break; | |
376 case SDL_GL_DOUBLEBUFFER: | |
377 glx_attrib = GLX_DOUBLEBUFFER; | |
378 break; | |
379 case SDL_GL_BUFFER_SIZE: | |
380 glx_attrib = GLX_BUFFER_SIZE; | |
381 break; | |
382 case SDL_GL_DEPTH_SIZE: | |
383 glx_attrib = GLX_DEPTH_SIZE; | |
384 break; | |
385 case SDL_GL_STENCIL_SIZE: | |
386 glx_attrib = GLX_STENCIL_SIZE; | |
387 break; | |
388 case SDL_GL_ACCUM_RED_SIZE: | |
389 glx_attrib = GLX_ACCUM_RED_SIZE; | |
390 break; | |
391 case SDL_GL_ACCUM_GREEN_SIZE: | |
392 glx_attrib = GLX_ACCUM_GREEN_SIZE; | |
393 break; | |
394 case SDL_GL_ACCUM_BLUE_SIZE: | |
395 glx_attrib = GLX_ACCUM_BLUE_SIZE; | |
396 break; | |
397 case SDL_GL_ACCUM_ALPHA_SIZE: | |
398 glx_attrib = GLX_ACCUM_ALPHA_SIZE; | |
399 break; | |
450
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
400 case SDL_GL_STEREO: |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
401 glx_attrib = GLX_STEREO; |
8a43e0cbf02f
Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents:
297
diff
changeset
|
402 break; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
403 case SDL_GL_MULTISAMPLEBUFFERS: |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
404 glx_attrib = GLX_SAMPLE_BUFFERS_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
405 break; |
656
864e2d2a9a55
Merged in Ryan's multisample code for MacOS, and changed the constants to match.
Sam Lantinga <slouken@libsdl.org>
parents:
655
diff
changeset
|
406 case SDL_GL_MULTISAMPLESAMPLES: |
655
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
407 glx_attrib = GLX_SAMPLES_ARB; |
9c42ee1b7d77
Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents:
646
diff
changeset
|
408 break; |
1737 | 409 case SDL_GL_ACCELERATED_VISUAL: |
410 if ( glXExtensionSupported(this, "GLX_EXT_visual_rating") ) { | |
411 glx_attrib = GLX_VISUAL_CAVEAT_EXT; | |
412 retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value); | |
413 if ( *value == GLX_SLOW_VISUAL_EXT ) { | |
414 *value = SDL_FALSE; | |
415 } else { | |
416 *value = SDL_TRUE; | |
417 } | |
418 return retval; | |
419 } else { | |
4092
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
420 unsupported = 1; |
1737 | 421 } |
422 break; | |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
423 case SDL_GL_SWAP_CONTROL: |
4290
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
424 if ( ( this->gl_data->glXSwapIntervalMESA ) || |
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
425 ( this->gl_data->glXSwapIntervalSGI ) ) { |
485868a1c283
Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents:
4289
diff
changeset
|
426 *value = this->gl_data->swap_interval; |
4268
d48035d857d3
Make SDL_GL_GetAttribute(SDL_GL_SWAP_CONTROL) work with GLX_SGI_swap_control.
Ryan C. Gordon <icculus@icculus.org>
parents:
4183
diff
changeset
|
427 return 0; |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
428 } else { |
4092
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
429 unsupported = 1; |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
430 } |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
431 break; |
0 | 432 default: |
4092
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
433 unsupported = 1; |
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
434 break; |
0 | 435 } |
436 | |
4092
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
437 if (unsupported) { |
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
438 SDL_SetError("OpenGL attribute is unsupported on this system"); |
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
439 } else { |
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
440 retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value); |
2b32a416d202
Set an error message when SDL_GL_SetAttribute() fails because we can't support
Ryan C. Gordon <icculus@icculus.org>
parents:
4023
diff
changeset
|
441 } |
0 | 442 return retval; |
443 } | |
444 | |
445 void X11_GL_SwapBuffers(_THIS) | |
446 { | |
447 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window); | |
448 } | |
449 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
450 #endif /* SDL_VIDEO_OPENGL_GLX */ |
0 | 451 |
1861 | 452 #define OPENGL_REQUIRS_DLOPEN |
453 #if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN) | |
454 #include <dlfcn.h> | |
455 #define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) | |
456 #define GL_LoadFunction dlsym | |
457 #define GL_UnloadObject dlclose | |
458 #else | |
459 #define GL_LoadObject SDL_LoadObject | |
460 #define GL_LoadFunction SDL_LoadFunction | |
461 #define GL_UnloadObject SDL_UnloadObject | |
462 #endif | |
463 | |
0 | 464 void X11_GL_UnloadLibrary(_THIS) |
465 { | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
466 #if SDL_VIDEO_OPENGL_GLX |
0 | 467 if ( this->gl_config.driver_loaded ) { |
1191
2bd4cec0de63
Seperate glX from HAVE_OPENGL, for platforms that have both an X server and
Ryan C. Gordon <icculus@icculus.org>
parents:
1182
diff
changeset
|
468 |
1861 | 469 GL_UnloadObject(this->gl_config.dll_handle); |
0 | 470 |
471 this->gl_data->glXGetProcAddress = NULL; | |
472 this->gl_data->glXChooseVisual = NULL; | |
473 this->gl_data->glXCreateContext = NULL; | |
474 this->gl_data->glXDestroyContext = NULL; | |
475 this->gl_data->glXMakeCurrent = NULL; | |
476 this->gl_data->glXSwapBuffers = NULL; | |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
477 this->gl_data->glXSwapIntervalSGI = NULL; |
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
478 this->gl_data->glXSwapIntervalMESA = NULL; |
0 | 479 |
480 this->gl_config.dll_handle = NULL; | |
481 this->gl_config.driver_loaded = 0; | |
482 } | |
483 #endif | |
484 } | |
485 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
486 #if SDL_VIDEO_OPENGL_GLX |
1182
e8e8dcb68e7a
X11 driver now chooses "libGL.so.1" as a default when a NULL is passed to
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
487 |
0 | 488 /* Passing a NULL path means load pointers from the application */ |
489 int X11_GL_LoadLibrary(_THIS, const char* path) | |
490 { | |
1191
2bd4cec0de63
Seperate glX from HAVE_OPENGL, for platforms that have both an X server and
Ryan C. Gordon <icculus@icculus.org>
parents:
1182
diff
changeset
|
491 void* handle = NULL; |
0 | 492 |
1182
e8e8dcb68e7a
X11 driver now chooses "libGL.so.1" as a default when a NULL is passed to
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
493 if ( gl_active ) { |
e8e8dcb68e7a
X11 driver now chooses "libGL.so.1" as a default when a NULL is passed to
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
494 SDL_SetError("OpenGL context already created"); |
e8e8dcb68e7a
X11 driver now chooses "libGL.so.1" as a default when a NULL is passed to
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
495 return -1; |
e8e8dcb68e7a
X11 driver now chooses "libGL.so.1" as a default when a NULL is passed to
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
496 } |
e8e8dcb68e7a
X11 driver now chooses "libGL.so.1" as a default when a NULL is passed to
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
497 |
e8e8dcb68e7a
X11 driver now chooses "libGL.so.1" as a default when a NULL is passed to
Ryan C. Gordon <icculus@icculus.org>
parents:
1168
diff
changeset
|
498 if ( path == NULL ) { |
1336
3692456e7b0f
Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents:
1315
diff
changeset
|
499 path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); |
0 | 500 if ( path == NULL ) { |
501 path = DEFAULT_OPENGL; | |
502 } | |
1191
2bd4cec0de63
Seperate glX from HAVE_OPENGL, for platforms that have both an X server and
Ryan C. Gordon <icculus@icculus.org>
parents:
1182
diff
changeset
|
503 } |
2bd4cec0de63
Seperate glX from HAVE_OPENGL, for platforms that have both an X server and
Ryan C. Gordon <icculus@icculus.org>
parents:
1182
diff
changeset
|
504 |
1861 | 505 handle = GL_LoadObject(path); |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
506 if ( handle == NULL ) { |
3905
0e0883cb7137
Add error message if not using SDL_LoadObject
Patrice Mandin <patmandin@gmail.com>
parents:
1880
diff
changeset
|
507 #if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN) |
0e0883cb7137
Add error message if not using SDL_LoadObject
Patrice Mandin <patmandin@gmail.com>
parents:
1880
diff
changeset
|
508 SDL_SetError("Failed loading %s", path); |
0e0883cb7137
Add error message if not using SDL_LoadObject
Patrice Mandin <patmandin@gmail.com>
parents:
1880
diff
changeset
|
509 #else |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
510 /* SDL_LoadObject() will call SDL_SetError() for us. */ |
3905
0e0883cb7137
Add error message if not using SDL_LoadObject
Patrice Mandin <patmandin@gmail.com>
parents:
1880
diff
changeset
|
511 #endif |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
512 return -1; |
0 | 513 } |
514 | |
515 /* Unload the old driver and reset the pointers */ | |
516 X11_GL_UnloadLibrary(this); | |
517 | |
518 /* Load new function pointers */ | |
180
578815880307
Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents:
127
diff
changeset
|
519 this->gl_data->glXGetProcAddress = |
1861 | 520 (void *(*)(const GLubyte *)) GL_LoadFunction(handle, "glXGetProcAddressARB"); |
180
578815880307
Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents:
127
diff
changeset
|
521 this->gl_data->glXChooseVisual = |
1861 | 522 (XVisualInfo *(*)(Display *, int, int *)) GL_LoadFunction(handle, "glXChooseVisual"); |
180
578815880307
Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents:
127
diff
changeset
|
523 this->gl_data->glXCreateContext = |
1861 | 524 (GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) GL_LoadFunction(handle, "glXCreateContext"); |
180
578815880307
Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents:
127
diff
changeset
|
525 this->gl_data->glXDestroyContext = |
1861 | 526 (void (*)(Display *, GLXContext)) GL_LoadFunction(handle, "glXDestroyContext"); |
180
578815880307
Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents:
127
diff
changeset
|
527 this->gl_data->glXMakeCurrent = |
1861 | 528 (int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle, "glXMakeCurrent"); |
180
578815880307
Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents:
127
diff
changeset
|
529 this->gl_data->glXSwapBuffers = |
1861 | 530 (void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle, "glXSwapBuffers"); |
180
578815880307
Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents:
127
diff
changeset
|
531 this->gl_data->glXGetConfig = |
1861 | 532 (int (*)(Display *, XVisualInfo *, int, int *)) GL_LoadFunction(handle, "glXGetConfig"); |
638
b0108e9dea53
Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
566
diff
changeset
|
533 this->gl_data->glXQueryExtensionsString = |
1861 | 534 (const char *(*)(Display *, int)) GL_LoadFunction(handle, "glXQueryExtensionsString"); |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
535 this->gl_data->glXSwapIntervalSGI = |
1861 | 536 (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI"); |
1736
3b2a92126f4d
Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents:
1577
diff
changeset
|
537 this->gl_data->glXSwapIntervalMESA = |
1861 | 538 (GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA"); |
1315
e94b0d7c33bc
Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents:
1312
diff
changeset
|
539 |
0 | 540 if ( (this->gl_data->glXChooseVisual == NULL) || |
541 (this->gl_data->glXCreateContext == NULL) || | |
542 (this->gl_data->glXDestroyContext == NULL) || | |
543 (this->gl_data->glXMakeCurrent == NULL) || | |
544 (this->gl_data->glXSwapBuffers == NULL) || | |
638
b0108e9dea53
Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
566
diff
changeset
|
545 (this->gl_data->glXGetConfig == NULL) || |
b0108e9dea53
Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents:
566
diff
changeset
|
546 (this->gl_data->glXQueryExtensionsString == NULL)) { |
0 | 547 SDL_SetError("Could not retrieve OpenGL functions"); |
548 return -1; | |
549 } | |
550 | |
551 this->gl_config.dll_handle = handle; | |
552 this->gl_config.driver_loaded = 1; | |
553 if ( path ) { | |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
554 SDL_strlcpy(this->gl_config.driver_path, path, |
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
555 SDL_arraysize(this->gl_config.driver_path)); |
0 | 556 } else { |
1379
c0a74f199ecf
Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents:
1361
diff
changeset
|
557 *this->gl_config.driver_path = '\0'; |
0 | 558 } |
559 return 0; | |
560 } | |
561 | |
562 void *X11_GL_GetProcAddress(_THIS, const char* proc) | |
563 { | |
564 void* handle; | |
565 | |
566 handle = this->gl_config.dll_handle; | |
567 if ( this->gl_data->glXGetProcAddress ) { | |
1196
b81f54c3963f
Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents:
1191
diff
changeset
|
568 return this->gl_data->glXGetProcAddress((const GLubyte *)proc); |
0 | 569 } |
1861 | 570 return GL_LoadFunction(handle, proc); |
0 | 571 } |
572 | |
1361
19418e4422cb
New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents:
1358
diff
changeset
|
573 #endif /* SDL_VIDEO_OPENGL_GLX */ |