comparison src/video/win32/SDL_win32opengl.c @ 1952:420716272158

Implemented X11 OpenGL support. Added support for the SDL_VIDEO_OPENGL environment variable.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 28 Jul 2006 08:43:17 +0000
parents 83946ee0ff1f
children abbe2c1dcf0a
comparison
equal deleted inserted replaced
1951:7177581dc9fa 1952:420716272158
23 23
24 #include "SDL_win32video.h" 24 #include "SDL_win32video.h"
25 25
26 /* WGL implementation of SDL OpenGL support */ 26 /* WGL implementation of SDL OpenGL support */
27 27
28 #if SDL_VIDEO_OPENGL 28 #if SDL_VIDEO_OPENGL_WGL
29 #include "SDL_opengl.h" 29 #include "SDL_opengl.h"
30 30
31 #define DEFAULT_OPENGL_PATH "OPENGL32.DLL" 31 #define DEFAULT_OPENGL "OPENGL32.DLL"
32 32
33 33
34 int 34 int
35 WIN_GL_LoadLibrary(_THIS, const char *path) 35 WIN_GL_LoadLibrary(_THIS, const char *path)
36 { 36 {
45 ++_this->gl_config.driver_loaded; 45 ++_this->gl_config.driver_loaded;
46 return 0; 46 return 0;
47 } 47 }
48 } 48 }
49 if (path == NULL) { 49 if (path == NULL) {
50 path = DEFAULT_OPENGL_PATH; 50 path = SDL_getenv("SDL_OPENGL_LIBRARY");
51 }
52 if (path == NULL) {
53 path = DEFAULT_OPENGL;
51 } 54 }
52 wpath = WIN_UTF8ToString(path); 55 wpath = WIN_UTF8ToString(path);
53 handle = LoadLibrary(wpath); 56 handle = LoadLibrary(wpath);
54 SDL_free(wpath); 57 SDL_free(wpath);
55 if (!handle) { 58 if (!handle) {
255 ReleaseDC(hwnd, hdc); 258 ReleaseDC(hwnd, hdc);
256 DestroyWindow(hwnd); 259 DestroyWindow(hwnd);
257 WIN_PumpEvents(_this); 260 WIN_PumpEvents(_this);
258 } 261 }
259 262
260 static void
261 WIN_GL_Shutdown(_THIS)
262 {
263 if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
264 return;
265 }
266
267 WIN_GL_UnloadLibrary(_this);
268
269 SDL_free(_this->gl_data);
270 _this->gl_data = NULL;
271 }
272
273 static int 263 static int
274 WIN_GL_Initialize(_THIS) 264 WIN_GL_Initialize(_THIS)
275 { 265 {
276 if (_this->gl_data) { 266 if (_this->gl_data) {
277 ++_this->gl_data->initialized; 267 ++_this->gl_data->initialized;
294 284
295 /* Initialize extensions */ 285 /* Initialize extensions */
296 WIN_GL_InitExtensions(_this); 286 WIN_GL_InitExtensions(_this);
297 287
298 return 0; 288 return 0;
289 }
290
291 static void
292 WIN_GL_Shutdown(_THIS)
293 {
294 if (!_this->gl_data || (--_this->gl_data->initialized > 0)) {
295 return;
296 }
297
298 WIN_GL_UnloadLibrary(_this);
299
300 SDL_free(_this->gl_data);
301 _this->gl_data = NULL;
299 } 302 }
300 303
301 int 304 int
302 WIN_GL_SetupWindow(_THIS, SDL_Window * window) 305 WIN_GL_SetupWindow(_THIS, SDL_Window * window)
303 { 306 {
477 WIN_GL_DeleteContext(_THIS, SDL_GLContext context) 480 WIN_GL_DeleteContext(_THIS, SDL_GLContext context)
478 { 481 {
479 _this->gl_data->wglDeleteContext((HGLRC) context); 482 _this->gl_data->wglDeleteContext((HGLRC) context);
480 } 483 }
481 484
482 #endif /* SDL_VIDEO_OPENGL */ 485 #endif /* SDL_VIDEO_OPENGL_WGL */
483
484 486
485 /* vi: set ts=4 sw=4 expandtab: */ 487 /* vi: set ts=4 sw=4 expandtab: */