annotate src/video/x11/SDL_x11gl.c @ 1736:3b2a92126f4d

Implemented bug #2, 117: Date: Mon, 21 Mar 2005 12:06:14 +0100 From: Per Inge Mathisen Subject: Re: [SDL] Outstanding patches? The patch adds support for setting SDL_GL_SWAP_CONTROL to Windows and X11. In Windows you can also query this enum to check that it is working, or see what the default is - such functionality does not exist in GLX. For more information on the standards implemented: http://oss.sgi.com/projects/ogl-sample/registry/SGI/swap_control.txt http://oss.sgi.com/projects/ogl-sample/registry/EXT/wgl_swap_control.txt
author Sam Lantinga <slouken@libsdl.org>
date Thu, 27 Apr 2006 07:59:16 +0000
parents d75c2d78e87d
children eacc5bc01d1c
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
1312
c9b51268668f Updated copyright information and removed rcs id lines (problematic in branch merges)
Sam Lantinga <slouken@libsdl.org>
parents: 1247
diff changeset
3 Copyright (C) 1997-2006 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"
862
f7a8b0ca2ae3 IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
36 #else
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
37 #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
38 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
39
667
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
40 #ifndef GLX_ARB_multisample
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
41 #define GLX_ARB_multisample
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
42 #define GLX_SAMPLE_BUFFERS_ARB 100000
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
43 #define GLX_SAMPLES_ARB 100001
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
44 #endif
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
45
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
46 XVisualInfo *X11_GL_GetVisual(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
48 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
49 /* 64 seems nice. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 int attribs[64];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 int i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53 /* load the gl driver from a default path */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 if ( ! this->gl_config.driver_loaded ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 /* no driver has been loaded, use default (ourselves) */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 if ( X11_GL_LoadLibrary(this, NULL) < 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
59 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
60
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
61 /* See if we already have a window which we must use */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 if ( SDL_windowid ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 XWindowAttributes a;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 XVisualInfo vi_in;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 int out_count;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
67 XGetWindowAttributes(SDL_Display, SDL_Window, &a);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
68 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
69 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
70 glx_visualinfo = XGetVisualInfo(SDL_Display,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
71 VisualScreenMask|VisualIDMask, &vi_in, &out_count);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 return glx_visualinfo;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75 /* 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
76 i = 0;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
77 attribs[i++] = GLX_RGBA;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
78 attribs[i++] = GLX_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 attribs[i++] = this->gl_config.red_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 attribs[i++] = GLX_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 attribs[i++] = this->gl_config.green_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 attribs[i++] = GLX_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 attribs[i++] = this->gl_config.blue_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85 if( this->gl_config.alpha_size ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 attribs[i++] = GLX_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 attribs[i++] = this->gl_config.alpha_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90 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
91 attribs[i++] = GLX_BUFFER_SIZE;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
92 attribs[i++] = this->gl_config.buffer_size;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
93 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95 if( this->gl_config.double_buffer ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 attribs[i++] = GLX_DOUBLEBUFFER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99 attribs[i++] = GLX_DEPTH_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 attribs[i++] = this->gl_config.depth_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102 if( this->gl_config.stencil_size ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 attribs[i++] = GLX_STENCIL_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 attribs[i++] = this->gl_config.stencil_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107 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
108 attribs[i++] = GLX_ACCUM_RED_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
109 attribs[i++] = this->gl_config.accum_red_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112 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
113 attribs[i++] = GLX_ACCUM_GREEN_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
114 attribs[i++] = this->gl_config.accum_green_size;
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 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
118 attribs[i++] = GLX_ACCUM_BLUE_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
119 attribs[i++] = this->gl_config.accum_blue_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122 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
123 attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
124 attribs[i++] = this->gl_config.accum_alpha_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
127 if( this->gl_config.stereo ) {
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
128 attribs[i++] = GLX_STEREO;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
129 }
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
130
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
131 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
132 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
133 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
134 }
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
135
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
136 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
137 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
138 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
139 }
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
140
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
141 #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
142 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
143 attribs[i++] = GLX_X_VISUAL_TYPE;
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
144 attribs[i++] = GLX_DIRECT_COLOR;
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
145 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
146 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
147 attribs[i++] = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150 SDL_Screen, attribs);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 #ifdef GLX_DIRECT_COLOR
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1315
diff changeset
152 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
153 attribs[i-3] = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
154 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 SDL_Screen, attribs);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 if( !glx_visualinfo ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 SDL_SetError( "Couldn't find matching GLX visual");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 }
1315
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
162 /*
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
163 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
164 */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
165 return glx_visualinfo;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
166 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 int X11_GL_CreateWindow(_THIS, int w, int h)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
173 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
174 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
175 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 XSetWindowAttributes attributes;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
177 unsigned long mask;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 unsigned long black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 black = (glx_visualinfo->visual == DefaultVisual(SDL_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181 SDL_Screen))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 ? BlackPixel(SDL_Display, SDL_Screen) : 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 attributes.background_pixel = black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 attributes.border_pixel = black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 attributes.colormap = SDL_XColorMap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 mask = CWBackPixel | CWBorderPixel | CWColormap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
188 SDL_Window = XCreateWindow(SDL_Display, WMwindow,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189 0, 0, w, h, 0, glx_visualinfo->depth,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
190 InputOutput, glx_visualinfo->visual,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 mask, &attributes);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 if ( !SDL_Window ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 SDL_SetError("Could not create window");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 int X11_GL_CreateContext(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
205 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
206 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
207 #if SDL_VIDEO_OPENGL_GLX
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
208 const char *glXext;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
209
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
210 /* 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
211 XSync( SDL_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
212 glx_context = this->gl_data->glXCreateContext(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
213 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
214 XSync( GFX_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
216 if ( glx_context == NULL ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 SDL_SetError("Could not create GL context");
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
218 return(-1);
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
219 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
220 if ( X11_GL_MakeCurrent(this) < 0 ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
221 return(-1);
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
222 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
223 gl_active = 1;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
224
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
225 /* The use of strstr here should be safe */
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
226 glXext = this->gl_data->glXQueryExtensionsString(GFX_Display, DefaultScreen(GFX_Display));
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
227 if ( !SDL_strstr(glXext, "SGI_swap_control") ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
228 this->gl_data->glXSwapIntervalSGI = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229 }
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
230 if ( !SDL_strstr(glXext, "GLX_MESA_swap_control") ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
231 this->gl_data->glXSwapIntervalMESA = NULL;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
232 this->gl_data->glXGetSwapIntervalMESA = NULL;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
233 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
234 if ( this->gl_config.swap_control >= 0 ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
235 if ( this->gl_data->glXSwapIntervalMESA ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
236 this->gl_data->glXSwapIntervalMESA(this->gl_config.swap_control);
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
237 } else if ( this->gl_data->glXSwapIntervalSGI ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
238 this->gl_data->glXSwapIntervalSGI(this->gl_config.swap_control);
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
239 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
240 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 if ( gl_active ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
246 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
249 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 void X11_GL_Shutdown(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
254 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
255 /* Clean up OpenGL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 if( glx_context ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 this->gl_data->glXMakeCurrent(GFX_Display, None, NULL);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 if (glx_context != NULL)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 this->gl_data->glXDestroyContext(GFX_Display, glx_context);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
262 glx_context = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 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
265 #endif /* SDL_VIDEO_OPENGL_GLX */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
268 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270 /* Make the current context active */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271 int X11_GL_MakeCurrent(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 int retval;
638
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
274
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277 SDL_Window, glx_context) ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 SDL_SetError("Unable to make GL context current");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 }
1575
3ba88cb7eb1b Updated dynamic X11 code. See details in Bugzilla #170.
Ryan C. Gordon <icculus@icculus.org>
parents: 1402
diff changeset
281 XSync( GFX_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 /* More Voodoo X server workarounds... Grr... */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 SDL_Lock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
285 X11_CheckDGAMouse(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 SDL_Unlock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 /* Get attribute data from glX. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 int retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 int glx_attrib = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 switch( attrib ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 case SDL_GL_RED_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 glx_attrib = GLX_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 case SDL_GL_GREEN_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 glx_attrib = GLX_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 case SDL_GL_BLUE_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 glx_attrib = GLX_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 case SDL_GL_ALPHA_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308 glx_attrib = GLX_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 case SDL_GL_DOUBLEBUFFER:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 glx_attrib = GLX_DOUBLEBUFFER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 case SDL_GL_BUFFER_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 glx_attrib = GLX_BUFFER_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
315 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
316 case SDL_GL_DEPTH_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
317 glx_attrib = GLX_DEPTH_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
318 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
319 case SDL_GL_STENCIL_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
320 glx_attrib = GLX_STENCIL_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
321 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
322 case SDL_GL_ACCUM_RED_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
323 glx_attrib = GLX_ACCUM_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 case SDL_GL_ACCUM_GREEN_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 glx_attrib = GLX_ACCUM_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 case SDL_GL_ACCUM_BLUE_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329 glx_attrib = GLX_ACCUM_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331 case SDL_GL_ACCUM_ALPHA_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332 glx_attrib = GLX_ACCUM_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333 break;
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
334 case SDL_GL_STEREO:
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
335 glx_attrib = GLX_STEREO;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
336 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
337 case SDL_GL_MULTISAMPLEBUFFERS:
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
338 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
339 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
340 case SDL_GL_MULTISAMPLESAMPLES:
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
341 glx_attrib = GLX_SAMPLES_ARB;
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
342 break;
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
343 case SDL_GL_SWAP_CONTROL:
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
344 if ( this->gl_data->glXGetSwapIntervalMESA ) {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
345 return this->gl_data->glXGetSwapIntervalMESA();
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
346 } else {
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
347 return -1 /*(this->gl_config.swap_control > 0)*/;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
348 }
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
349 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
350 default:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
351 return(-1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
354 retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
356 return retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
359 void X11_GL_SwapBuffers(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
364 #endif /* SDL_VIDEO_OPENGL_GLX */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
365
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
366 void X11_GL_UnloadLibrary(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
367 {
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
368 #if SDL_VIDEO_OPENGL_GLX
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
369 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
370
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
371 SDL_UnloadObject(this->gl_config.dll_handle);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
372
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
373 this->gl_data->glXGetProcAddress = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
374 this->gl_data->glXChooseVisual = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
375 this->gl_data->glXCreateContext = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
376 this->gl_data->glXDestroyContext = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
377 this->gl_data->glXMakeCurrent = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
378 this->gl_data->glXSwapBuffers = NULL;
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
379 this->gl_data->glXSwapIntervalSGI = NULL;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
380 this->gl_data->glXSwapIntervalMESA = NULL;
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
381 this->gl_data->glXGetSwapIntervalMESA = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
382
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
383 this->gl_config.dll_handle = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
384 this->gl_config.driver_loaded = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
385 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
386 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
387 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
388
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
389 #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
390
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
391 /* Passing a NULL path means load pointers from the application */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
392 int X11_GL_LoadLibrary(_THIS, const char* path)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
393 {
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
394 void* handle = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
395
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
396 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
397 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
398 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
399 }
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
400
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
401 if ( path == NULL ) {
1336
3692456e7b0f Use SDL_ prefixed versions of C library functions.
Sam Lantinga <slouken@libsdl.org>
parents: 1315
diff changeset
402 path = SDL_getenv("SDL_VIDEO_GL_DRIVER");
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
403 if ( path == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
404 path = DEFAULT_OPENGL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
405 }
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
406 }
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
407
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
408 handle = SDL_LoadObject(path);
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
409 if ( handle == NULL ) {
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
410 /* SDL_LoadObject() will call SDL_SetError() for us. */
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
411 return -1;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
412 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
413
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
414 /* Unload the old driver and reset the pointers */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
415 X11_GL_UnloadLibrary(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
416
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
417 /* Load new function pointers */
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
418 this->gl_data->glXGetProcAddress =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
419 (void *(*)(const GLubyte *)) SDL_LoadFunction(handle, "glXGetProcAddressARB");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
420 this->gl_data->glXChooseVisual =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
421 (XVisualInfo *(*)(Display *, int, int *)) SDL_LoadFunction(handle, "glXChooseVisual");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
422 this->gl_data->glXCreateContext =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
423 (GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) SDL_LoadFunction(handle, "glXCreateContext");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
424 this->gl_data->glXDestroyContext =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
425 (void (*)(Display *, GLXContext)) SDL_LoadFunction(handle, "glXDestroyContext");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
426 this->gl_data->glXMakeCurrent =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
427 (int (*)(Display *, GLXDrawable, GLXContext)) SDL_LoadFunction(handle, "glXMakeCurrent");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
428 this->gl_data->glXSwapBuffers =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
429 (void (*)(Display *, GLXDrawable)) SDL_LoadFunction(handle, "glXSwapBuffers");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
430 this->gl_data->glXGetConfig =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
431 (int (*)(Display *, XVisualInfo *, int, int *)) SDL_LoadFunction(handle, "glXGetConfig");
638
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
432 this->gl_data->glXQueryExtensionsString =
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
433 (const char *(*)(Display *, int)) SDL_LoadFunction(handle, "glXQueryExtensionsString");
1736
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
434 this->gl_data->glXSwapIntervalSGI =
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
435 (int (*)(int)) SDL_LoadFunction(handle, "glXSwapIntervalSGI");
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
436 this->gl_data->glXSwapIntervalMESA =
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
437 (GLint (*)(unsigned)) SDL_LoadFunction(handle, "glXSwapIntervalMESA");
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
438 this->gl_data->glXGetSwapIntervalMESA =
3b2a92126f4d Implemented bug #2, 117:
Sam Lantinga <slouken@libsdl.org>
parents: 1577
diff changeset
439 (GLint (*)(void)) SDL_LoadFunction(handle, "glXGetSwapIntervalMESA");
1315
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
440
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
441 if ( (this->gl_data->glXChooseVisual == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
442 (this->gl_data->glXCreateContext == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
443 (this->gl_data->glXDestroyContext == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
444 (this->gl_data->glXMakeCurrent == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
445 (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
446 (this->gl_data->glXGetConfig == NULL) ||
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
447 (this->gl_data->glXQueryExtensionsString == NULL)) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
448 SDL_SetError("Could not retrieve OpenGL functions");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
449 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
450 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
451
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
452 this->gl_config.dll_handle = handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
453 this->gl_config.driver_loaded = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
454 if ( path ) {
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
455 SDL_strlcpy(this->gl_config.driver_path, path,
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
456 SDL_arraysize(this->gl_config.driver_path));
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
457 } else {
1379
c0a74f199ecf Use only safe string functions
Sam Lantinga <slouken@libsdl.org>
parents: 1361
diff changeset
458 *this->gl_config.driver_path = '\0';
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
459 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
460 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
461 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
463 void *X11_GL_GetProcAddress(_THIS, const char* proc)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
464 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
465 void* handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
466
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
467 handle = this->gl_config.dll_handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
468 if ( this->gl_data->glXGetProcAddress ) {
1196
b81f54c3963f Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents: 1191
diff changeset
469 return this->gl_data->glXGetProcAddress((const GLubyte *)proc);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
470 }
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
471 return SDL_LoadFunction(handle, proc);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
472 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
473
1361
19418e4422cb New configure-based build system. Still work in progress, but much improved
Sam Lantinga <slouken@libsdl.org>
parents: 1358
diff changeset
474 #endif /* SDL_VIDEO_OPENGL_GLX */