annotate src/video/x11/SDL_x11gl.c @ 1325:1dfc85090d07

Resolve bug #120 Use the real executable's name for the window class, if it's available.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 03 Feb 2006 07:39:02 +0000
parents e94b0d7c33bc
children 3692456e7b0f
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 */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
22
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
23 #include <stdlib.h> /* For getenv() prototype */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
24 #include <string.h>
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
25
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
26 #include "SDL_events_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
27 #include "SDL_error.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
28 #include "SDL_x11video.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
29 #include "SDL_x11dga_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
30 #include "SDL_x11gl_c.h"
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
31
862
f7a8b0ca2ae3 IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
32 #if defined(sgi)
f7a8b0ca2ae3 IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
33 /* 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
34 #define DEFAULT_OPENGL "libGL.so"
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
35 #elif defined(MACOSX)
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
36 #define DEFAULT_OPENGL "/usr/X11R6/lib/libGL.1.dylib"
862
f7a8b0ca2ae3 IRIX doesn't have a GL library versioning system
Sam Lantinga <slouken@libsdl.org>
parents: 769
diff changeset
37 #else
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
38 #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
39 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
40
667
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
41 #ifndef GLX_ARB_multisample
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
42 #define GLX_ARB_multisample
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
43 #define GLX_SAMPLE_BUFFERS_ARB 100000
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
44 #define GLX_SAMPLES_ARB 100001
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
45 #endif
adbed8d7a991 *** empty log message ***
Sam Lantinga <slouken@libsdl.org>
parents: 656
diff changeset
46
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
47 XVisualInfo *X11_GL_GetVisual(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
48 {
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
49 #ifdef HAVE_OPENGL_X11
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
50 /* 64 seems nice. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
51 int attribs[64];
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
52 int i;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
53
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
54 /* load the gl driver from a default path */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
55 if ( ! this->gl_config.driver_loaded ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
56 /* no driver has been loaded, use default (ourselves) */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
57 if ( X11_GL_LoadLibrary(this, NULL) < 0 ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
58 return NULL;
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
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
62 /* See if we already have a window which we must use */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
63 if ( SDL_windowid ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
64 XWindowAttributes a;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
65 XVisualInfo vi_in;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
66 int out_count;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
67
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1060
diff changeset
68 pXGetWindowAttributes(SDL_Display, SDL_Window, &a);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
69 vi_in.screen = SDL_Screen;
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1060
diff changeset
70 vi_in.visualid = pXVisualIDFromVisual(a.visual);
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1060
diff changeset
71 glx_visualinfo = pXGetVisualInfo(SDL_Display,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
72 VisualScreenMask|VisualIDMask, &vi_in, &out_count);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
73 return glx_visualinfo;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
74 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
75
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
76 /* 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
77 i = 0;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
78 attribs[i++] = GLX_RGBA;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
79 attribs[i++] = GLX_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
80 attribs[i++] = this->gl_config.red_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
81 attribs[i++] = GLX_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
82 attribs[i++] = this->gl_config.green_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
83 attribs[i++] = GLX_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
84 attribs[i++] = this->gl_config.blue_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
85
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
86 if( this->gl_config.alpha_size ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
87 attribs[i++] = GLX_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
88 attribs[i++] = this->gl_config.alpha_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
89 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
90
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
91 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
92 attribs[i++] = GLX_BUFFER_SIZE;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
93 attribs[i++] = this->gl_config.buffer_size;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
94 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
95
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
96 if( this->gl_config.double_buffer ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
97 attribs[i++] = GLX_DOUBLEBUFFER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
98 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
99
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
100 attribs[i++] = GLX_DEPTH_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
101 attribs[i++] = this->gl_config.depth_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
102
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
103 if( this->gl_config.stencil_size ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
104 attribs[i++] = GLX_STENCIL_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
105 attribs[i++] = this->gl_config.stencil_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
106 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
107
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
108 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
109 attribs[i++] = GLX_ACCUM_RED_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
110 attribs[i++] = this->gl_config.accum_red_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
111 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
112
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
113 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
114 attribs[i++] = GLX_ACCUM_GREEN_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
115 attribs[i++] = this->gl_config.accum_green_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
116 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
117
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
118 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
119 attribs[i++] = GLX_ACCUM_BLUE_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
120 attribs[i++] = this->gl_config.accum_blue_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
121 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
122
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
123 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
124 attribs[i++] = GLX_ACCUM_ALPHA_SIZE;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
125 attribs[i++] = this->gl_config.accum_alpha_size;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
126 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
127
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
128 if( this->gl_config.stereo ) {
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
129 attribs[i++] = GLX_STEREO;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
130 attribs[i++] = this->gl_config.stereo;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
131 }
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
132
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 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
134 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
135 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
136 }
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
137
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 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
139 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
140 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
141 }
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
142
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
143 #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */
1060
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
144 if ( !getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) {
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
145 attribs[i++] = GLX_X_VISUAL_TYPE;
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
146 attribs[i++] = GLX_DIRECT_COLOR;
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
147 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
148 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
149 attribs[i++] = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
150
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
151 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
152 SDL_Screen, attribs);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
153 #ifdef GLX_DIRECT_COLOR
1060
86885b40a53b Support SDL_VIDEO_X11_NODIRECTCOLOR for OpenGL visuals
Sam Lantinga <slouken@libsdl.org>
parents: 862
diff changeset
154 if( !glx_visualinfo && !getenv("SDL_VIDEO_X11_NODIRECTCOLOR") ) { /* No DirectColor visual? Try again.. */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
155 attribs[i-3] = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
156 glx_visualinfo = this->gl_data->glXChooseVisual(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
157 SDL_Screen, attribs);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
158 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
159 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
160 if( !glx_visualinfo ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
161 SDL_SetError( "Couldn't find matching GLX visual");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
162 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
163 }
1315
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
164 /*
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
165 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
166 */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
167 return glx_visualinfo;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
168 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
169 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
170 return NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
171 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
172 }
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 X11_GL_CreateWindow(_THIS, int w, int h)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
175 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
176 int retval;
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
177 #ifdef HAVE_OPENGL_X11
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
178 XSetWindowAttributes attributes;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
179 unsigned long mask;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
180 unsigned long black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
181
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
182 black = (glx_visualinfo->visual == DefaultVisual(SDL_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
183 SDL_Screen))
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
184 ? BlackPixel(SDL_Display, SDL_Screen) : 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
185 attributes.background_pixel = black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
186 attributes.border_pixel = black;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
187 attributes.colormap = SDL_XColorMap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
188 mask = CWBackPixel | CWBorderPixel | CWColormap;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
189
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1060
diff changeset
190 SDL_Window = pXCreateWindow(SDL_Display, WMwindow,
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
191 0, 0, w, h, 0, glx_visualinfo->depth,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
192 InputOutput, glx_visualinfo->visual,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
193 mask, &attributes);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
194 if ( !SDL_Window ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
195 SDL_SetError("Could not create window");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
196 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
197 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
198 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
199 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
200 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
201 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
202 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
203 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
204 }
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 X11_GL_CreateContext(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
207 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
208 int retval;
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
209 #ifdef HAVE_OPENGL_X11
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. */
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1060
diff changeset
211 pXSync( 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);
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1060
diff changeset
214 pXSync( GFX_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
215
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
216 if (glx_context == NULL) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
217 SDL_SetError("Could not create GL context");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
218 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
219 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
220
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
221 gl_active = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
222 #else
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
223 SDL_SetError("X11 driver not configured with OpenGL");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
224 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
225 if ( gl_active ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
226 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
227 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
228 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
229 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
230 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
231 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
232
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
233 void X11_GL_Shutdown(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
234 {
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
235 #ifdef HAVE_OPENGL_X11
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
236 /* Clean up OpenGL */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
237 if( glx_context ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
238 this->gl_data->glXMakeCurrent(GFX_Display, None, NULL);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
239
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
240 if (glx_context != NULL)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
241 this->gl_data->glXDestroyContext(GFX_Display, glx_context);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
242
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
243 glx_context = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
244 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
245 gl_active = 0;
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
246 #endif /* HAVE_OPENGL_X11 */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
247 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
248
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
249 #ifdef HAVE_OPENGL_X11
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
250
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
251 /* Make the current context active */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
252 int X11_GL_MakeCurrent(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
253 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
254 int retval;
638
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
255
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
256 retval = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
257 if ( ! this->gl_data->glXMakeCurrent(GFX_Display,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
258 SDL_Window, glx_context) ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
259 SDL_SetError("Unable to make GL context current");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
260 retval = -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
261 }
1168
045f186426e1 Dynamically load X11 libraries like we currently do for alsa, esd, etc.
Ryan C. Gordon <icculus@icculus.org>
parents: 1060
diff changeset
262 pXSync( GFX_Display, False );
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
263
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
264 /* More Voodoo X server workarounds... Grr... */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
265 SDL_Lock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
266 X11_CheckDGAMouse(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
267 SDL_Unlock_EventThread();
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
268
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
269 return(retval);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
270 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
271
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
272 /* Get attribute data from glX. */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
273 int X11_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
274 {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
275 int retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
276 int glx_attrib = None;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
277
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
278 switch( attrib ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
279 case SDL_GL_RED_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
280 glx_attrib = GLX_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
281 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
282 case SDL_GL_GREEN_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
283 glx_attrib = GLX_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
284 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
285 case SDL_GL_BLUE_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
286 glx_attrib = GLX_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
287 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
288 case SDL_GL_ALPHA_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
289 glx_attrib = GLX_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
290 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
291 case SDL_GL_DOUBLEBUFFER:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
292 glx_attrib = GLX_DOUBLEBUFFER;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
293 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
294 case SDL_GL_BUFFER_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
295 glx_attrib = GLX_BUFFER_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
296 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
297 case SDL_GL_DEPTH_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
298 glx_attrib = GLX_DEPTH_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
299 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
300 case SDL_GL_STENCIL_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
301 glx_attrib = GLX_STENCIL_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
302 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
303 case SDL_GL_ACCUM_RED_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
304 glx_attrib = GLX_ACCUM_RED_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
305 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
306 case SDL_GL_ACCUM_GREEN_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
307 glx_attrib = GLX_ACCUM_GREEN_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
308 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
309 case SDL_GL_ACCUM_BLUE_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
310 glx_attrib = GLX_ACCUM_BLUE_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
311 break;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
312 case SDL_GL_ACCUM_ALPHA_SIZE:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
313 glx_attrib = GLX_ACCUM_ALPHA_SIZE;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
314 break;
450
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
315 case SDL_GL_STEREO:
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
316 glx_attrib = GLX_STEREO;
8a43e0cbf02f Added SDL_GL_STEREO for stereoscopic OpenGL contexts
Sam Lantinga <slouken@libsdl.org>
parents: 297
diff changeset
317 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
318 case SDL_GL_MULTISAMPLEBUFFERS:
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
319 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
320 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
321 case SDL_GL_MULTISAMPLESAMPLES:
655
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
322 glx_attrib = GLX_SAMPLES_ARB;
9c42ee1b7d77 Date: Thu, 24 Apr 2003 15:13:47 -0400
Sam Lantinga <slouken@libsdl.org>
parents: 646
diff changeset
323 break;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
324 default:
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
325 return(-1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
326 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
327
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
328 retval = this->gl_data->glXGetConfig(GFX_Display, glx_visualinfo, glx_attrib, value);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
329
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
330 return retval;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
331 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
332
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
333 void X11_GL_SwapBuffers(_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 this->gl_data->glXSwapBuffers(GFX_Display, SDL_Window);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
336 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
337
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
338 #endif /* HAVE_OPENGL_X11 */
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
339
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
340 void X11_GL_UnloadLibrary(_THIS)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
341 {
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
342 #ifdef HAVE_OPENGL_X11
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
343 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
344
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
345 /* !!! FIXME: Can we just use SDL_UnloadObject() everywhere? */
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
346 #ifdef USE_DLOPEN
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
347 dlclose(this->gl_config.dll_handle);
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
348 #else
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
349 SDL_UnloadObject(this->gl_config.dll_handle);
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
350 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
351
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
352 this->gl_data->glXGetProcAddress = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
353 this->gl_data->glXChooseVisual = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
354 this->gl_data->glXCreateContext = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
355 this->gl_data->glXDestroyContext = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
356 this->gl_data->glXMakeCurrent = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
357 this->gl_data->glXSwapBuffers = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
358
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
359 this->gl_config.dll_handle = NULL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
360 this->gl_config.driver_loaded = 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
361 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
362 #endif
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
363 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
364
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
365 #ifdef HAVE_OPENGL_X11
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
366
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
367 static void *do_dlsym(void *handle, const char *name)
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
368 {
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
369 /* !!! FIXME: Can we just use SDL_LoadFunction() everywhere? */
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 #ifdef USE_DLOPEN
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 return dlsym(handle, name);
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
372 #else
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
373 return SDL_LoadFunction(handle, name);
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
374 #endif
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
375 }
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
376
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
377 #if defined(__OpenBSD__) && !defined(__ELF__)
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
378 #define do_dlsym(x,y) do_dlsym(x, "_" y)
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
379 #endif
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
380
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
381 /* Passing a NULL path means load pointers from the application */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
382 int X11_GL_LoadLibrary(_THIS, const char* path)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
383 {
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
384 void* handle = NULL;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
385
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
386 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
387 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
388 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
389 }
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
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
391 if ( path == NULL ) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
392 path = getenv("SDL_VIDEO_GL_DRIVER");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
393 if ( path == NULL ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
394 path = DEFAULT_OPENGL;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
395 }
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
396 }
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
397
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
398 /* !!! FIXME: Can we just use SDL_LoadObject() everywhere? */
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
399 #ifdef USE_DLOPEN
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
400 {
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
401 #ifdef RTLD_GLOBAL
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
402 int dlopen_flags = RTLD_LAZY | RTLD_GLOBAL;
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
403 #else
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
404 int dlopen_flags = RTLD_LAZY;
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
405 #endif
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
406 handle = dlopen(path, dlopen_flags);
1246
ca51a76a7328 Make error message meaningful if dlopen() fails on libX11.
Ryan C. Gordon <icculus@icculus.org>
parents: 1196
diff changeset
407 if ( handle == NULL ) {
ca51a76a7328 Make error message meaningful if dlopen() fails on libX11.
Ryan C. Gordon <icculus@icculus.org>
parents: 1196
diff changeset
408 SDL_SetError("Could not load OpenGL library: %s", (const char *) dlerror());
ca51a76a7328 Make error message meaningful if dlopen() fails on libX11.
Ryan C. Gordon <icculus@icculus.org>
parents: 1196
diff changeset
409 return -1;
ca51a76a7328 Make error message meaningful if dlopen() fails on libX11.
Ryan C. Gordon <icculus@icculus.org>
parents: 1196
diff changeset
410 }
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
411 }
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
412 #else
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
413 handle = SDL_LoadObject(path);
1246
ca51a76a7328 Make error message meaningful if dlopen() fails on libX11.
Ryan C. Gordon <icculus@icculus.org>
parents: 1196
diff changeset
414 if ( handle == NULL ) {
1247
ff73ee89ff4b Don't trample SDL_LoadObject()'s error message in GL loader.
Ryan C. Gordon <icculus@icculus.org>
parents: 1246
diff changeset
415 /* SDL_LoadObject() will call SDL_SetError() for us. */
1246
ca51a76a7328 Make error message meaningful if dlopen() fails on libX11.
Ryan C. Gordon <icculus@icculus.org>
parents: 1196
diff changeset
416 return -1;
ca51a76a7328 Make error message meaningful if dlopen() fails on libX11.
Ryan C. Gordon <icculus@icculus.org>
parents: 1196
diff changeset
417 }
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
418 #endif
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
419
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
420
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
421 /* Unload the old driver and reset the pointers */
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
422 X11_GL_UnloadLibrary(this);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
423
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
424 /* Load new function pointers */
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
425 this->gl_data->glXGetProcAddress =
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
426 (void *(*)(const GLubyte *)) do_dlsym(handle, "glXGetProcAddressARB");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
427 this->gl_data->glXChooseVisual =
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
428 (XVisualInfo *(*)(Display *, int, int *)) do_dlsym(handle, "glXChooseVisual");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
429 this->gl_data->glXCreateContext =
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
430 (GLXContext (*)(Display *, XVisualInfo *, GLXContext, int)) do_dlsym(handle, "glXCreateContext");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
431 this->gl_data->glXDestroyContext =
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
432 (void (*)(Display *, GLXContext)) do_dlsym(handle, "glXDestroyContext");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
433 this->gl_data->glXMakeCurrent =
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
434 (int (*)(Display *, GLXDrawable, GLXContext)) do_dlsym(handle, "glXMakeCurrent");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
435 this->gl_data->glXSwapBuffers =
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
436 (void (*)(Display *, GLXDrawable)) do_dlsym(handle, "glXSwapBuffers");
180
578815880307 Do proper typecasting so this compiles on IRIX
Sam Lantinga <slouken@libsdl.org>
parents: 127
diff changeset
437 this->gl_data->glXGetConfig =
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
438 (int (*)(Display *, XVisualInfo *, int, int *)) do_dlsym(handle, "glXGetConfig");
638
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
439 this->gl_data->glXQueryExtensionsString =
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
440 (const char *(*)(Display *, int)) do_dlsym(handle, "glXQueryExtensionsString");
638
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
441
1315
e94b0d7c33bc Merged useful fixes from 1.3 branch
Sam Lantinga <slouken@libsdl.org>
parents: 1312
diff changeset
442
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
443 if ( (this->gl_data->glXChooseVisual == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
444 (this->gl_data->glXCreateContext == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
445 (this->gl_data->glXDestroyContext == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
446 (this->gl_data->glXMakeCurrent == NULL) ||
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
447 (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
448 (this->gl_data->glXGetConfig == NULL) ||
b0108e9dea53 Date: Sun, 11 May 2003 19:59:06 +0300
Sam Lantinga <slouken@libsdl.org>
parents: 566
diff changeset
449 (this->gl_data->glXQueryExtensionsString == NULL)) {
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
450 SDL_SetError("Could not retrieve OpenGL functions");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
451 return -1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
452 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
453
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
454 this->gl_config.dll_handle = handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
455 this->gl_config.driver_loaded = 1;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
456 if ( path ) {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
457 strncpy(this->gl_config.driver_path, path,
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
458 sizeof(this->gl_config.driver_path)-1);
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
459 } else {
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
460 strcpy(this->gl_config.driver_path, "");
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
461 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
462 return 0;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
463 }
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 *X11_GL_GetProcAddress(_THIS, const char* proc)
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
466 {
110
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
467 static char procname[1024];
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
468 void* handle;
110
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
469 void* retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
470
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
471 handle = this->gl_config.dll_handle;
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
472 if ( this->gl_data->glXGetProcAddress ) {
1196
b81f54c3963f Fixed compile warnings with gcc 4
Sam Lantinga <slouken@libsdl.org>
parents: 1191
diff changeset
473 return this->gl_data->glXGetProcAddress((const GLubyte *)proc);
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
474 }
110
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
475 #if defined(__OpenBSD__) && !defined(__ELF__)
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
476 #undef do_dlsym
110
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
477 #endif
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
478 retval = do_dlsym(handle, proc);
110
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
479 if (!retval && strlen(proc) <= 1022) {
127
0bcae11eba14 Oops, that wasn't right...
Sam Lantinga <slouken@libsdl.org>
parents: 110
diff changeset
480 procname[0] = '_';
110
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
481 strcpy(procname + 1, proc);
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
482 retval = do_dlsym(handle, procname);
110
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
483 }
7edee9f0f2cc SDL GL dynamic loading fix for OpenBSD
Sam Lantinga <slouken@lokigames.com>
parents: 29
diff changeset
484 return retval;
0
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
485 }
74212992fb08 Initial revision
Sam Lantinga <slouken@lokigames.com>
parents:
diff changeset
486
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
487 #endif /* HAVE_OPENGL_X11 */