Mercurial > sdl-ios-xcode
comparison src/video/wincommon/SDL_wingl.c @ 1662:782fd950bd46 SDL-1.3
Revamp of the video system in progress - adding support for multiple displays, multiple windows, and a full video mode selection API.
WARNING: None of the video drivers have been updated for the new API yet! The API is still under design and very fluid.
The code is now run through a consistent indent format:
indent -i4 -nut -nsc -br -ce
The headers are being converted to automatically generate doxygen documentation.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Sun, 28 May 2006 13:04:16 +0000 |
parents | 14717b52abc0 |
children | 4da1ee79c9af |
comparison
equal
deleted
inserted
replaced
1661:281d3f4870e5 | 1662:782fd950bd46 |
---|---|
32 #if SDL_VIDEO_OPENGL | 32 #if SDL_VIDEO_OPENGL |
33 #define DEFAULT_GL_DRIVER_PATH "OPENGL32.DLL" | 33 #define DEFAULT_GL_DRIVER_PATH "OPENGL32.DLL" |
34 #endif | 34 #endif |
35 | 35 |
36 /* If setting the HDC fails, we may need to recreate the window (MSDN) */ | 36 /* If setting the HDC fails, we may need to recreate the window (MSDN) */ |
37 static int WIN_GL_ResetWindow(_THIS) | 37 static int |
38 { | 38 WIN_GL_ResetWindow (_THIS) |
39 int status = 0; | 39 { |
40 | 40 int status = 0; |
41 #ifndef _WIN32_WCE /* FIXME WinCE needs the UNICODE version of CreateWindow() */ | 41 |
42 /* This doesn't work with DirectX code (see CVS comments) */ | 42 #ifndef _WIN32_WCE /* FIXME WinCE needs the UNICODE version of CreateWindow() */ |
43 /* If we were passed a window, then we can't create a new one */ | 43 /* This doesn't work with DirectX code (see CVS comments) */ |
44 if ( !SDL_windowid && SDL_strcmp(this->name, "windib") == 0 ) { | 44 /* If we were passed a window, then we can't create a new one */ |
45 /* Save the existing window attributes */ | 45 if (!SDL_windowid && SDL_strcmp (this->name, "windib") == 0) { |
46 LONG style; | 46 /* Save the existing window attributes */ |
47 RECT rect = { 0, 0, 0, 0 }; | 47 LONG style; |
48 style = GetWindowLong(SDL_Window, GWL_STYLE); | 48 RECT rect = { 0, 0, 0, 0 }; |
49 GetWindowRect(SDL_Window, &rect); | 49 style = GetWindowLong (SDL_Window, GWL_STYLE); |
50 DestroyWindow(SDL_Window); | 50 GetWindowRect (SDL_Window, &rect); |
51 WIN_FlushMessageQueue(); | 51 DestroyWindow (SDL_Window); |
52 | 52 WIN_FlushMessageQueue (); |
53 SDL_Window = CreateWindow(SDL_Appname, SDL_Appname, | 53 |
54 style, | 54 SDL_Window = CreateWindow (SDL_Appname, SDL_Appname, |
55 rect.left, rect.top, | 55 style, |
56 (rect.right-rect.left)+1, | 56 rect.left, rect.top, |
57 (rect.top-rect.bottom)+1, | 57 (rect.right - rect.left) + 1, |
58 NULL, NULL, SDL_Instance, NULL); | 58 (rect.top - rect.bottom) + 1, |
59 WIN_FlushMessageQueue(); | 59 NULL, NULL, SDL_Instance, NULL); |
60 | 60 WIN_FlushMessageQueue (); |
61 if ( SDL_Window ) { | 61 |
62 this->SetCaption(this, this->wm_title, this->wm_icon); | 62 if (SDL_Window) { |
63 } else { | 63 this->SetCaption (this, this->wm_title, this->wm_icon); |
64 SDL_SetError("Couldn't create window"); | 64 } else { |
65 status = -1; | 65 SDL_SetError ("Couldn't create window"); |
66 } | 66 status = -1; |
67 } else | 67 } |
68 } else | |
68 #endif /* !_WIN32_WCE */ | 69 #endif /* !_WIN32_WCE */ |
69 { | 70 { |
70 SDL_SetError("Unable to reset window for OpenGL context"); | 71 SDL_SetError ("Unable to reset window for OpenGL context"); |
71 status = -1; | 72 status = -1; |
72 } | 73 } |
73 return(status); | 74 return (status); |
74 } | 75 } |
75 | 76 |
76 #if SDL_VIDEO_OPENGL | 77 #if SDL_VIDEO_OPENGL |
77 | 78 |
78 static int ExtensionSupported(const char *extension, const char *extensions) | 79 static int |
79 { | 80 ExtensionSupported (const char *extension, const char *extensions) |
80 const char *start; | 81 { |
81 const char *where, *terminator; | 82 const char *start; |
82 | 83 const char *where, *terminator; |
83 /* Extension names should not have spaces. */ | 84 |
84 where = SDL_strchr(extension, ' '); | 85 /* Extension names should not have spaces. */ |
85 if ( where || *extension == '\0' ) | 86 where = SDL_strchr (extension, ' '); |
86 return 0; | 87 if (where || *extension == '\0') |
87 | 88 return 0; |
88 if ( ! extensions ) | 89 |
89 return 0; | 90 if (!extensions) |
90 | 91 return 0; |
91 /* It takes a bit of care to be fool-proof about parsing the | 92 |
92 * OpenGL extensions string. Don't be fooled by sub-strings, | 93 /* It takes a bit of care to be fool-proof about parsing the |
93 * etc. */ | 94 * OpenGL extensions string. Don't be fooled by sub-strings, |
94 | 95 * etc. */ |
95 start = extensions; | 96 |
96 | 97 start = extensions; |
97 for (;;) | 98 |
98 { | 99 for (;;) { |
99 where = SDL_strstr(start, extension); | 100 where = SDL_strstr (start, extension); |
100 if (!where) break; | 101 if (!where) |
101 | 102 break; |
102 terminator = where + SDL_strlen(extension); | 103 |
103 if (where == start || *(where - 1) == ' ') | 104 terminator = where + SDL_strlen (extension); |
104 if (*terminator == ' ' || *terminator == '\0') return 1; | 105 if (where == start || *(where - 1) == ' ') |
105 | 106 if (*terminator == ' ' || *terminator == '\0') |
106 start = terminator; | 107 return 1; |
107 } | 108 |
108 | 109 start = terminator; |
109 return 0; | 110 } |
110 } | 111 |
111 | 112 return 0; |
112 static void Init_WGL_ARB_extensions(_THIS) | 113 } |
113 { | 114 |
114 HWND hwnd; | 115 static void |
115 HDC hdc; | 116 Init_WGL_ARB_extensions (_THIS) |
116 HGLRC hglrc; | 117 { |
117 int pformat; | 118 HWND hwnd; |
118 const char * (WINAPI *wglGetExtensionsStringARB)(HDC) = 0; | 119 HDC hdc; |
119 const char *extensions; | 120 HGLRC hglrc; |
120 | 121 int pformat; |
121 hwnd = CreateWindow(SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED, | 122 const char *(WINAPI * wglGetExtensionsStringARB) (HDC) = 0; |
122 0, 0, 10, 10, | 123 const char *extensions; |
123 NULL, NULL, SDL_Instance, NULL); | 124 |
124 WIN_FlushMessageQueue(); | 125 hwnd = CreateWindow (SDL_Appname, SDL_Appname, WS_POPUP | WS_DISABLED, |
125 | 126 0, 0, 10, 10, NULL, NULL, SDL_Instance, NULL); |
126 hdc = GetDC(hwnd); | 127 WIN_FlushMessageQueue (); |
127 | 128 |
128 pformat = ChoosePixelFormat(hdc, &GL_pfd); | 129 hdc = GetDC (hwnd); |
129 SetPixelFormat(hdc, pformat, &GL_pfd); | 130 |
130 | 131 pformat = ChoosePixelFormat (hdc, &GL_pfd); |
131 hglrc = this->gl_data->wglCreateContext(hdc); | 132 SetPixelFormat (hdc, pformat, &GL_pfd); |
132 if ( hglrc ) { | 133 |
133 this->gl_data->wglMakeCurrent(hdc, hglrc); | 134 hglrc = this->gl_data->wglCreateContext (hdc); |
134 } | 135 if (hglrc) { |
135 | 136 this->gl_data->wglMakeCurrent (hdc, hglrc); |
136 wglGetExtensionsStringARB = (const char * (WINAPI *)(HDC)) | 137 } |
137 this->gl_data->wglGetProcAddress("wglGetExtensionsStringARB"); | 138 |
138 | 139 wglGetExtensionsStringARB = (const char *(WINAPI *) (HDC)) |
139 if( wglGetExtensionsStringARB ) { | 140 this->gl_data->wglGetProcAddress ("wglGetExtensionsStringARB"); |
140 extensions = wglGetExtensionsStringARB(hdc); | 141 |
141 } else { | 142 if (wglGetExtensionsStringARB) { |
142 extensions = NULL; | 143 extensions = wglGetExtensionsStringARB (hdc); |
143 } | 144 } else { |
144 | 145 extensions = NULL; |
145 this->gl_data->WGL_ARB_pixel_format = 0; | 146 } |
146 if( ExtensionSupported("WGL_ARB_pixel_format", extensions) ) { | 147 |
147 this->gl_data->wglChoosePixelFormatARB = | 148 this->gl_data->WGL_ARB_pixel_format = 0; |
148 (BOOL (WINAPI *)(HDC, const int *, const FLOAT *, UINT, int *, UINT *)) | 149 if (ExtensionSupported ("WGL_ARB_pixel_format", extensions)) { |
149 this->gl_data->wglGetProcAddress("wglChoosePixelFormatARB"); | 150 this->gl_data->wglChoosePixelFormatARB = (BOOL (WINAPI *) |
150 this->gl_data->wglGetPixelFormatAttribivARB = | 151 (HDC, const int *, |
151 (BOOL (WINAPI *)(HDC, int, int, UINT, const int *, int *)) | 152 const FLOAT *, UINT, int *, |
152 this->gl_data->wglGetProcAddress("wglGetPixelFormatAttribivARB"); | 153 UINT *)) this->gl_data-> |
153 | 154 wglGetProcAddress ("wglChoosePixelFormatARB"); |
154 if( (this->gl_data->wglChoosePixelFormatARB != NULL) && | 155 this->gl_data->wglGetPixelFormatAttribivARB = |
155 (this->gl_data->wglGetPixelFormatAttribivARB != NULL) ) { | 156 (BOOL (WINAPI *) (HDC, int, int, UINT, const int *, int *)) |
156 this->gl_data->WGL_ARB_pixel_format = 1; | 157 this->gl_data->wglGetProcAddress ("wglGetPixelFormatAttribivARB"); |
157 } | 158 |
158 } | 159 if ((this->gl_data->wglChoosePixelFormatARB != NULL) && |
159 | 160 (this->gl_data->wglGetPixelFormatAttribivARB != NULL)) { |
160 if ( hglrc ) { | 161 this->gl_data->WGL_ARB_pixel_format = 1; |
161 this->gl_data->wglMakeCurrent(NULL, NULL); | 162 } |
162 this->gl_data->wglDeleteContext(hglrc); | 163 } |
163 } | 164 |
164 ReleaseDC(hwnd, hdc); | 165 if (hglrc) { |
165 DestroyWindow(hwnd); | 166 this->gl_data->wglMakeCurrent (NULL, NULL); |
166 WIN_FlushMessageQueue(); | 167 this->gl_data->wglDeleteContext (hglrc); |
168 } | |
169 ReleaseDC (hwnd, hdc); | |
170 DestroyWindow (hwnd); | |
171 WIN_FlushMessageQueue (); | |
167 } | 172 } |
168 | 173 |
169 #endif /* SDL_VIDEO_OPENGL */ | 174 #endif /* SDL_VIDEO_OPENGL */ |
170 | 175 |
171 int WIN_GL_SetupWindow(_THIS) | 176 int |
172 { | 177 WIN_GL_SetupWindow (_THIS) |
173 int retval; | 178 { |
179 int retval; | |
174 #if SDL_VIDEO_OPENGL | 180 #if SDL_VIDEO_OPENGL |
175 int i; | 181 int i; |
176 unsigned int matching; | 182 unsigned int matching; |
177 int iAttribs[64]; | 183 int iAttribs[64]; |
178 int *iAttr; | 184 int *iAttr; |
179 float fAttribs[1] = { 0 }; | 185 float fAttribs[1] = { 0 }; |
180 const GLubyte *(WINAPI *glGetStringFunc)(GLenum); | 186 const GLubyte *(WINAPI * glGetStringFunc) (GLenum); |
181 const char *wglext; | 187 const char *wglext; |
182 | 188 |
183 /* load the gl driver from a default path */ | 189 /* load the gl driver from a default path */ |
184 if ( ! this->gl_config.driver_loaded ) { | 190 if (!this->gl_config.driver_loaded) { |
185 /* no driver has been loaded, use default (ourselves) */ | 191 /* no driver has been loaded, use default (ourselves) */ |
186 if ( WIN_GL_LoadLibrary(this, NULL) < 0 ) { | 192 if (WIN_GL_LoadLibrary (this, NULL) < 0) { |
187 return(-1); | 193 return (-1); |
188 } | 194 } |
189 } | 195 } |
190 | 196 |
191 for ( i=0; ; ++i ) { | 197 for (i = 0;; ++i) { |
192 /* Get the window device context for our OpenGL drawing */ | 198 /* Get the window device context for our OpenGL drawing */ |
193 GL_hdc = GetDC(SDL_Window); | 199 GL_hdc = GetDC (SDL_Window); |
194 if ( GL_hdc == NULL ) { | 200 if (GL_hdc == NULL) { |
195 SDL_SetError("Unable to get DC for SDL_Window"); | 201 SDL_SetError ("Unable to get DC for SDL_Window"); |
196 return(-1); | 202 return (-1); |
197 } | 203 } |
198 | 204 |
199 /* Set up the pixel format descriptor with our needed format */ | 205 /* Set up the pixel format descriptor with our needed format */ |
200 SDL_memset(&GL_pfd, 0, sizeof(GL_pfd)); | 206 SDL_memset (&GL_pfd, 0, sizeof (GL_pfd)); |
201 GL_pfd.nSize = sizeof(GL_pfd); | 207 GL_pfd.nSize = sizeof (GL_pfd); |
202 GL_pfd.nVersion = 1; | 208 GL_pfd.nVersion = 1; |
203 GL_pfd.dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL); | 209 GL_pfd.dwFlags = (PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL); |
204 if ( this->gl_config.double_buffer ) { | 210 if (this->gl_config.double_buffer) { |
205 GL_pfd.dwFlags |= PFD_DOUBLEBUFFER; | 211 GL_pfd.dwFlags |= PFD_DOUBLEBUFFER; |
206 } | 212 } |
207 if ( this->gl_config.stereo ) { | 213 if (this->gl_config.stereo) { |
208 GL_pfd.dwFlags |= PFD_STEREO; | 214 GL_pfd.dwFlags |= PFD_STEREO; |
209 } | 215 } |
210 GL_pfd.iPixelType = PFD_TYPE_RGBA; | 216 GL_pfd.iPixelType = PFD_TYPE_RGBA; |
211 GL_pfd.cColorBits = this->gl_config.buffer_size; | 217 GL_pfd.cColorBits = this->gl_config.buffer_size; |
212 GL_pfd.cRedBits = this->gl_config.red_size; | 218 GL_pfd.cRedBits = this->gl_config.red_size; |
213 GL_pfd.cGreenBits = this->gl_config.green_size; | 219 GL_pfd.cGreenBits = this->gl_config.green_size; |
214 GL_pfd.cBlueBits = this->gl_config.blue_size; | 220 GL_pfd.cBlueBits = this->gl_config.blue_size; |
215 GL_pfd.cAlphaBits = this->gl_config.alpha_size; | 221 GL_pfd.cAlphaBits = this->gl_config.alpha_size; |
216 GL_pfd.cAccumRedBits = this->gl_config.accum_red_size; | 222 GL_pfd.cAccumRedBits = this->gl_config.accum_red_size; |
217 GL_pfd.cAccumGreenBits = this->gl_config.accum_green_size; | 223 GL_pfd.cAccumGreenBits = this->gl_config.accum_green_size; |
218 GL_pfd.cAccumBlueBits = this->gl_config.accum_blue_size; | 224 GL_pfd.cAccumBlueBits = this->gl_config.accum_blue_size; |
219 GL_pfd.cAccumAlphaBits = this->gl_config.accum_alpha_size; | 225 GL_pfd.cAccumAlphaBits = this->gl_config.accum_alpha_size; |
220 GL_pfd.cAccumBits = | 226 GL_pfd.cAccumBits = |
221 (GL_pfd.cAccumRedBits + GL_pfd.cAccumGreenBits + | 227 (GL_pfd.cAccumRedBits + GL_pfd.cAccumGreenBits + |
222 GL_pfd.cAccumBlueBits + GL_pfd.cAccumAlphaBits); | 228 GL_pfd.cAccumBlueBits + GL_pfd.cAccumAlphaBits); |
223 GL_pfd.cDepthBits = this->gl_config.depth_size; | 229 GL_pfd.cDepthBits = this->gl_config.depth_size; |
224 GL_pfd.cStencilBits = this->gl_config.stencil_size; | 230 GL_pfd.cStencilBits = this->gl_config.stencil_size; |
225 | 231 |
226 /* initialize WGL_ARB_pixel_format */ | 232 /* initialize WGL_ARB_pixel_format */ |
227 Init_WGL_ARB_extensions(this); | 233 Init_WGL_ARB_extensions (this); |
228 | 234 |
229 /* setup WGL_ARB_pixel_format attribs */ | 235 /* setup WGL_ARB_pixel_format attribs */ |
230 iAttr = &iAttribs[0]; | 236 iAttr = &iAttribs[0]; |
231 | 237 |
232 *iAttr++ = WGL_DRAW_TO_WINDOW_ARB; | 238 *iAttr++ = WGL_DRAW_TO_WINDOW_ARB; |
233 *iAttr++ = GL_TRUE; | 239 *iAttr++ = GL_TRUE; |
234 *iAttr++ = WGL_ACCELERATION_ARB; | 240 *iAttr++ = WGL_ACCELERATION_ARB; |
235 *iAttr++ = WGL_FULL_ACCELERATION_ARB; | 241 *iAttr++ = WGL_FULL_ACCELERATION_ARB; |
236 *iAttr++ = WGL_RED_BITS_ARB; | 242 *iAttr++ = WGL_RED_BITS_ARB; |
237 *iAttr++ = this->gl_config.red_size; | 243 *iAttr++ = this->gl_config.red_size; |
238 *iAttr++ = WGL_GREEN_BITS_ARB; | 244 *iAttr++ = WGL_GREEN_BITS_ARB; |
239 *iAttr++ = this->gl_config.green_size; | 245 *iAttr++ = this->gl_config.green_size; |
240 *iAttr++ = WGL_BLUE_BITS_ARB; | 246 *iAttr++ = WGL_BLUE_BITS_ARB; |
241 *iAttr++ = this->gl_config.blue_size; | 247 *iAttr++ = this->gl_config.blue_size; |
242 | 248 |
243 if ( this->gl_config.alpha_size ) { | 249 if (this->gl_config.alpha_size) { |
244 *iAttr++ = WGL_ALPHA_BITS_ARB; | 250 *iAttr++ = WGL_ALPHA_BITS_ARB; |
245 *iAttr++ = this->gl_config.alpha_size; | 251 *iAttr++ = this->gl_config.alpha_size; |
246 } | 252 } |
247 | 253 |
248 *iAttr++ = WGL_DOUBLE_BUFFER_ARB; | 254 *iAttr++ = WGL_DOUBLE_BUFFER_ARB; |
249 *iAttr++ = this->gl_config.double_buffer; | 255 *iAttr++ = this->gl_config.double_buffer; |
250 | 256 |
251 *iAttr++ = WGL_DEPTH_BITS_ARB; | 257 *iAttr++ = WGL_DEPTH_BITS_ARB; |
252 *iAttr++ = this->gl_config.depth_size; | 258 *iAttr++ = this->gl_config.depth_size; |
253 | 259 |
254 if ( this->gl_config.stencil_size ) { | 260 if (this->gl_config.stencil_size) { |
255 *iAttr++ = WGL_STENCIL_BITS_ARB; | 261 *iAttr++ = WGL_STENCIL_BITS_ARB; |
256 *iAttr++ = this->gl_config.stencil_size; | 262 *iAttr++ = this->gl_config.stencil_size; |
257 } | 263 } |
258 | 264 |
259 if ( this->gl_config.accum_red_size ) { | 265 if (this->gl_config.accum_red_size) { |
260 *iAttr++ = WGL_ACCUM_RED_BITS_ARB; | 266 *iAttr++ = WGL_ACCUM_RED_BITS_ARB; |
261 *iAttr++ = this->gl_config.accum_red_size; | 267 *iAttr++ = this->gl_config.accum_red_size; |
262 } | 268 } |
263 | 269 |
264 if ( this->gl_config.accum_green_size ) { | 270 if (this->gl_config.accum_green_size) { |
265 *iAttr++ = WGL_ACCUM_GREEN_BITS_ARB; | 271 *iAttr++ = WGL_ACCUM_GREEN_BITS_ARB; |
266 *iAttr++ = this->gl_config.accum_green_size; | 272 *iAttr++ = this->gl_config.accum_green_size; |
267 } | 273 } |
268 | 274 |
269 if ( this->gl_config.accum_blue_size ) { | 275 if (this->gl_config.accum_blue_size) { |
270 *iAttr++ = WGL_ACCUM_BLUE_BITS_ARB; | 276 *iAttr++ = WGL_ACCUM_BLUE_BITS_ARB; |
271 *iAttr++ = this->gl_config.accum_blue_size; | 277 *iAttr++ = this->gl_config.accum_blue_size; |
272 } | 278 } |
273 | 279 |
274 if ( this->gl_config.accum_alpha_size ) { | 280 if (this->gl_config.accum_alpha_size) { |
275 *iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB; | 281 *iAttr++ = WGL_ACCUM_ALPHA_BITS_ARB; |
276 *iAttr++ = this->gl_config.accum_alpha_size; | 282 *iAttr++ = this->gl_config.accum_alpha_size; |
277 } | 283 } |
278 | 284 |
279 if ( this->gl_config.stereo ) { | 285 if (this->gl_config.stereo) { |
280 *iAttr++ = WGL_STEREO_ARB; | 286 *iAttr++ = WGL_STEREO_ARB; |
281 *iAttr++ = GL_TRUE; | 287 *iAttr++ = GL_TRUE; |
282 } | 288 } |
283 | 289 |
284 if ( this->gl_config.multisamplebuffers ) { | 290 if (this->gl_config.multisamplebuffers) { |
285 *iAttr++ = WGL_SAMPLE_BUFFERS_ARB; | 291 *iAttr++ = WGL_SAMPLE_BUFFERS_ARB; |
286 *iAttr++ = this->gl_config.multisamplebuffers; | 292 *iAttr++ = this->gl_config.multisamplebuffers; |
287 } | 293 } |
288 | 294 |
289 if ( this->gl_config.multisamplesamples ) { | 295 if (this->gl_config.multisamplesamples) { |
290 *iAttr++ = WGL_SAMPLES_ARB; | 296 *iAttr++ = WGL_SAMPLES_ARB; |
291 *iAttr++ = this->gl_config.multisamplesamples; | 297 *iAttr++ = this->gl_config.multisamplesamples; |
292 } | 298 } |
293 | 299 |
294 if ( this->gl_config.accelerated >= 0 ) { | 300 if (this->gl_config.accelerated >= 0) { |
295 *iAttr++ = WGL_ACCELERATION_ARB; | 301 *iAttr++ = WGL_ACCELERATION_ARB; |
296 *iAttr++ = (this->gl_config.accelerated ? WGL_GENERIC_ACCELERATION_ARB : WGL_NO_ACCELERATION_ARB); | 302 *iAttr++ = |
297 } | 303 (this->gl_config. |
298 | 304 accelerated ? WGL_GENERIC_ACCELERATION_ARB : |
299 *iAttr = 0; | 305 WGL_NO_ACCELERATION_ARB); |
300 | 306 } |
301 /* Choose and set the closest available pixel format */ | 307 |
302 if ( !this->gl_data->WGL_ARB_pixel_format || | 308 *iAttr = 0; |
303 !this->gl_data->wglChoosePixelFormatARB(GL_hdc, iAttribs, fAttribs, 1, &pixel_format, &matching) || | 309 |
304 !matching ) { | 310 /* Choose and set the closest available pixel format */ |
305 pixel_format = ChoosePixelFormat(GL_hdc, &GL_pfd); | 311 if (!this->gl_data->WGL_ARB_pixel_format || |
306 this->gl_data->WGL_ARB_pixel_format = 0; | 312 !this->gl_data->wglChoosePixelFormatARB (GL_hdc, iAttribs, |
307 } | 313 fAttribs, 1, |
308 if ( !pixel_format ) { | 314 &pixel_format, &matching) |
309 SDL_SetError("No matching GL pixel format available"); | 315 || !matching) { |
310 return(-1); | 316 pixel_format = ChoosePixelFormat (GL_hdc, &GL_pfd); |
311 } | 317 this->gl_data->WGL_ARB_pixel_format = 0; |
312 if ( !SetPixelFormat(GL_hdc, pixel_format, &GL_pfd) ) { | 318 } |
313 if ( i == 0 ) { | 319 if (!pixel_format) { |
314 /* First time through, try resetting the window */ | 320 SDL_SetError ("No matching GL pixel format available"); |
315 if ( WIN_GL_ResetWindow(this) < 0 ) { | 321 return (-1); |
316 return(-1); | 322 } |
317 } | 323 if (!SetPixelFormat (GL_hdc, pixel_format, &GL_pfd)) { |
318 continue; | 324 if (i == 0) { |
319 } | 325 /* First time through, try resetting the window */ |
320 SDL_SetError("Unable to set HDC pixel format"); | 326 if (WIN_GL_ResetWindow (this) < 0) { |
321 return(-1); | 327 return (-1); |
322 } | 328 } |
323 /* We either succeeded or failed by this point */ | 329 continue; |
324 break; | 330 } |
325 } | 331 SDL_SetError ("Unable to set HDC pixel format"); |
326 DescribePixelFormat(GL_hdc, pixel_format, sizeof(GL_pfd), &GL_pfd); | 332 return (-1); |
327 | 333 } |
328 GL_hrc = this->gl_data->wglCreateContext(GL_hdc); | 334 /* We either succeeded or failed by this point */ |
329 if ( GL_hrc == NULL ) { | 335 break; |
330 SDL_SetError("Unable to create GL context"); | 336 } |
331 return(-1); | 337 DescribePixelFormat (GL_hdc, pixel_format, sizeof (GL_pfd), &GL_pfd); |
332 } | 338 |
333 if ( WIN_GL_MakeCurrent(this) < 0 ) { | 339 GL_hrc = this->gl_data->wglCreateContext (GL_hdc); |
334 return(-1); | 340 if (GL_hrc == NULL) { |
335 } | 341 SDL_SetError ("Unable to create GL context"); |
336 gl_active = 1; | 342 return (-1); |
337 | 343 } |
338 /* Vsync control under Windows. Checking glGetString here is | 344 if (WIN_GL_MakeCurrent (this) < 0) { |
339 * somewhat a documented and reliable hack - it was originally | 345 return (-1); |
340 * as a feature added by mistake, but since so many people rely | 346 } |
341 * on it, it will not be removed. strstr should be safe here.*/ | 347 gl_active = 1; |
342 glGetStringFunc = WIN_GL_GetProcAddress(this, "glGetString"); | 348 |
343 if ( glGetStringFunc ) { | 349 /* Vsync control under Windows. Checking glGetString here is |
344 wglext = (const char *)glGetStringFunc(GL_EXTENSIONS); | 350 * somewhat a documented and reliable hack - it was originally |
345 } else { | 351 * as a feature added by mistake, but since so many people rely |
346 /* Uh oh, something is seriously wrong here... */ | 352 * on it, it will not be removed. strstr should be safe here.*/ |
347 wglext = NULL; | 353 glGetStringFunc = WIN_GL_GetProcAddress (this, "glGetString"); |
348 } | 354 if (glGetStringFunc) { |
349 if ( !wglext || !SDL_strstr(wglext, "WGL_EXT_swap_control") ) { | 355 wglext = (const char *) glGetStringFunc (GL_EXTENSIONS); |
350 this->gl_data->wglSwapIntervalEXT = NULL; | 356 } else { |
351 this->gl_data->wglGetSwapIntervalEXT = NULL; | 357 /* Uh oh, something is seriously wrong here... */ |
352 } | 358 wglext = NULL; |
353 if ( this->gl_config.swap_control >= 0 ) { | 359 } |
354 if ( this->gl_data->wglSwapIntervalEXT ) { | 360 if (!wglext || !SDL_strstr (wglext, "WGL_EXT_swap_control")) { |
355 this->gl_data->wglSwapIntervalEXT(this->gl_config.swap_control); | 361 this->gl_data->wglSwapIntervalEXT = NULL; |
356 } | 362 this->gl_data->wglGetSwapIntervalEXT = NULL; |
357 } | 363 } |
364 if (this->gl_config.swap_control >= 0) { | |
365 if (this->gl_data->wglSwapIntervalEXT) { | |
366 this->gl_data->wglSwapIntervalEXT (this->gl_config.swap_control); | |
367 } | |
368 } | |
358 #else | 369 #else |
359 SDL_SetError("WIN driver not configured with OpenGL"); | 370 SDL_SetError ("WIN driver not configured with OpenGL"); |
360 #endif | 371 #endif |
361 if ( gl_active ) { | 372 if (gl_active) { |
362 retval = 0; | 373 retval = 0; |
363 } else { | 374 } else { |
364 retval = -1; | 375 retval = -1; |
365 } | 376 } |
366 return(retval); | 377 return (retval); |
367 } | 378 } |
368 | 379 |
369 void WIN_GL_ShutDown(_THIS) | 380 void |
381 WIN_GL_ShutDown (_THIS) | |
370 { | 382 { |
371 #if SDL_VIDEO_OPENGL | 383 #if SDL_VIDEO_OPENGL |
372 /* Clean up OpenGL */ | 384 /* Clean up OpenGL */ |
373 if ( GL_hrc ) { | 385 if (GL_hrc) { |
374 this->gl_data->wglMakeCurrent(NULL, NULL); | 386 this->gl_data->wglMakeCurrent (NULL, NULL); |
375 this->gl_data->wglDeleteContext(GL_hrc); | 387 this->gl_data->wglDeleteContext (GL_hrc); |
376 GL_hrc = NULL; | 388 GL_hrc = NULL; |
377 } | 389 } |
378 if ( GL_hdc ) { | 390 if (GL_hdc) { |
379 ReleaseDC(SDL_Window, GL_hdc); | 391 ReleaseDC (SDL_Window, GL_hdc); |
380 GL_hdc = NULL; | 392 GL_hdc = NULL; |
381 } | 393 } |
382 gl_active = 0; | 394 gl_active = 0; |
383 | 395 |
384 WIN_GL_UnloadLibrary(this); | 396 WIN_GL_UnloadLibrary (this); |
385 #endif /* SDL_VIDEO_OPENGL */ | 397 #endif /* SDL_VIDEO_OPENGL */ |
386 } | 398 } |
387 | 399 |
388 #if SDL_VIDEO_OPENGL | 400 #if SDL_VIDEO_OPENGL |
389 | 401 |
390 /* Make the current context active */ | 402 /* Make the current context active */ |
391 int WIN_GL_MakeCurrent(_THIS) | 403 int |
392 { | 404 WIN_GL_MakeCurrent (_THIS) |
393 int retval; | 405 { |
394 | 406 int retval; |
395 retval = 0; | 407 |
396 if ( ! this->gl_data->wglMakeCurrent(GL_hdc, GL_hrc) ) { | 408 retval = 0; |
397 SDL_SetError("Unable to make GL context current"); | 409 if (!this->gl_data->wglMakeCurrent (GL_hdc, GL_hrc)) { |
398 retval = -1; | 410 SDL_SetError ("Unable to make GL context current"); |
399 } | 411 retval = -1; |
400 return(retval); | 412 } |
413 return (retval); | |
401 } | 414 } |
402 | 415 |
403 /* Get attribute data from glX. */ | 416 /* Get attribute data from glX. */ |
404 int WIN_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) | 417 int |
405 { | 418 WIN_GL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) |
406 int retval; | 419 { |
407 | 420 int retval; |
408 if ( this->gl_data->WGL_ARB_pixel_format ) { | 421 |
409 int wgl_attrib; | 422 if (this->gl_data->WGL_ARB_pixel_format) { |
410 | 423 int wgl_attrib; |
411 switch(attrib) { | 424 |
412 case SDL_GL_RED_SIZE: | 425 switch (attrib) { |
413 wgl_attrib = WGL_RED_BITS_ARB; | 426 case SDL_GL_RED_SIZE: |
414 break; | 427 wgl_attrib = WGL_RED_BITS_ARB; |
415 case SDL_GL_GREEN_SIZE: | 428 break; |
416 wgl_attrib = WGL_GREEN_BITS_ARB; | 429 case SDL_GL_GREEN_SIZE: |
417 break; | 430 wgl_attrib = WGL_GREEN_BITS_ARB; |
418 case SDL_GL_BLUE_SIZE: | 431 break; |
419 wgl_attrib = WGL_BLUE_BITS_ARB; | 432 case SDL_GL_BLUE_SIZE: |
420 break; | 433 wgl_attrib = WGL_BLUE_BITS_ARB; |
421 case SDL_GL_ALPHA_SIZE: | 434 break; |
422 wgl_attrib = WGL_ALPHA_BITS_ARB; | 435 case SDL_GL_ALPHA_SIZE: |
423 break; | 436 wgl_attrib = WGL_ALPHA_BITS_ARB; |
424 case SDL_GL_DOUBLEBUFFER: | 437 break; |
425 wgl_attrib = WGL_DOUBLE_BUFFER_ARB; | 438 case SDL_GL_DOUBLEBUFFER: |
426 break; | 439 wgl_attrib = WGL_DOUBLE_BUFFER_ARB; |
427 case SDL_GL_BUFFER_SIZE: | 440 break; |
428 wgl_attrib = WGL_COLOR_BITS_ARB; | 441 case SDL_GL_BUFFER_SIZE: |
429 break; | 442 wgl_attrib = WGL_COLOR_BITS_ARB; |
430 case SDL_GL_DEPTH_SIZE: | 443 break; |
431 wgl_attrib = WGL_DEPTH_BITS_ARB; | 444 case SDL_GL_DEPTH_SIZE: |
432 break; | 445 wgl_attrib = WGL_DEPTH_BITS_ARB; |
433 case SDL_GL_STENCIL_SIZE: | 446 break; |
434 wgl_attrib = WGL_STENCIL_BITS_ARB; | 447 case SDL_GL_STENCIL_SIZE: |
435 break; | 448 wgl_attrib = WGL_STENCIL_BITS_ARB; |
436 case SDL_GL_ACCUM_RED_SIZE: | 449 break; |
437 wgl_attrib = WGL_ACCUM_RED_BITS_ARB; | 450 case SDL_GL_ACCUM_RED_SIZE: |
438 break; | 451 wgl_attrib = WGL_ACCUM_RED_BITS_ARB; |
439 case SDL_GL_ACCUM_GREEN_SIZE: | 452 break; |
440 wgl_attrib = WGL_ACCUM_GREEN_BITS_ARB; | 453 case SDL_GL_ACCUM_GREEN_SIZE: |
441 break; | 454 wgl_attrib = WGL_ACCUM_GREEN_BITS_ARB; |
442 case SDL_GL_ACCUM_BLUE_SIZE: | 455 break; |
443 wgl_attrib = WGL_ACCUM_BLUE_BITS_ARB; | 456 case SDL_GL_ACCUM_BLUE_SIZE: |
444 break; | 457 wgl_attrib = WGL_ACCUM_BLUE_BITS_ARB; |
445 case SDL_GL_ACCUM_ALPHA_SIZE: | 458 break; |
446 wgl_attrib = WGL_ACCUM_ALPHA_BITS_ARB; | 459 case SDL_GL_ACCUM_ALPHA_SIZE: |
447 break; | 460 wgl_attrib = WGL_ACCUM_ALPHA_BITS_ARB; |
448 case SDL_GL_STEREO: | 461 break; |
449 wgl_attrib = WGL_STEREO_ARB; | 462 case SDL_GL_STEREO: |
450 break; | 463 wgl_attrib = WGL_STEREO_ARB; |
451 case SDL_GL_MULTISAMPLEBUFFERS: | 464 break; |
452 wgl_attrib = WGL_SAMPLE_BUFFERS_ARB; | 465 case SDL_GL_MULTISAMPLEBUFFERS: |
453 break; | 466 wgl_attrib = WGL_SAMPLE_BUFFERS_ARB; |
454 case SDL_GL_MULTISAMPLESAMPLES: | 467 break; |
455 wgl_attrib = WGL_SAMPLES_ARB; | 468 case SDL_GL_MULTISAMPLESAMPLES: |
456 break; | 469 wgl_attrib = WGL_SAMPLES_ARB; |
457 case SDL_GL_ACCELERATED_VISUAL: | 470 break; |
458 wgl_attrib = WGL_ACCELERATION_ARB; | 471 case SDL_GL_ACCELERATED_VISUAL: |
459 this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0, 1, &wgl_attrib, value); | 472 wgl_attrib = WGL_ACCELERATION_ARB; |
460 if ( *value == WGL_NO_ACCELERATION_ARB ) { | 473 this->gl_data->wglGetPixelFormatAttribivARB (GL_hdc, |
461 *value = SDL_FALSE; | 474 pixel_format, 0, |
462 } else { | 475 1, &wgl_attrib, |
463 *value = SDL_TRUE; | 476 value); |
464 } | 477 if (*value == WGL_NO_ACCELERATION_ARB) { |
465 return 0; | 478 *value = SDL_FALSE; |
466 break; | 479 } else { |
467 case SDL_GL_SWAP_CONTROL: | 480 *value = SDL_TRUE; |
468 if ( this->gl_data->wglGetSwapIntervalEXT ) { | 481 } |
469 return this->gl_data->wglGetSwapIntervalEXT(); | 482 return 0; |
470 } else { | 483 break; |
471 return -1; | 484 case SDL_GL_SWAP_CONTROL: |
472 } | 485 if (this->gl_data->wglGetSwapIntervalEXT) { |
473 default: | 486 return this->gl_data->wglGetSwapIntervalEXT (); |
474 return(-1); | 487 } else { |
475 } | 488 return -1; |
476 this->gl_data->wglGetPixelFormatAttribivARB(GL_hdc, pixel_format, 0, 1, &wgl_attrib, value); | 489 } |
477 | 490 default: |
478 return 0; | 491 return (-1); |
479 } | 492 } |
480 | 493 this->gl_data->wglGetPixelFormatAttribivARB (GL_hdc, pixel_format, |
481 retval = 0; | 494 0, 1, &wgl_attrib, |
482 switch ( attrib ) { | 495 value); |
483 case SDL_GL_RED_SIZE: | 496 |
484 *value = GL_pfd.cRedBits; | 497 return 0; |
485 break; | 498 } |
486 case SDL_GL_GREEN_SIZE: | 499 |
487 *value = GL_pfd.cGreenBits; | 500 retval = 0; |
488 break; | 501 switch (attrib) { |
489 case SDL_GL_BLUE_SIZE: | 502 case SDL_GL_RED_SIZE: |
490 *value = GL_pfd.cBlueBits; | 503 *value = GL_pfd.cRedBits; |
491 break; | 504 break; |
492 case SDL_GL_ALPHA_SIZE: | 505 case SDL_GL_GREEN_SIZE: |
493 *value = GL_pfd.cAlphaBits; | 506 *value = GL_pfd.cGreenBits; |
494 break; | 507 break; |
495 case SDL_GL_DOUBLEBUFFER: | 508 case SDL_GL_BLUE_SIZE: |
496 if ( GL_pfd.dwFlags & PFD_DOUBLEBUFFER ) { | 509 *value = GL_pfd.cBlueBits; |
497 *value = 1; | 510 break; |
498 } else { | 511 case SDL_GL_ALPHA_SIZE: |
499 *value = 0; | 512 *value = GL_pfd.cAlphaBits; |
500 } | 513 break; |
501 break; | 514 case SDL_GL_DOUBLEBUFFER: |
502 case SDL_GL_BUFFER_SIZE: | 515 if (GL_pfd.dwFlags & PFD_DOUBLEBUFFER) { |
503 *value = GL_pfd.cColorBits; | 516 *value = 1; |
504 break; | 517 } else { |
505 case SDL_GL_DEPTH_SIZE: | 518 *value = 0; |
506 *value = GL_pfd.cDepthBits; | 519 } |
507 break; | 520 break; |
508 case SDL_GL_STENCIL_SIZE: | 521 case SDL_GL_BUFFER_SIZE: |
509 *value = GL_pfd.cStencilBits; | 522 *value = GL_pfd.cColorBits; |
510 break; | 523 break; |
511 case SDL_GL_ACCUM_RED_SIZE: | 524 case SDL_GL_DEPTH_SIZE: |
512 *value = GL_pfd.cAccumRedBits; | 525 *value = GL_pfd.cDepthBits; |
513 break; | 526 break; |
514 case SDL_GL_ACCUM_GREEN_SIZE: | 527 case SDL_GL_STENCIL_SIZE: |
515 *value = GL_pfd.cAccumGreenBits; | 528 *value = GL_pfd.cStencilBits; |
516 break; | 529 break; |
517 case SDL_GL_ACCUM_BLUE_SIZE: | 530 case SDL_GL_ACCUM_RED_SIZE: |
518 *value = GL_pfd.cAccumBlueBits; | 531 *value = GL_pfd.cAccumRedBits; |
519 break; | 532 break; |
520 case SDL_GL_ACCUM_ALPHA_SIZE: | 533 case SDL_GL_ACCUM_GREEN_SIZE: |
521 *value = GL_pfd.cAccumAlphaBits; | 534 *value = GL_pfd.cAccumGreenBits; |
522 break; | 535 break; |
523 case SDL_GL_STEREO: | 536 case SDL_GL_ACCUM_BLUE_SIZE: |
524 if ( GL_pfd.dwFlags & PFD_STEREO ) { | 537 *value = GL_pfd.cAccumBlueBits; |
525 *value = 1; | 538 break; |
526 } else { | 539 case SDL_GL_ACCUM_ALPHA_SIZE: |
527 *value = 0; | 540 *value = GL_pfd.cAccumAlphaBits; |
528 } | 541 break; |
529 break; | 542 case SDL_GL_STEREO: |
530 case SDL_GL_MULTISAMPLEBUFFERS: | 543 if (GL_pfd.dwFlags & PFD_STEREO) { |
531 *value = 0; | 544 *value = 1; |
532 break; | 545 } else { |
533 case SDL_GL_MULTISAMPLESAMPLES: | 546 *value = 0; |
534 *value = 1; | 547 } |
535 break; | 548 break; |
536 default: | 549 case SDL_GL_MULTISAMPLEBUFFERS: |
537 retval = -1; | 550 *value = 0; |
538 break; | 551 break; |
539 } | 552 case SDL_GL_MULTISAMPLESAMPLES: |
540 return retval; | 553 *value = 1; |
541 } | 554 break; |
542 | 555 default: |
543 void WIN_GL_SwapBuffers(_THIS) | 556 retval = -1; |
544 { | 557 break; |
545 SwapBuffers(GL_hdc); | 558 } |
546 } | 559 return retval; |
547 | 560 } |
548 void WIN_GL_UnloadLibrary(_THIS) | 561 |
549 { | 562 void |
550 if ( this->gl_config.driver_loaded ) { | 563 WIN_GL_SwapBuffers (_THIS) |
551 FreeLibrary((HMODULE)this->gl_config.dll_handle); | 564 { |
552 | 565 SwapBuffers (GL_hdc); |
553 this->gl_data->wglGetProcAddress = NULL; | 566 } |
554 this->gl_data->wglCreateContext = NULL; | 567 |
555 this->gl_data->wglDeleteContext = NULL; | 568 void |
556 this->gl_data->wglMakeCurrent = NULL; | 569 WIN_GL_UnloadLibrary (_THIS) |
557 this->gl_data->wglChoosePixelFormatARB = NULL; | 570 { |
558 this->gl_data->wglGetPixelFormatAttribivARB = NULL; | 571 if (this->gl_config.driver_loaded) { |
559 this->gl_data->wglSwapIntervalEXT = NULL; | 572 FreeLibrary ((HMODULE) this->gl_config.dll_handle); |
560 this->gl_data->wglGetSwapIntervalEXT = NULL; | 573 |
561 | 574 this->gl_data->wglGetProcAddress = NULL; |
562 this->gl_config.dll_handle = NULL; | 575 this->gl_data->wglCreateContext = NULL; |
563 this->gl_config.driver_loaded = 0; | 576 this->gl_data->wglDeleteContext = NULL; |
564 } | 577 this->gl_data->wglMakeCurrent = NULL; |
578 this->gl_data->wglChoosePixelFormatARB = NULL; | |
579 this->gl_data->wglGetPixelFormatAttribivARB = NULL; | |
580 this->gl_data->wglSwapIntervalEXT = NULL; | |
581 this->gl_data->wglGetSwapIntervalEXT = NULL; | |
582 | |
583 this->gl_config.dll_handle = NULL; | |
584 this->gl_config.driver_loaded = 0; | |
585 } | |
565 } | 586 } |
566 | 587 |
567 /* Passing a NULL path means load pointers from the application */ | 588 /* Passing a NULL path means load pointers from the application */ |
568 int WIN_GL_LoadLibrary(_THIS, const char* path) | 589 int |
569 { | 590 WIN_GL_LoadLibrary (_THIS, const char *path) |
570 HMODULE handle; | 591 { |
571 | 592 HMODULE handle; |
572 if ( gl_active ) { | 593 |
573 SDL_SetError("OpenGL context already created"); | 594 if (gl_active) { |
574 return -1; | 595 SDL_SetError ("OpenGL context already created"); |
575 } | 596 return -1; |
576 | 597 } |
577 if ( path == NULL ) { | 598 |
578 path = DEFAULT_GL_DRIVER_PATH; | 599 if (path == NULL) { |
579 } | 600 path = DEFAULT_GL_DRIVER_PATH; |
580 handle = LoadLibrary(path); | 601 } |
581 if ( handle == NULL ) { | 602 handle = LoadLibrary (path); |
582 SDL_SetError("Could not load OpenGL library"); | 603 if (handle == NULL) { |
583 return -1; | 604 SDL_SetError ("Could not load OpenGL library"); |
584 } | 605 return -1; |
585 | 606 } |
586 /* Unload the old driver and reset the pointers */ | 607 |
587 WIN_GL_UnloadLibrary(this); | 608 /* Unload the old driver and reset the pointers */ |
588 | 609 WIN_GL_UnloadLibrary (this); |
589 /* Load new function pointers */ | 610 |
590 SDL_memset(this->gl_data, 0, sizeof(*this->gl_data)); | 611 /* Load new function pointers */ |
591 this->gl_data->wglGetProcAddress = (void * (WINAPI *)(const char *)) | 612 SDL_memset (this->gl_data, 0, sizeof (*this->gl_data)); |
592 GetProcAddress(handle, "wglGetProcAddress"); | 613 this->gl_data->wglGetProcAddress = (void *(WINAPI *) (const char *)) |
593 this->gl_data->wglCreateContext = (HGLRC (WINAPI *)(HDC)) | 614 GetProcAddress (handle, "wglGetProcAddress"); |
594 GetProcAddress(handle, "wglCreateContext"); | 615 this->gl_data->wglCreateContext = (HGLRC (WINAPI *) (HDC)) |
595 this->gl_data->wglDeleteContext = (BOOL (WINAPI *)(HGLRC)) | 616 GetProcAddress (handle, "wglCreateContext"); |
596 GetProcAddress(handle, "wglDeleteContext"); | 617 this->gl_data->wglDeleteContext = (BOOL (WINAPI *) (HGLRC)) |
597 this->gl_data->wglMakeCurrent = (BOOL (WINAPI *)(HDC, HGLRC)) | 618 GetProcAddress (handle, "wglDeleteContext"); |
598 GetProcAddress(handle, "wglMakeCurrent"); | 619 this->gl_data->wglMakeCurrent = (BOOL (WINAPI *) (HDC, HGLRC)) |
599 this->gl_data->wglSwapIntervalEXT = (void (WINAPI *)(int)) | 620 GetProcAddress (handle, "wglMakeCurrent"); |
600 GetProcAddress(handle, "wglSwapIntervalEXT"); | 621 this->gl_data->wglSwapIntervalEXT = (void (WINAPI *) (int)) |
601 this->gl_data->wglGetSwapIntervalEXT = (int (WINAPI *)(void)) | 622 GetProcAddress (handle, "wglSwapIntervalEXT"); |
602 GetProcAddress(handle, "wglGetSwapIntervalEXT"); | 623 this->gl_data->wglGetSwapIntervalEXT = (int (WINAPI *) (void)) |
603 | 624 GetProcAddress (handle, "wglGetSwapIntervalEXT"); |
604 if ( (this->gl_data->wglGetProcAddress == NULL) || | 625 |
605 (this->gl_data->wglCreateContext == NULL) || | 626 if ((this->gl_data->wglGetProcAddress == NULL) || |
606 (this->gl_data->wglDeleteContext == NULL) || | 627 (this->gl_data->wglCreateContext == NULL) || |
607 (this->gl_data->wglMakeCurrent == NULL) ) { | 628 (this->gl_data->wglDeleteContext == NULL) || |
608 SDL_SetError("Could not retrieve OpenGL functions"); | 629 (this->gl_data->wglMakeCurrent == NULL)) { |
609 FreeLibrary(handle); | 630 SDL_SetError ("Could not retrieve OpenGL functions"); |
610 return -1; | 631 FreeLibrary (handle); |
611 } | 632 return -1; |
612 | 633 } |
613 this->gl_config.dll_handle = handle; | 634 |
614 SDL_strlcpy(this->gl_config.driver_path, path, SDL_arraysize(this->gl_config.driver_path)); | 635 this->gl_config.dll_handle = handle; |
615 this->gl_config.driver_loaded = 1; | 636 SDL_strlcpy (this->gl_config.driver_path, path, |
616 return 0; | 637 SDL_arraysize (this->gl_config.driver_path)); |
617 } | 638 this->gl_config.driver_loaded = 1; |
618 | 639 return 0; |
619 void *WIN_GL_GetProcAddress(_THIS, const char* proc) | 640 } |
620 { | 641 |
621 void *func; | 642 void * |
622 | 643 WIN_GL_GetProcAddress (_THIS, const char *proc) |
623 /* This is to pick up extensions */ | 644 { |
624 func = this->gl_data->wglGetProcAddress(proc); | 645 void *func; |
625 if ( ! func ) { | 646 |
626 /* This is probably a normal GL function */ | 647 /* This is to pick up extensions */ |
627 func = GetProcAddress(this->gl_config.dll_handle, proc); | 648 func = this->gl_data->wglGetProcAddress (proc); |
628 } | 649 if (!func) { |
629 return func; | 650 /* This is probably a normal GL function */ |
651 func = GetProcAddress (this->gl_config.dll_handle, proc); | |
652 } | |
653 return func; | |
630 } | 654 } |
631 | 655 |
632 #endif /* SDL_VIDEO_OPENGL */ | 656 #endif /* SDL_VIDEO_OPENGL */ |
657 /* vi: set ts=4 sw=4 expandtab: */ |