Mercurial > sdl-ios-xcode
annotate src/video/x11/SDL_x11opengl.c @ 3063:9f2482d6662c
Fixed off by one error in line drawing code
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Thu, 12 Feb 2009 06:01:54 +0000 |
parents | 089a77aebb7d |
children | 7dc982143c06 |
rev | line source |
---|---|
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 /* |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 SDL - Simple DirectMedia Layer |
2859 | 3 Copyright (C) 1997-2009 Sam Lantinga |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 This library is free software; you can redistribute it and/or |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 modify it under the terms of the GNU Lesser General Public |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 License as published by the Free Software Foundation; either |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 version 2.1 of the License, or (at your option) any later version. |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 This library is distributed in the hope that it will be useful, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 Lesser General Public License for more details. |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
15 You should have received a copy of the GNU Lesser General Public |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
16 License along with _this library; if not, write to the Free Software |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
17 Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
18 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
19 Sam Lantinga |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
20 slouken@libsdl.org |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
21 */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
22 #include "SDL_config.h" |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
23 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
24 #include "SDL_x11video.h" |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
25 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
26 /* GLX implementation of SDL OpenGL support */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
27 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
28 #if SDL_VIDEO_OPENGL_GLX |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
29 #include "SDL_loadso.h" |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 #if defined(__IRIX__) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 /* IRIX doesn't have a GL library versioning system */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 #define DEFAULT_OPENGL "libGL.so" |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
34 #elif defined(__MACOSX__) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
35 #define DEFAULT_OPENGL "/usr/X11R6/lib/libGL.1.dylib" |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
36 #elif defined(__QNXNTO__) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
37 #define DEFAULT_OPENGL "libGL.so.3" |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
38 #else |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
39 #define DEFAULT_OPENGL "libGL.so.1" |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
40 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
41 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
42 #ifndef GLX_ARB_multisample |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
43 #define GLX_ARB_multisample |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
44 #define GLX_SAMPLE_BUFFERS_ARB 100000 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
45 #define GLX_SAMPLES_ARB 100001 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
46 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
47 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
48 #ifndef GLX_EXT_visual_rating |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
49 #define GLX_EXT_visual_rating |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
50 #define GLX_VISUAL_CAVEAT_EXT 0x20 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
51 #define GLX_NONE_EXT 0x8000 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
52 #define GLX_SLOW_VISUAL_EXT 0x8001 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
53 #define GLX_NON_CONFORMANT_VISUAL_EXT 0x800D |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
54 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
55 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
56 #define OPENGL_REQUIRS_DLOPEN |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
57 #if defined(OPENGL_REQUIRS_DLOPEN) && defined(SDL_LOADSO_DLOPEN) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
58 #include <dlfcn.h> |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
59 #define GL_LoadObject(X) dlopen(X, (RTLD_NOW|RTLD_GLOBAL)) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
60 #define GL_LoadFunction dlsym |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
61 #define GL_UnloadObject dlclose |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
62 #else |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
63 #define GL_LoadObject SDL_LoadObject |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
64 #define GL_LoadFunction SDL_LoadFunction |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
65 #define GL_UnloadObject SDL_UnloadObject |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
68 static void X11_GL_InitExtensions(_THIS); |
2322 | 69 |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 int |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
71 X11_GL_LoadLibrary(_THIS, const char *path) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 void *handle; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
75 /* Load the OpenGL library */ |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
76 if (path == NULL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
77 path = SDL_getenv("SDL_OPENGL_LIBRARY"); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
78 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
79 if (path == NULL) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
80 path = DEFAULT_OPENGL; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
81 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
82 _this->gl_config.dll_handle = SDL_LoadObject(path); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
83 if (!_this->gl_config.dll_handle) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
84 return -1; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
85 } |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
86 SDL_strlcpy(_this->gl_config.driver_path, path, |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
87 SDL_arraysize(_this->gl_config.driver_path)); |
2244 | 88 |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
89 /* Allocate OpenGL memory */ |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
90 _this->gl_data = |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
91 (struct SDL_GLDriverData *) SDL_calloc(1, |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
92 sizeof(struct |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
93 SDL_GLDriverData)); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
94 if (!_this->gl_data) { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
95 SDL_OutOfMemory(); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
96 return -1; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
97 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
98 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
99 /* Load function pointers */ |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
100 handle = _this->gl_config.dll_handle; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
101 _this->gl_data->glXGetProcAddress = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
102 (void *(*)(const GLubyte *)) GL_LoadFunction(handle, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
103 "glXGetProcAddressARB"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
104 _this->gl_data->glXChooseVisual = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
105 (XVisualInfo * (*)(Display *, int, int *)) GL_LoadFunction(handle, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
106 "glXChooseVisual"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
107 _this->gl_data->glXCreateContext = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
108 (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int)) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
109 GL_LoadFunction(handle, "glXCreateContext"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
110 _this->gl_data->glXDestroyContext = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
111 (void (*)(Display *, GLXContext)) GL_LoadFunction(handle, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
112 "glXDestroyContext"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
113 _this->gl_data->glXMakeCurrent = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
114 (int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
115 "glXMakeCurrent"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
116 _this->gl_data->glXSwapBuffers = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
117 (void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
118 "glXSwapBuffers"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
119 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
120 if (!_this->gl_data->glXChooseVisual || |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
121 !_this->gl_data->glXCreateContext || |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
122 !_this->gl_data->glXDestroyContext || |
1956
ba0d62354872
Simplified driver window creation code.
Sam Lantinga <slouken@libsdl.org>
parents:
1955
diff
changeset
|
123 !_this->gl_data->glXMakeCurrent || !_this->gl_data->glXSwapBuffers) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
124 SDL_SetError("Could not retrieve OpenGL functions"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
125 return -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
126 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
127 |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
128 /* Initialize extensions */ |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
129 X11_GL_InitExtensions(_this); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
130 |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
131 return 0; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
132 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
133 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
134 void * |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
135 X11_GL_GetProcAddress(_THIS, const char *proc) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
136 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
137 void *handle; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
138 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
139 handle = _this->gl_config.dll_handle; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
140 if (_this->gl_data->glXGetProcAddress) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
141 return _this->gl_data->glXGetProcAddress((const GLubyte *) proc); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
142 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
143 return GL_LoadFunction(handle, proc); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
144 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
145 |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
146 void |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
147 X11_GL_UnloadLibrary(_THIS) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
148 { |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
149 /* Don't actually unload the library, since it may have registered |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
150 * X11 shutdown hooks, per the notes at: |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
151 * http://dri.sourceforge.net/doc/DRIuserguide.html |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
152 */ |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
153 #if 0 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
154 GL_UnloadObject(_this->gl_config.dll_handle); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
155 _this->gl_config.dll_handle = NULL; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
156 #endif |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
157 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
158 /* Free OpenGL memory */ |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
159 SDL_free(_this->gl_data); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
3013
diff
changeset
|
160 _this->gl_data = NULL; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
161 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
162 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
163 static SDL_bool |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
164 HasExtension(const char *extension, const char *extensions) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
165 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
166 const char *start; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
167 const char *where, *terminator; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
168 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
169 /* Extension names should not have spaces. */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
170 where = SDL_strchr(extension, ' '); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
171 if (where || *extension == '\0') |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
172 return SDL_FALSE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
173 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
174 if (!extensions) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
175 return SDL_FALSE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
176 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
177 /* It takes a bit of care to be fool-proof about parsing the |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
178 * OpenGL extensions string. Don't be fooled by sub-strings, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
179 * etc. */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
180 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
181 start = extensions; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
182 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
183 for (;;) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
184 where = SDL_strstr(start, extension); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
185 if (!where) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
186 break; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
187 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
188 terminator = where + SDL_strlen(extension); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
189 if (where == start || *(where - 1) == ' ') |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
190 if (*terminator == ' ' || *terminator == '\0') |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
191 return SDL_TRUE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
192 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
193 start = terminator; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
194 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
195 return SDL_FALSE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
196 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
197 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
198 static void |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
199 X11_GL_InitExtensions(_THIS) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
200 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
201 Display *display = ((SDL_VideoData *) _this->driverdata)->display; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
202 int screen = ((SDL_DisplayData *) SDL_CurrentDisplay.driverdata)->screen; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
203 XVisualInfo *vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
204 XSetWindowAttributes xattr; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
205 Window w; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
206 GLXContext context; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
207 const char *(*glXQueryExtensionsStringFunc) (Display *, int); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
208 const char *extensions; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
209 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
210 vinfo = X11_GL_GetVisual(_this, display, screen); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
211 if (!vinfo) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
212 return; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
213 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
214 xattr.background_pixel = 0; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
215 xattr.border_pixel = 0; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
216 xattr.colormap = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
217 XCreateColormap(display, RootWindow(display, screen), vinfo->visual, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
218 AllocNone); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
219 w = XCreateWindow(display, RootWindow(display, screen), 0, 0, 32, 32, 0, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
220 vinfo->depth, InputOutput, vinfo->visual, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
221 (CWBackPixel | CWBorderPixel | CWColormap), &xattr); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
222 context = _this->gl_data->glXCreateContext(display, vinfo, NULL, True); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
223 if (context) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
224 _this->gl_data->glXMakeCurrent(display, w, context); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
225 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
226 XFree(vinfo); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
227 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
228 glXQueryExtensionsStringFunc = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
229 (const char *(*)(Display *, int)) X11_GL_GetProcAddress(_this, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
230 "glXQueryExtensionsString"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
231 if (glXQueryExtensionsStringFunc) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
232 extensions = glXQueryExtensionsStringFunc(display, screen); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
233 } else { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
234 extensions = NULL; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
235 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
236 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
237 /* Check for SGI_swap_control */ |
2105
12bcd4fd2606
Date: Wed, 23 May 2007 00:39:47 +0300
Ryan C. Gordon <icculus@icculus.org>
parents:
1956
diff
changeset
|
238 if (HasExtension("GLX_SGI_swap_control", extensions)) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
239 _this->gl_data->glXSwapIntervalSGI = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
240 (int (*)(int)) X11_GL_GetProcAddress(_this, "glXSwapIntervalSGI"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
241 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
242 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
243 /* Check for GLX_MESA_swap_control */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
244 if (HasExtension("GLX_MESA_swap_control", extensions)) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
245 _this->gl_data->glXSwapIntervalMESA = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
246 (GLint(*)(unsigned)) X11_GL_GetProcAddress(_this, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
247 "glXSwapIntervalMESA"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
248 _this->gl_data->glXGetSwapIntervalMESA = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
249 (GLint(*)(void)) X11_GL_GetProcAddress(_this, |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
250 "glXGetSwapIntervalMESA"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
251 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
252 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
253 /* Check for GLX_EXT_visual_rating */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
254 if (HasExtension("GLX_EXT_visual_rating", extensions)) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
255 _this->gl_data->HAS_GLX_EXT_visual_rating = SDL_TRUE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
256 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
257 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
258 if (context) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
259 _this->gl_data->glXMakeCurrent(display, None, NULL); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
260 _this->gl_data->glXDestroyContext(display, context); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
261 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
262 XDestroyWindow(display, w); |
2323
4ac07ae446d3
Fixed many valgrind errors. But, I broke testdyngl.
Bob Pendleton <bob@pendleton.com>
parents:
2322
diff
changeset
|
263 X11_PumpEvents(_this); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
264 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
265 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
266 XVisualInfo * |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
267 X11_GL_GetVisual(_THIS, Display * display, int screen) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
268 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
269 XVisualInfo *vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
270 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
271 /* 64 seems nice. */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
272 int attribs[64]; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
273 int i; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
274 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
275 /* Setup our GLX attributes according to the gl_config. */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
276 i = 0; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
277 attribs[i++] = GLX_RGBA; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
278 attribs[i++] = GLX_RED_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
279 attribs[i++] = _this->gl_config.red_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
280 attribs[i++] = GLX_GREEN_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
281 attribs[i++] = _this->gl_config.green_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
282 attribs[i++] = GLX_BLUE_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
283 attribs[i++] = _this->gl_config.blue_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
284 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
285 if (_this->gl_config.alpha_size) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
286 attribs[i++] = GLX_ALPHA_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
287 attribs[i++] = _this->gl_config.alpha_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
288 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
289 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
290 if (_this->gl_config.buffer_size) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
291 attribs[i++] = GLX_BUFFER_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
292 attribs[i++] = _this->gl_config.buffer_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
293 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
294 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
295 if (_this->gl_config.double_buffer) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
296 attribs[i++] = GLX_DOUBLEBUFFER; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
297 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
298 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
299 attribs[i++] = GLX_DEPTH_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
300 attribs[i++] = _this->gl_config.depth_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
301 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
302 if (_this->gl_config.stencil_size) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
303 attribs[i++] = GLX_STENCIL_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
304 attribs[i++] = _this->gl_config.stencil_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
305 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
306 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
307 if (_this->gl_config.accum_red_size) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
308 attribs[i++] = GLX_ACCUM_RED_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
309 attribs[i++] = _this->gl_config.accum_red_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
310 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
311 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
312 if (_this->gl_config.accum_green_size) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
313 attribs[i++] = GLX_ACCUM_GREEN_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
314 attribs[i++] = _this->gl_config.accum_green_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
315 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
316 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
317 if (_this->gl_config.accum_blue_size) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
318 attribs[i++] = GLX_ACCUM_BLUE_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
319 attribs[i++] = _this->gl_config.accum_blue_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
320 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
321 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
322 if (_this->gl_config.accum_alpha_size) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
323 attribs[i++] = GLX_ACCUM_ALPHA_SIZE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
324 attribs[i++] = _this->gl_config.accum_alpha_size; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
325 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
326 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
327 if (_this->gl_config.stereo) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
328 attribs[i++] = GLX_STEREO; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
329 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
330 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
331 if (_this->gl_config.multisamplebuffers) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
332 attribs[i++] = GLX_SAMPLE_BUFFERS_ARB; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
333 attribs[i++] = _this->gl_config.multisamplebuffers; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
334 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
335 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
336 if (_this->gl_config.multisamplesamples) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
337 attribs[i++] = GLX_SAMPLES_ARB; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
338 attribs[i++] = _this->gl_config.multisamplesamples; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
339 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
340 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
341 if (_this->gl_config.accelerated >= 0 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
342 && _this->gl_data->HAS_GLX_EXT_visual_rating) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
343 attribs[i++] = GLX_VISUAL_CAVEAT_EXT; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
344 attribs[i++] = GLX_NONE_EXT; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
345 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
346 #ifdef GLX_DIRECT_COLOR /* Try for a DirectColor visual for gamma support */ |
2963
ee331407574f
Don't use DirectColor visuals until we implement DirectColor colormap support
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
347 if (X11_UseDirectColorVisuals()) { |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
348 attribs[i++] = GLX_X_VISUAL_TYPE; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
349 attribs[i++] = GLX_DIRECT_COLOR; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
350 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
351 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
352 attribs[i++] = None; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
353 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
354 vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
355 #ifdef GLX_DIRECT_COLOR |
2963
ee331407574f
Don't use DirectColor visuals until we implement DirectColor colormap support
Sam Lantinga <slouken@libsdl.org>
parents:
2859
diff
changeset
|
356 if (!vinfo && X11_UseDirectColorVisuals()) { /* No DirectColor visual? Try again.. */ |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
357 attribs[i - 3] = None; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
358 vinfo = _this->gl_data->glXChooseVisual(display, screen, attribs); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
359 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
360 #endif |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
361 if (!vinfo) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
362 SDL_SetError("Couldn't find matching GLX visual"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
363 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
364 return vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
365 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
366 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
367 SDL_GLContext |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
368 X11_GL_CreateContext(_THIS, SDL_Window * window) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
369 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
370 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
371 Display *display = data->videodata->display; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
372 int screen = |
3013
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
373 ((SDL_DisplayData *) SDL_GetDisplayFromWindow(window)-> |
8cc00819c8d6
Reverted Bob's indent checkin
Sam Lantinga <slouken@libsdl.org>
parents:
3011
diff
changeset
|
374 driverdata)->screen; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
375 XWindowAttributes xattr; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
376 XVisualInfo v, *vinfo; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
377 int n; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
378 GLXContext context = NULL; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
379 |
1955 | 380 /* We do this to create a clean separation between X and GLX errors. */ |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
381 XSync(display, False); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
382 XGetWindowAttributes(display, data->window, &xattr); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
383 v.screen = screen; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
384 v.visualid = XVisualIDFromVisual(xattr.visual); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
385 vinfo = XGetVisualInfo(display, VisualScreenMask | VisualIDMask, &v, &n); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
386 if (vinfo) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
387 context = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
388 _this->gl_data->glXCreateContext(display, vinfo, NULL, True); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
389 XFree(vinfo); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
390 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
391 XSync(display, False); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
392 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
393 if (!context) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
394 SDL_SetError("Could not create GL context"); |
2178
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
395 return NULL; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
396 } |
2178
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
397 |
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
398 if (X11_GL_MakeCurrent(_this, window, context) < 0) { |
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
399 X11_GL_DeleteContext(_this, context); |
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
400 return NULL; |
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
401 } |
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
402 |
114a541cfae2
Creating a context makes it current, per the documentation.
Sam Lantinga <slouken@libsdl.org>
parents:
2105
diff
changeset
|
403 return context; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
404 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
405 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
406 int |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
407 X11_GL_MakeCurrent(_THIS, SDL_Window * window, SDL_GLContext context) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
408 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
409 Display *display = ((SDL_VideoData *) _this->driverdata)->display; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
410 Window drawable = |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
411 (window ? ((SDL_WindowData *) window->driverdata)->window : None); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
412 GLXContext glx_context = (GLXContext) context; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
413 int status; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
414 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
415 status = 0; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
416 if (!_this->gl_data->glXMakeCurrent(display, drawable, glx_context)) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
417 SDL_SetError("Unable to make GL context current"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
418 status = -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
419 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
420 XSync(display, False); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
421 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
422 return (status); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
423 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
424 |
2327
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
425 /* |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
426 0 is a valid argument to glxSwapIntervalMESA and setting it to 0 |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
427 with the MESA version of the extension will undo the effect of a |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
428 previous call with a value that is greater than zero (or at least |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
429 that is what the FM says. OTOH, 0 is an invalid argument to |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
430 glxSwapIntervalSGI and it returns an error if you call it with 0 as |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
431 an argument. |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
432 */ |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
433 |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
434 static int swapinterval = -1; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
435 int |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
436 X11_GL_SetSwapInterval(_THIS, int interval) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
437 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
438 int status; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
439 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
440 if (_this->gl_data->glXSwapIntervalMESA) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
441 status = _this->gl_data->glXSwapIntervalMESA(interval); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
442 if (status != 0) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
443 SDL_SetError("glxSwapIntervalMESA failed"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
444 status = -1; |
2327
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
445 } else { |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
446 swapinterval = interval; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
447 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
448 } else if (_this->gl_data->glXSwapIntervalSGI) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
449 status = _this->gl_data->glXSwapIntervalSGI(interval); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
450 if (status != 0) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
451 SDL_SetError("glxSwapIntervalSGI failed"); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
452 status = -1; |
2327
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
453 } else { |
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
454 swapinterval = interval; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
455 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
456 } else { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
457 SDL_Unsupported(); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
458 status = -1; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
459 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
460 return status; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
461 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
462 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
463 int |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
464 X11_GL_GetSwapInterval(_THIS) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
465 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
466 if (_this->gl_data->glXGetSwapIntervalMESA) { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
467 return _this->gl_data->glXGetSwapIntervalMESA(); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
468 } else { |
2327
7b53a8401195
In testdyngl.c the event type was being anded (&) with SDL_KEYDOWN and if the result was none zero the program was quiting. This is very weird because it was
Bob Pendleton <bob@pendleton.com>
parents:
2324
diff
changeset
|
469 return swapinterval; |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
470 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
471 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
472 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
473 void |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
474 X11_GL_SwapWindow(_THIS, SDL_Window * window) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
475 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
476 SDL_WindowData *data = (SDL_WindowData *) window->driverdata; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
477 Display *display = data->videodata->display; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
478 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
479 _this->gl_data->glXSwapBuffers(display, data->window); |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
480 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
481 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
482 void |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
483 X11_GL_DeleteContext(_THIS, SDL_GLContext context) |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
484 { |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
485 Display *display = ((SDL_VideoData *) _this->driverdata)->display; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
486 GLXContext glx_context = (GLXContext) context; |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
487 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
488 _this->gl_data->glXDestroyContext(display, glx_context); |
2324
3202e4826c57
more valgrind errors fixed. Plus I ran make indent which changed a few files.
Bob Pendleton <bob@pendleton.com>
parents:
2323
diff
changeset
|
489 XSync(display, False); |
1952
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
490 } |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
491 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
492 #endif /* SDL_VIDEO_OPENGL_GLX */ |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
493 |
420716272158
Implemented X11 OpenGL support.
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
494 /* vi: set ts=4 sw=4 expandtab: */ |