comparison src/video/maccommon/SDL_macgl.c @ 1668:4da1ee79c9af SDL-1.3

more tweaking indent options
author Sam Lantinga <slouken@libsdl.org>
date Mon, 29 May 2006 04:04:35 +0000
parents 782fd950bd46
children
comparison
equal deleted inserted replaced
1667:1fddae038bc8 1668:4da1ee79c9af
28 #include "SDL_loadso.h" 28 #include "SDL_loadso.h"
29 29
30 30
31 /* krat: adding OpenGL support */ 31 /* krat: adding OpenGL support */
32 int 32 int
33 Mac_GL_Init (_THIS) 33 Mac_GL_Init(_THIS)
34 { 34 {
35 #if SDL_VIDEO_OPENGL 35 #if SDL_VIDEO_OPENGL
36 AGLPixelFormat format; 36 AGLPixelFormat format;
37 int i = 0; 37 int i = 0;
38 GLint attributes[26]; /* 26 is max possible in this setup */ 38 GLint attributes[26]; /* 26 is max possible in this setup */
39 GLboolean noerr; 39 GLboolean noerr;
40 40
41 /* load the gl driver from a default path */ 41 /* load the gl driver from a default path */
42 if (!this->gl_config.driver_loaded) { 42 if (!this->gl_config.driver_loaded) {
43 /* no driver has been loaded, use default (ourselves) */ 43 /* no driver has been loaded, use default (ourselves) */
44 if (Mac_GL_LoadLibrary (this, NULL) < 0) { 44 if (Mac_GL_LoadLibrary(this, NULL) < 0) {
45 return (-1); 45 return (-1);
46 } 46 }
47 } 47 }
48 48
49 attributes[i++] = AGL_RGBA; 49 attributes[i++] = AGL_RGBA;
101 } 101 }
102 102
103 attributes[i++] = AGL_ALL_RENDERERS; 103 attributes[i++] = AGL_ALL_RENDERERS;
104 attributes[i] = AGL_NONE; 104 attributes[i] = AGL_NONE;
105 105
106 format = aglChoosePixelFormat (NULL, 0, attributes); 106 format = aglChoosePixelFormat(NULL, 0, attributes);
107 if (format == NULL) { 107 if (format == NULL) {
108 SDL_SetError ("Couldn't match OpenGL desired format"); 108 SDL_SetError("Couldn't match OpenGL desired format");
109 return (-1); 109 return (-1);
110 } 110 }
111 111
112 glContext = aglCreateContext (format, NULL); 112 glContext = aglCreateContext(format, NULL);
113 if (glContext == NULL) { 113 if (glContext == NULL) {
114 SDL_SetError ("Couldn't create OpenGL context"); 114 SDL_SetError("Couldn't create OpenGL context");
115 return (-1); 115 return (-1);
116 } 116 }
117 aglDestroyPixelFormat (format); 117 aglDestroyPixelFormat(format);
118 118
119 #if TARGET_API_MAC_CARBON 119 #if TARGET_API_MAC_CARBON
120 noerr = aglSetDrawable (glContext, GetWindowPort (SDL_Window)); 120 noerr = aglSetDrawable(glContext, GetWindowPort(SDL_Window));
121 #else 121 #else
122 noerr = aglSetDrawable (glContext, (AGLDrawable) SDL_Window); 122 noerr = aglSetDrawable(glContext, (AGLDrawable) SDL_Window);
123 #endif 123 #endif
124 124
125 if (!noerr) { 125 if (!noerr) {
126 SDL_SetError ("Unable to bind GL context to window"); 126 SDL_SetError("Unable to bind GL context to window");
127 return (-1); 127 return (-1);
128 } 128 }
129 return (0); 129 return (0);
130 #else 130 #else
131 SDL_SetError ("OpenGL support not configured"); 131 SDL_SetError("OpenGL support not configured");
132 return (-1); 132 return (-1);
133 #endif 133 #endif
134 } 134 }
135 135
136 void 136 void
137 Mac_GL_Quit (_THIS) 137 Mac_GL_Quit(_THIS)
138 { 138 {
139 #if SDL_VIDEO_OPENGL 139 #if SDL_VIDEO_OPENGL
140 if (glContext != NULL) { 140 if (glContext != NULL) {
141 aglSetCurrentContext (NULL); 141 aglSetCurrentContext(NULL);
142 aglSetDrawable (glContext, NULL); 142 aglSetDrawable(glContext, NULL);
143 aglDestroyContext (glContext); 143 aglDestroyContext(glContext);
144 glContext = NULL; 144 glContext = NULL;
145 } 145 }
146 #endif 146 #endif
147 } 147 }
148 148
149 #if SDL_VIDEO_OPENGL 149 #if SDL_VIDEO_OPENGL
150 150
151 /* Make the current context active */ 151 /* Make the current context active */
152 int 152 int
153 Mac_GL_MakeCurrent (_THIS) 153 Mac_GL_MakeCurrent(_THIS)
154 { 154 {
155 int retval; 155 int retval;
156 156
157 retval = 0; 157 retval = 0;
158 if (!aglSetCurrentContext (glContext)) { 158 if (!aglSetCurrentContext(glContext)) {
159 SDL_SetError ("Unable to make GL context current"); 159 SDL_SetError("Unable to make GL context current");
160 retval = -1; 160 retval = -1;
161 } 161 }
162 return (retval); 162 return (retval);
163 } 163 }
164 164
165 void 165 void
166 Mac_GL_SwapBuffers (_THIS) 166 Mac_GL_SwapBuffers(_THIS)
167 { 167 {
168 aglSwapBuffers (glContext); 168 aglSwapBuffers(glContext);
169 } 169 }
170 170
171 int 171 int
172 Mac_GL_LoadLibrary (_THIS, const char *location) 172 Mac_GL_LoadLibrary(_THIS, const char *location)
173 { 173 {
174 if (location == NULL) 174 if (location == NULL)
175 #if __MACH__ 175 #if __MACH__
176 location = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; 176 location = "/System/Library/Frameworks/OpenGL.framework/OpenGL";
177 #else 177 #else
178 location = "OpenGLLibrary"; 178 location = "OpenGLLibrary";
179 #endif 179 #endif
180 180
181 this->hidden->libraryHandle = SDL_LoadObject (location); 181 this->hidden->libraryHandle = SDL_LoadObject(location);
182 182
183 this->gl_config.driver_loaded = 1; 183 this->gl_config.driver_loaded = 1;
184 return (this->hidden->libraryHandle != NULL) ? 0 : -1; 184 return (this->hidden->libraryHandle != NULL) ? 0 : -1;
185 } 185 }
186 186
187 void 187 void
188 Mac_GL_UnloadLibrary (_THIS) 188 Mac_GL_UnloadLibrary(_THIS)
189 { 189 {
190 SDL_UnloadObject (this->hidden->libraryHandle); 190 SDL_UnloadObject(this->hidden->libraryHandle);
191 191
192 this->hidden->libraryHandle = NULL; 192 this->hidden->libraryHandle = NULL;
193 this->gl_config.driver_loaded = 0; 193 this->gl_config.driver_loaded = 0;
194 } 194 }
195 195
196 void * 196 void *
197 Mac_GL_GetProcAddress (_THIS, const char *proc) 197 Mac_GL_GetProcAddress(_THIS, const char *proc)
198 { 198 {
199 return SDL_LoadFunction (this->hidden->libraryHandle, proc); 199 return SDL_LoadFunction(this->hidden->libraryHandle, proc);
200 } 200 }
201 201
202 #endif /* SDL_VIDEO_OPENGL */ 202 #endif /* SDL_VIDEO_OPENGL */
203 /* vi: set ts=4 sw=4 expandtab: */ 203 /* vi: set ts=4 sw=4 expandtab: */