Mercurial > sdl-ios-xcode
comparison src/video/cocoa/SDL_cocoaopengl.m @ 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 | db3ba6c0d0df |
comparison
equal
deleted
inserted
replaced
1951:7177581dc9fa | 1952:420716272158 |
---|---|
23 | 23 |
24 #include "SDL_cocoavideo.h" | 24 #include "SDL_cocoavideo.h" |
25 | 25 |
26 /* NSOpenGL implementation of SDL OpenGL support */ | 26 /* NSOpenGL implementation of SDL OpenGL support */ |
27 | 27 |
28 #if SDL_VIDEO_OPENGL | 28 #if SDL_VIDEO_OPENGL_CGL |
29 #include <OpenGL/CGLTypes.h> | 29 #include <OpenGL/CGLTypes.h> |
30 | 30 |
31 #include "SDL_loadso.h" | 31 #include "SDL_loadso.h" |
32 #include "SDL_opengl.h" | 32 #include "SDL_opengl.h" |
33 | 33 |
34 | 34 |
35 #define DEFAULT_OPENGL_PATH "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" | 35 #define DEFAULT_OPENGL "/System/Library/Frameworks/OpenGL.framework/Libraries/libGL.dylib" |
36 | 36 |
37 /* This is implemented in Mac OS X 10.3 and above */ | 37 /* This is implemented in Mac OS X 10.3 and above */ |
38 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 | 38 #if MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_3 |
39 @implementation NSOpenGLContext(CGLContextAccess) | 39 @implementation NSOpenGLContext(CGLContextAccess) |
40 - (CGLContextObj)CGLContextObj; | 40 - (CGLContextObj)CGLContextObj; |
55 ++_this->gl_config.driver_loaded; | 55 ++_this->gl_config.driver_loaded; |
56 return 0; | 56 return 0; |
57 } | 57 } |
58 } | 58 } |
59 if (path == NULL) { | 59 if (path == NULL) { |
60 path = DEFAULT_OPENGL_PATH; | 60 path = SDL_getenv("SDL_OPENGL_LIBRARY"); |
61 } | |
62 if (path == NULL) { | |
63 path = DEFAULT_OPENGL; | |
61 } | 64 } |
62 _this->gl_config.dll_handle = SDL_LoadObject(path); | 65 _this->gl_config.dll_handle = SDL_LoadObject(path); |
63 if (!_this->gl_config.dll_handle) { | 66 if (!_this->gl_config.dll_handle) { |
64 return -1; | 67 return -1; |
65 } | 68 } |
83 return; | 86 return; |
84 } | 87 } |
85 SDL_UnloadObject(_this->gl_config.dll_handle); | 88 SDL_UnloadObject(_this->gl_config.dll_handle); |
86 _this->gl_config.dll_handle = NULL; | 89 _this->gl_config.dll_handle = NULL; |
87 } | 90 } |
88 } | |
89 | |
90 static void | |
91 Cocoa_GL_Shutdown(_THIS) | |
92 { | |
93 if (!_this->gl_data || (--_this->gl_data->initialized > 0)) { | |
94 return; | |
95 } | |
96 | |
97 Cocoa_GL_UnloadLibrary(_this); | |
98 | |
99 SDL_free(_this->gl_data); | |
100 _this->gl_data = NULL; | |
101 } | 91 } |
102 | 92 |
103 static int | 93 static int |
104 Cocoa_GL_Initialize(_THIS) | 94 Cocoa_GL_Initialize(_THIS) |
105 { | 95 { |
120 | 110 |
121 if (Cocoa_GL_LoadLibrary(_this, NULL) < 0) { | 111 if (Cocoa_GL_LoadLibrary(_this, NULL) < 0) { |
122 return -1; | 112 return -1; |
123 } | 113 } |
124 return 0; | 114 return 0; |
115 } | |
116 | |
117 static void | |
118 Cocoa_GL_Shutdown(_THIS) | |
119 { | |
120 if (!_this->gl_data || (--_this->gl_data->initialized > 0)) { | |
121 return; | |
122 } | |
123 | |
124 Cocoa_GL_UnloadLibrary(_this); | |
125 | |
126 SDL_free(_this->gl_data); | |
127 _this->gl_data = NULL; | |
125 } | 128 } |
126 | 129 |
127 int | 130 int |
128 Cocoa_GL_SetupWindow(_THIS, SDL_Window * window) | 131 Cocoa_GL_SetupWindow(_THIS, SDL_Window * window) |
129 { | 132 { |
350 [nscontext release]; | 353 [nscontext release]; |
351 | 354 |
352 [pool release]; | 355 [pool release]; |
353 } | 356 } |
354 | 357 |
355 #endif /* SDL_VIDEO_OPENGL */ | 358 #endif /* SDL_VIDEO_OPENGL_CGL */ |
356 | 359 |
357 /* vi: set ts=4 sw=4 expandtab: */ | 360 /* vi: set ts=4 sw=4 expandtab: */ |