comparison src/video/x11/SDL_x11opengl.c @ 4550:e4e462f591d7

Fixed bug 1006 Get the GLX functions with glXGetProcAddress() when available.
author Sam Lantinga <slouken@libsdl.org>
date Sun, 18 Jul 2010 11:18:36 -0700
parents f7b03b6838cb
children 6dfc9c4a9ae5
comparison
equal deleted inserted replaced
4549:80277d92551b 4550:e4e462f591d7
119 } 119 }
120 120
121 /* Load function pointers */ 121 /* Load function pointers */
122 handle = _this->gl_config.dll_handle; 122 handle = _this->gl_config.dll_handle;
123 _this->gl_data->glXGetProcAddress = 123 _this->gl_data->glXGetProcAddress =
124 (void *(*)(const GLubyte *)) GL_LoadFunction(handle, 124 (void *(*)(const GLubyte *))
125 "glXGetProcAddressARB"); 125 GL_LoadFunction(handle, "glXGetProcAddressARB");
126 _this->gl_data->glXChooseVisual = 126 _this->gl_data->glXChooseVisual =
127 (XVisualInfo * (*)(Display *, int, int *)) GL_LoadFunction(handle, 127 (XVisualInfo * (*)(Display *, int, int *))
128 "glXChooseVisual"); 128 X11_GL_GetProcAddress(_this, "glXChooseVisual");
129 _this->gl_data->glXCreateContext = 129 _this->gl_data->glXCreateContext =
130 (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int)) 130 (GLXContext(*)(Display *, XVisualInfo *, GLXContext, int))
131 GL_LoadFunction(handle, "glXCreateContext"); 131 X11_GL_GetProcAddress(_this, "glXCreateContext");
132 _this->gl_data->glXDestroyContext = 132 _this->gl_data->glXDestroyContext =
133 (void (*)(Display *, GLXContext)) GL_LoadFunction(handle, 133 (void (*)(Display *, GLXContext))
134 "glXDestroyContext"); 134 X11_GL_GetProcAddress(_this, "glXDestroyContext");
135 _this->gl_data->glXMakeCurrent = 135 _this->gl_data->glXMakeCurrent =
136 (int (*)(Display *, GLXDrawable, GLXContext)) GL_LoadFunction(handle, 136 (int (*)(Display *, GLXDrawable, GLXContext))
137 "glXMakeCurrent"); 137 X11_GL_GetProcAddress(_this, "glXMakeCurrent");
138 _this->gl_data->glXSwapBuffers = 138 _this->gl_data->glXSwapBuffers =
139 (void (*)(Display *, GLXDrawable)) GL_LoadFunction(handle, 139 (void (*)(Display *, GLXDrawable))
140 "glXSwapBuffers"); 140 X11_GL_GetProcAddress(_this, "glXSwapBuffers");
141 141
142 if (!_this->gl_data->glXChooseVisual || 142 if (!_this->gl_data->glXChooseVisual ||
143 !_this->gl_data->glXCreateContext || 143 !_this->gl_data->glXCreateContext ||
144 !_this->gl_data->glXDestroyContext || 144 !_this->gl_data->glXDestroyContext ||
145 !_this->gl_data->glXMakeCurrent || !_this->gl_data->glXSwapBuffers) { 145 !_this->gl_data->glXMakeCurrent ||
146 !_this->gl_data->glXSwapBuffers) {
146 SDL_SetError("Could not retrieve OpenGL functions"); 147 SDL_SetError("Could not retrieve OpenGL functions");
147 return -1; 148 return -1;
148 } 149 }
149 150
150 /* Initialize extensions */ 151 /* Initialize extensions */
154 } 155 }
155 156
156 void * 157 void *
157 X11_GL_GetProcAddress(_THIS, const char *proc) 158 X11_GL_GetProcAddress(_THIS, const char *proc)
158 { 159 {
159 void *handle;
160
161 handle = _this->gl_config.dll_handle;
162 if (_this->gl_data->glXGetProcAddress) { 160 if (_this->gl_data->glXGetProcAddress) {
163 return _this->gl_data->glXGetProcAddress((const GLubyte *) proc); 161 return _this->gl_data->glXGetProcAddress((const GLubyte *) proc);
164 } 162 }
165 return GL_LoadFunction(handle, proc); 163 return GL_LoadFunction(_this->gl_config.dll_handle, proc);
166 } 164 }
167 165
168 void 166 void
169 X11_GL_UnloadLibrary(_THIS) 167 X11_GL_UnloadLibrary(_THIS)
170 { 168 {