comparison src/video/x11/SDL_x11opengl.c @ 2322:c25d45b7add3

Fixing valgrind errors. One of the error was the result of an unitended recursive call to X11_GL_LoadLibrary which was also fixed.
author Bob Pendleton <bob@pendleton.com>
date Thu, 06 Mar 2008 17:08:10 +0000
parents 166400aa33d7
children 4ac07ae446d3
comparison
equal deleted inserted replaced
2321:c5feceb0395e 2322:c25d45b7add3
63 #define GL_LoadObject SDL_LoadObject 63 #define GL_LoadObject SDL_LoadObject
64 #define GL_LoadFunction SDL_LoadFunction 64 #define GL_LoadFunction SDL_LoadFunction
65 #define GL_UnloadObject SDL_UnloadObject 65 #define GL_UnloadObject SDL_UnloadObject
66 #endif 66 #endif
67 67
68 static int X11_GL_InitializeMemory(_THIS);
69
68 int 70 int
69 X11_GL_LoadLibrary(_THIS, const char *path) 71 X11_GL_LoadLibrary(_THIS, const char *path)
70 { 72 {
71 void *handle; 73 void *handle;
72 74
88 handle = GL_LoadObject(path); 90 handle = GL_LoadObject(path);
89 if (!handle) { 91 if (!handle) {
90 return -1; 92 return -1;
91 } 93 }
92 // LoadLibrary may be called before WindowCreate! 94 // LoadLibrary may be called before WindowCreate!
93 X11_GL_Initialize(_this); 95 // Must create the memory used by GL
96 X11_GL_InitializeMemory(_this);
94 97
95 /* Load new function pointers */ 98 /* Load new function pointers */
96 _this->gl_data->glXGetProcAddress = 99 _this->gl_data->glXGetProcAddress =
97 (void *(*)(const GLubyte *)) GL_LoadFunction(handle, 100 (void *(*)(const GLubyte *)) GL_LoadFunction(handle,
98 "glXGetProcAddressARB"); 101 "glXGetProcAddressARB");
252 } 255 }
253 XDestroyWindow(display, w); 256 XDestroyWindow(display, w);
254 /* X11_PumpEvents(_this); */ /* can't do that because the windowlist may be inconsitent at this point */ 257 /* X11_PumpEvents(_this); */ /* can't do that because the windowlist may be inconsitent at this point */
255 } 258 }
256 259
257 int 260 static int
258 X11_GL_Initialize(_THIS) 261 X11_GL_InitializeMemory(_THIS)
259 { 262 {
260 if (_this->gl_data) { 263 if (_this->gl_data) {
261 ++_this->gl_data->initialized;
262 return 0; 264 return 0;
263 } 265 }
264 266
265 _this->gl_data = 267 _this->gl_data =
266 (struct SDL_GLDriverData *) SDL_calloc(1, 268 (struct SDL_GLDriverData *) SDL_calloc(1,
268 SDL_GLDriverData)); 270 SDL_GLDriverData));
269 if (!_this->gl_data) { 271 if (!_this->gl_data) {
270 SDL_OutOfMemory(); 272 SDL_OutOfMemory();
271 return -1; 273 return -1;
272 } 274 }
273 _this->gl_data->initialized = 1; 275 _this->gl_data->initialized = 0;
274
275 if (X11_GL_LoadLibrary(_this, NULL) < 0) {
276 return -1;
277 }
278
279 /* Initialize extensions */
280 X11_GL_InitExtensions(_this);
281 276
282 return 0; 277 return 0;
278 }
279
280 int
281 X11_GL_Initialize(_THIS)
282 {
283
284 if (X11_GL_InitializeMemory(_this) < 0) {
285 return -1;
286 }
287 ++_this->gl_data->initialized;
288
289 if (X11_GL_LoadLibrary(_this, NULL) < 0) {
290 return -1;
291 }
292
293 /* Initialize extensions */
294 X11_GL_InitExtensions(_this);
295
296 return 0;
283 } 297 }
284 298
285 void 299 void
286 X11_GL_Shutdown(_THIS) 300 X11_GL_Shutdown(_THIS)
287 { 301 {