annotate src/video/x11/SDL_x11gl.c @ 4390:725e506f6243 SDL-1.2

Fixed bug #895 Markus Rothe 2009-12-07 09:32:46 PST Check if libspe2 is available Building on PowerPC64 results in: [...] In file included from ./src/video/ps3/SDL_ps3events_c.h:33, from ./src/video/ps3/SDL_ps3video.c:32: ./src/video/ps3/SDL_ps3video.h:34:21: error: libspe2.h: No such file or directory In file included from ./src/video/ps3/SDL_ps3events_c.h:33, from ./src/video/ps3/SDL_ps3video.c:32: ./src/video/ps3/SDL_ps3video.h:75: error: expected specifier-qualifier-list before 'spe_context_ptr_t' ./src/video/ps3/SDL_ps3video.c:78: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'fb_writer_spu' ./src/video/ps3/SDL_ps3video.c: In function 'PS3_VideoInit': ./src/video/ps3/SDL_ps3video.c:167: error: 'spu_data_t' has no member named 'program' ./src/video/ps3/SDL_ps3video.c:167: error: 'fb_writer_spu' undeclared (first use in this function) [...] The problem is that the ps3 video driver is being build regardless if libspe2 is installed or not. The attached patch fixes this problem. [ Note: The other headers that are being checked for are coming from the linux headers package on powerpc64. As a result these are also available if you're on a generic powerpc64 machine and not a PS3 only. ]
author Sam Lantinga <slouken@libsdl.org>
date Fri, 11 Dec 2009 15:14:13 +0000
parents 5fe9b267cf55
children 6f0706a60146
rev   line source
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
1 /*
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
2 SDL - Simple DirectMedia Layer
4159
a1b03ba2fcd0 Updated copyright date
Sam Lantinga <slouken@libsdl.org>
parents: 4092
diff changeset
3 Copyright (C) 1997-2009 Sam Lantinga
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
4
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
9
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
10 This library is distributed in the hope that it will be useful,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
18
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #include "SDL_x11dga_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "SDL_x11gl_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
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"
862
f7a8b0ca2ae3 IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
38 #else
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39 #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
40 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
41
667
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
42 #ifndef GLX_ARB_multisample
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
43 #define GLX_ARB_multisample
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
44 #define GLX_SAMPLE_BUFFERS_ARB 100000
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
45 #define GLX_SAMPLES_ARB 100001
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
46 #endif
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
47
4183
39e748f251c6 Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 4159
diff changeset
48 /* 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
49 #ifndef GLX_VISUAL_CAVEAT_EXT
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
50 #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
51 #endif
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_NONE_EXT
1841
0495a8e98595 Use the correct parameter for GLX_VISUAL_CAVEAT_EXT
Sam Lantinga <slouken@libsdl.org>
parents: 1737
diff changeset
53 #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
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_SLOW_VISUAL_EXT
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
56 #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
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_NON_CONFORMANT_VISUAL_EXT
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
59 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
60 #endif
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
61
4183
39e748f251c6 Patched X11 code to compile on Mac OS X 10.6 SDK.
Ryan C. Gordon <icculus@icculus.org>
parents: 4159
diff changeset
62
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
63 #if SDL_VIDEO_OPENGL_GLX
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
64 static int glXExtensionSupported(_THIS, const char *extension)
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
65 {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
66 const char *extensions;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
67 const char *start;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
68 const char *where, *terminator;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
69
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
70 /* Extension names should not have spaces. */
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
71 where = SDL_strchr(extension, ' ');
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
72 if ( where || *extension == '\0' ) {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
73 return 0;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
74 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
75
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
76 extensions = this->gl_data->glXQueryExtensionsString(GFX_Display,SDL_Screen);
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
77 /* It takes a bit of care to be fool-proof about parsing the
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
78 * OpenGL extensions string. Don't be fooled by sub-strings, etc.
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
79 */
4312
f2f8525e60c2 Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents: 4290
diff changeset
80
f2f8525e60c2 Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents: 4290
diff changeset
81 /* http://bugs.debian.org/537487 */
f2f8525e60c2 Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents: 4290
diff changeset
82 if (extensions == NULL) {
f2f8525e60c2 Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents: 4290
diff changeset
83 return 0;
f2f8525e60c2 Debian patch: 310_segfault_noGLX.diff
Sam Lantinga <slouken@libsdl.org>
parents: 4290
diff changeset
84 }
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
85
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
86 start = extensions;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
87
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
88 for (;;) {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
89 where = SDL_strstr(start, extension);
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
90 if (!where) break;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
91
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
92 terminator = where + strlen(extension);
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
93 if (where == start || *(where - 1) == ' ')
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
94 if (*terminator == ' ' || *terminator == '\0') return 1;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
95
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
96 start = terminator;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
97 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
98 return 0;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
99 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
100 #endif /* SDL_VIDEO_OPENGL_GLX */
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
101
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 XVisualInfo *X11_GL_GetVisual(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
104 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 /* 64 seems nice. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 int attribs[64];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 int i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 /* load the gl driver from a default path */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 if ( ! this->gl_config.driver_loaded ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 /* no driver has been loaded, use default (ourselves) */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 if ( X11_GL_LoadLibrary(this, NULL) < 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117 /* See if we already have a window which we must use */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 if ( SDL_windowid ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 XWindowAttributes a;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 XVisualInfo vi_in;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 int out_count;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
123 XGetWindowAttributes(SDL_Display, SDL_Window, &a);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 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
125 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
126 glx_visualinfo = XGetVisualInfo(SDL_Display,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127 VisualScreenMask|VisualIDMask, &vi_in, &out_count);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
128 return glx_visualinfo;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
129 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
130
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
131 /* 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
132 i = 0;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
133 attribs[i++] = GLX_RGBA;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
134 attribs[i++] = GLX_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
135 attribs[i++] = this->gl_config.red_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
136 attribs[i++] = GLX_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
137 attribs[i++] = this->gl_config.green_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
138 attribs[i++] = GLX_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
139 attribs[i++] = this->gl_config.blue_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
140
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 if( this->gl_config.alpha_size ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
142 attribs[i++] = GLX_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 attribs[i++] = this->gl_config.alpha_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
144 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
145
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 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
147 attribs[i++] = GLX_BUFFER_SIZE;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
148 attribs[i++] = this->gl_config.buffer_size;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 if( this->gl_config.double_buffer ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 attribs[i++] = GLX_DOUBLEBUFFER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 attribs[i++] = GLX_DEPTH_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 attribs[i++] = this->gl_config.depth_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 if( this->gl_config.stencil_size ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 attribs[i++] = GLX_STENCIL_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 attribs[i++] = this->gl_config.stencil_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 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
164 attribs[i++] = GLX_ACCUM_RED_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 attribs[i++] = this->gl_config.accum_red_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 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
169 attribs[i++] = GLX_ACCUM_GREEN_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 attribs[i++] = this->gl_config.accum_green_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 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
174 attribs[i++] = GLX_ACCUM_BLUE_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 attribs[i++] = this->gl_config.accum_blue_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 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
179 attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 attribs[i++] = this->gl_config.accum_alpha_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
183 if( this->gl_config.stereo ) {
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
184 attribs[i++] = GLX_STEREO;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
185 }
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
186
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
187 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
188 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
189 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
190 }
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
191
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 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
193 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
194 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
195 }
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
196
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
197 if( this->gl_config.accelerated >= 0 &&
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
198 glXExtensionSupported(this, "GLX_EXT_visual_rating") ) {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
199 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
200 attribs[i++] = GLX_NONE_EXT;
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
201 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
202
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203 #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
204 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
205 attribs[i++] = GLX_X_VISUAL_TYPE;
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
206 attribs[i++] = GLX_DIRECT_COLOR;
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
207 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
209 attribs[i++] = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
211 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212 SDL_Screen, attribs);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 #ifdef GLX_DIRECT_COLOR
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1315
diff changeset
214 if( !glx_visualinfo && !SDL_getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { /* No DirectColor visual? Try again.. */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215 attribs[i-3] = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 SDL_Screen, attribs);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220 if( !glx_visualinfo ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221 SDL_SetError( "Couldn't find matching GLX visual");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
223 }
1315
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
224 /*
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
225 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
226 */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 return glx_visualinfo;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
230 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
231 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234 int X11_GL_CreateWindow(_THIS, int w, int h)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
235 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
236 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
237 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
238 XSetWindowAttributes attributes;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239 unsigned long mask;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
240 unsigned long black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 black = (glx_visualinfo->visual == DefaultVisual(SDL_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243 SDL_Screen))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 ? BlackPixel(SDL_Display, SDL_Screen) : 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 attributes.background_pixel = black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 attributes.border_pixel = black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 attributes.colormap = SDL_XColorMap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 mask = CWBackPixel | CWBorderPixel | CWColormap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
250 SDL_Window = XCreateWindow(SDL_Display, WMwindow,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 0, 0, w, h, 0, glx_visualinfo->depth,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 InputOutput, glx_visualinfo->visual,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 mask, &attributes);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 if ( !SDL_Window ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255 SDL_SetError("Could not create window");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 int X11_GL_CreateContext(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268 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
269 #if SDL_VIDEO_OPENGL_GLX
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
270
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 /* 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
272 XSync( SDL_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 glx_context = this->gl_data->glXCreateContext(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274 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
275 XSync( GFX_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
277 if ( glx_context == NULL ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 SDL_SetError("Could not create GL context");
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
279 return(-1);
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
280 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
281 if ( X11_GL_MakeCurrent(this) < 0 ) {
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 gl_active = 1;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
285
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
286 if ( !glXExtensionSupported(this, "GLX_SGI_swap_control") ) {
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
287 this->gl_data->glXSwapIntervalSGI = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 }
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
289 if ( !glXExtensionSupported(this, "GLX_MESA_swap_control") ) {
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
290 this->gl_data->glXSwapIntervalMESA = NULL;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
291 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
292 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
293 int rc = -1;
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
294 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
295 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
296 } 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
297 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
298 }
485868a1c283 Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents: 4289
diff changeset
299 if (rc == 0) {
485868a1c283 Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents: 4289
diff changeset
300 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
301 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
302 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 if ( gl_active ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 void X11_GL_Shutdown(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315 {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
316 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
317 /* Clean up OpenGL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318 if( glx_context ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
319 this->gl_data->glXMakeCurrent(GFX_Display, None, NULL);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
321 if (glx_context != NULL)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
322 this->gl_data->glXDestroyContext(GFX_Display, glx_context);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
323
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324 glx_context = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 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
327 #endif /* SDL_VIDEO_OPENGL_GLX */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
330 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332 /* Make the current context active */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333 int X11_GL_MakeCurrent(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
334 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
335 int retval;
638
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
336
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
338 if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339 SDL_Window, glx_context) ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340 SDL_SetError("Unable to make GL context current");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
342 }
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
343 XSync( GFX_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
344
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
345 /* More Voodoo X server workarounds... Grr... */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
346 SDL_Lock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
347 X11_CheckDGAMouse(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
348 SDL_Unlock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
349
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
351 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353 /* Get attribute data from glX. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
354 int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355 {
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
356 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
357 int unsupported = 0;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358 int glx_attrib = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
359
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360 switch( attrib ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 case SDL_GL_RED_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362 glx_attrib = GLX_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
364 case SDL_GL_GREEN_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
365 glx_attrib = GLX_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
366 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
367 case SDL_GL_BLUE_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
368 glx_attrib = GLX_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
369 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
370 case SDL_GL_ALPHA_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
371 glx_attrib = GLX_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
372 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
373 case SDL_GL_DOUBLEBUFFER:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
374 glx_attrib = GLX_DOUBLEBUFFER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
375 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
376 case SDL_GL_BUFFER_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
377 glx_attrib = GLX_BUFFER_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
378 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
379 case SDL_GL_DEPTH_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
380 glx_attrib = GLX_DEPTH_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
381 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
382 case SDL_GL_STENCIL_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
383 glx_attrib = GLX_STENCIL_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
384 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
385 case SDL_GL_ACCUM_RED_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
386 glx_attrib = GLX_ACCUM_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
387 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
388 case SDL_GL_ACCUM_GREEN_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
389 glx_attrib = GLX_ACCUM_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
390 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
391 case SDL_GL_ACCUM_BLUE_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
392 glx_attrib = GLX_ACCUM_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
393 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
394 case SDL_GL_ACCUM_ALPHA_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
395 glx_attrib = GLX_ACCUM_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
396 break;
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
397 case SDL_GL_STEREO:
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
398 glx_attrib = GLX_STEREO;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
399 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
400 case SDL_GL_MULTISAMPLEBUFFERS:
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
401 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
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_MULTISAMPLESAMPLES:
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
404 glx_attrib = GLX_SAMPLES_ARB;
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
405 break;
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
406 case SDL_GL_ACCELERATED_VISUAL:
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
407 if ( glXExtensionSupported(this, "GLX_EXT_visual_rating") ) {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
408 glx_attrib = GLX_VISUAL_CAVEAT_EXT;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
409 retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value);
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
410 if ( *value == GLX_SLOW_VISUAL_EXT ) {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
411 *value = SDL_FALSE;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
412 } else {
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
413 *value = SDL_TRUE;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
414 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
415 return retval;
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
416 } 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
417 unsupported = 1;
1737
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
418 }
eacc5bc01d1c Implemented bug #5
Sam Lantinga <slouken@libsdl.org>
parents: 1736
diff changeset
419 break;
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
420 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
421 if ( ( this->gl_data->glXSwapIntervalMESA ) ||
485868a1c283 Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents: 4289
diff changeset
422 ( this->gl_data->glXSwapIntervalSGI ) ) {
485868a1c283 Cache the swap control setting, even on Mesa.
Ryan C. Gordon <icculus@icculus.org>
parents: 4289
diff changeset
423 *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
424 return 0;
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
425 } 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
426 unsupported = 1;
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
427 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
428 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
429 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
430 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
431 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
432 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
433
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
434 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
435 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
436 } 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
437 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
438 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
439 return retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
440 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
441
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
442 void X11_GL_SwapBuffers(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
443 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
444 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
445 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
446
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
447 #endif /* SDL_VIDEO_OPENGL_GLX */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
448
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
449 #define OPENGL_REQUIRS_DLOPEN
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
450 #if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN)
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
451 #include <dlfcn.h>
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
452 #define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL))
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
453 #define GL_LoadFunction dlsym
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
454 #define GL_UnloadObject dlclose
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
455 #else
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
456 #define GL_LoadObject SDL_LoadObject
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
457 #define GL_LoadFunction SDL_LoadFunction
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
458 #define GL_UnloadObject SDL_UnloadObject
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
459 #endif
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
460
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
461 void X11_GL_UnloadLibrary(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462 {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
463 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
464 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
465
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
466 GL_UnloadObject(this->gl_config.dll_handle);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
467
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
468 this->gl_data->glXGetProcAddress = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
469 this->gl_data->glXChooseVisual = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
470 this->gl_data->glXCreateContext = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
471 this->gl_data->glXDestroyContext = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
472 this->gl_data->glXMakeCurrent = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
473 this->gl_data->glXSwapBuffers = NULL;
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
474 this->gl_data->glXSwapIntervalSGI = NULL;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
475 this->gl_data->glXSwapIntervalMESA = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
476
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
477 this->gl_config.dll_handle = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
478 this->gl_config.driver_loaded = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
479 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
480 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
481 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
482
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
483 #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
484
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
485 /* Passing a NULL path means load pointers from the application */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
486 int X11_GL_LoadLibrary(_THIS, const char* path)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
487 {
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
488 void* handle = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
489
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
490 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
491 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
492 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
493 }
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
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 if ( path == NULL ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1315
diff changeset
496 path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
497 if ( path == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
498 path = DEFAULT_OPENGL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
499 }
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
500 }
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
501
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
502 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
503 if ( handle == NULL ) {
3905
0e0883cb7137 Add error message if not using SDL_LoadObject
Patrice Mandin <patmandin@gmail.com>
parents: 1880
diff changeset
504 #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
505 SDL_SetError("Failed loading %s", path);
0e0883cb7137 Add error message if not using SDL_LoadObject
Patrice Mandin <patmandin@gmail.com>
parents: 1880
diff changeset
506 #else
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
507 /* 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
508 #endif
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
509 return -1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
510 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
511
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
512 /* Unload the old driver and reset the pointers */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
513 X11_GL_UnloadLibrary(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
514
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
515 /* Load new function pointers */
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
516 this->gl_data->glXGetProcAddress =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
517 (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
518 this->gl_data->glXChooseVisual =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
519 (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
520 this->gl_data->glXCreateContext =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
521 (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
522 this->gl_data->glXDestroyContext =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
523 (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
524 this->gl_data->glXMakeCurrent =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
525 (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
526 this->gl_data->glXSwapBuffers =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
527 (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
528 this->gl_data->glXGetConfig =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
529 (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
530 this->gl_data->glXQueryExtensionsString =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
531 (const char *(*)(Display *, int)) GL_LoadFunction(handle, "glXQueryExtensionsString");
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
532 this->gl_data->glXSwapIntervalSGI =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
533 (int (*)(int)) GL_LoadFunction(handle, "glXSwapIntervalSGI");
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
534 this->gl_data->glXSwapIntervalMESA =
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
535 (GLint (*)(unsigned)) GL_LoadFunction(handle, "glXSwapIntervalMESA");
1315
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
536
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
537 if ( (this->gl_data->glXChooseVisual == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
538 (this->gl_data->glXCreateContext == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
539 (this->gl_data->glXDestroyContext == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
540 (this->gl_data->glXMakeCurrent == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
541 (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
542 (this->gl_data->glXGetConfig == NULL) ||
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
543 (this->gl_data->glXQueryExtensionsString == NULL)) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
544 SDL_SetError("Could not retrieve OpenGL functions");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
545 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
546 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
547
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
548 this->gl_config.dll_handle = handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
549 this->gl_config.driver_loaded = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
550 if ( path ) {
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
551 SDL_strlcpy(this->gl_config.driver_path, path,
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
552 SDL_arraysize(this->gl_config.driver_path));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
553 } else {
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
554 *this->gl_config.driver_path = '\0';
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
555 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
556 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
557 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
558
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
559 void *X11_GL_GetProcAddress(_THIS, const char* proc)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
560 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
561 void* handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
562
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
563 handle = this->gl_config.dll_handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
564 if ( this->gl_data->glXGetProcAddress ) {
1196
b81f54c3963f Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents: 1191
diff changeset
565 return this->gl_data->glXGetProcAddress((const GLubyte *)proc);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
566 }
1861
b42823412c3b Fixed bug #232
Sam Lantinga <slouken@libsdl.org>
parents: 1841
diff changeset
567 return GL_LoadFunction(handle, proc);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
568 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
569
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
570 #endif /* SDL_VIDEO_OPENGL_GLX */