Mercurial > sdl-ios-xcode
comparison src/video/ataricommon/SDL_atarigl.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 |
---|---|
46 | 46 |
47 #define VDI_RGB 0xf | 47 #define VDI_RGB 0xf |
48 | 48 |
49 /*--- Functions prototypes ---*/ | 49 /*--- Functions prototypes ---*/ |
50 | 50 |
51 static void SDL_AtariGL_UnloadLibrary (_THIS); | 51 static void SDL_AtariGL_UnloadLibrary(_THIS); |
52 | 52 |
53 #if SDL_VIDEO_OPENGL | 53 #if SDL_VIDEO_OPENGL |
54 static void CopyShadowNull (_THIS, SDL_Surface * surface); | 54 static void CopyShadowNull(_THIS, SDL_Surface * surface); |
55 static void CopyShadowDirect (_THIS, SDL_Surface * surface); | 55 static void CopyShadowDirect(_THIS, SDL_Surface * surface); |
56 static void CopyShadowRGBTo555 (_THIS, SDL_Surface * surface); | 56 static void CopyShadowRGBTo555(_THIS, SDL_Surface * surface); |
57 static void CopyShadowRGBTo565 (_THIS, SDL_Surface * surface); | 57 static void CopyShadowRGBTo565(_THIS, SDL_Surface * surface); |
58 static void CopyShadowRGBSwap (_THIS, SDL_Surface * surface); | 58 static void CopyShadowRGBSwap(_THIS, SDL_Surface * surface); |
59 static void CopyShadowRGBToARGB (_THIS, SDL_Surface * surface); | 59 static void CopyShadowRGBToARGB(_THIS, SDL_Surface * surface); |
60 static void CopyShadowRGBToABGR (_THIS, SDL_Surface * surface); | 60 static void CopyShadowRGBToABGR(_THIS, SDL_Surface * surface); |
61 static void CopyShadowRGBToBGRA (_THIS, SDL_Surface * surface); | 61 static void CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface); |
62 static void CopyShadowRGBToRGBA (_THIS, SDL_Surface * surface); | 62 static void CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface); |
63 static void CopyShadow8888To555 (_THIS, SDL_Surface * surface); | 63 static void CopyShadow8888To555(_THIS, SDL_Surface * surface); |
64 static void CopyShadow8888To565 (_THIS, SDL_Surface * surface); | 64 static void CopyShadow8888To565(_THIS, SDL_Surface * surface); |
65 | 65 |
66 static void ConvertNull (_THIS, SDL_Surface * surface); | 66 static void ConvertNull(_THIS, SDL_Surface * surface); |
67 static void Convert565To555be (_THIS, SDL_Surface * surface); | 67 static void Convert565To555be(_THIS, SDL_Surface * surface); |
68 static void Convert565To555le (_THIS, SDL_Surface * surface); | 68 static void Convert565To555le(_THIS, SDL_Surface * surface); |
69 static void Convert565le (_THIS, SDL_Surface * surface); | 69 static void Convert565le(_THIS, SDL_Surface * surface); |
70 static void ConvertBGRAToABGR (_THIS, SDL_Surface * surface); | 70 static void ConvertBGRAToABGR(_THIS, SDL_Surface * surface); |
71 | 71 |
72 static int InitNew (_THIS, SDL_Surface * current); | 72 static int InitNew(_THIS, SDL_Surface * current); |
73 static int InitOld (_THIS, SDL_Surface * current); | 73 static int InitOld(_THIS, SDL_Surface * current); |
74 #endif | 74 #endif |
75 | 75 |
76 /*--- Public functions ---*/ | 76 /*--- Public functions ---*/ |
77 | 77 |
78 int | 78 int |
79 SDL_AtariGL_Init (_THIS, SDL_Surface * current) | 79 SDL_AtariGL_Init(_THIS, SDL_Surface * current) |
80 { | 80 { |
81 #if SDL_VIDEO_OPENGL | 81 #if SDL_VIDEO_OPENGL |
82 if (gl_oldmesa) { | 82 if (gl_oldmesa) { |
83 gl_active = InitOld (this, current); | 83 gl_active = InitOld(this, current); |
84 } else { | 84 } else { |
85 gl_active = InitNew (this, current); | 85 gl_active = InitNew(this, current); |
86 } | 86 } |
87 #endif | 87 #endif |
88 | 88 |
89 return (gl_active); | 89 return (gl_active); |
90 } | 90 } |
91 | 91 |
92 void | 92 void |
93 SDL_AtariGL_Quit (_THIS, SDL_bool unload) | 93 SDL_AtariGL_Quit(_THIS, SDL_bool unload) |
94 { | 94 { |
95 #if SDL_VIDEO_OPENGL | 95 #if SDL_VIDEO_OPENGL |
96 if (gl_oldmesa) { | 96 if (gl_oldmesa) { |
97 /* Old mesa implementations */ | 97 /* Old mesa implementations */ |
98 if (this->gl_data->OSMesaDestroyLDG) { | 98 if (this->gl_data->OSMesaDestroyLDG) { |
99 this->gl_data->OSMesaDestroyLDG (); | 99 this->gl_data->OSMesaDestroyLDG(); |
100 } | 100 } |
101 if (gl_shadow) { | 101 if (gl_shadow) { |
102 Mfree (gl_shadow); | 102 Mfree(gl_shadow); |
103 gl_shadow = NULL; | 103 gl_shadow = NULL; |
104 } | 104 } |
105 } else { | 105 } else { |
106 /* New mesa implementation */ | 106 /* New mesa implementation */ |
107 if (gl_ctx) { | 107 if (gl_ctx) { |
108 if (this->gl_data->OSMesaDestroyContext) { | 108 if (this->gl_data->OSMesaDestroyContext) { |
109 this->gl_data->OSMesaDestroyContext (gl_ctx); | 109 this->gl_data->OSMesaDestroyContext(gl_ctx); |
110 } | 110 } |
111 gl_ctx = NULL; | 111 gl_ctx = NULL; |
112 } | 112 } |
113 } | 113 } |
114 | 114 |
115 if (unload) { | 115 if (unload) { |
116 SDL_AtariGL_UnloadLibrary (this); | 116 SDL_AtariGL_UnloadLibrary(this); |
117 } | 117 } |
118 #endif /* SDL_VIDEO_OPENGL */ | 118 #endif /* SDL_VIDEO_OPENGL */ |
119 gl_active = 0; | 119 gl_active = 0; |
120 } | 120 } |
121 | 121 |
122 int | 122 int |
123 SDL_AtariGL_LoadLibrary (_THIS, const char *path) | 123 SDL_AtariGL_LoadLibrary(_THIS, const char *path) |
124 { | 124 { |
125 #if SDL_VIDEO_OPENGL | 125 #if SDL_VIDEO_OPENGL |
126 | 126 |
127 #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC | 127 #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC |
128 void *handle; | 128 void *handle; |
129 SDL_bool cancel_load; | 129 SDL_bool cancel_load; |
130 | 130 |
131 if (gl_active) { | 131 if (gl_active) { |
132 SDL_SetError ("OpenGL context already created"); | 132 SDL_SetError("OpenGL context already created"); |
133 return -1; | 133 return -1; |
134 } | 134 } |
135 | 135 |
136 /* Unload previous driver */ | 136 /* Unload previous driver */ |
137 SDL_AtariGL_UnloadLibrary (this); | 137 SDL_AtariGL_UnloadLibrary(this); |
138 | 138 |
139 /* Load library given by path */ | 139 /* Load library given by path */ |
140 handle = SDL_LoadObject (path); | 140 handle = SDL_LoadObject(path); |
141 if (handle == NULL) { | 141 if (handle == NULL) { |
142 /* Try to load another one */ | 142 /* Try to load another one */ |
143 path = SDL_getenv ("SDL_VIDEO_GL_DRIVER"); | 143 path = SDL_getenv("SDL_VIDEO_GL_DRIVER"); |
144 if (path != NULL) { | 144 if (path != NULL) { |
145 handle = SDL_LoadObject (path); | 145 handle = SDL_LoadObject(path); |
146 } | 146 } |
147 | 147 |
148 /* If it does not work, try some other */ | 148 /* If it does not work, try some other */ |
149 if (handle == NULL) { | 149 if (handle == NULL) { |
150 path = PATH_OSMESA_LDG; | 150 path = PATH_OSMESA_LDG; |
151 handle = SDL_LoadObject (path); | 151 handle = SDL_LoadObject(path); |
152 } | 152 } |
153 | 153 |
154 if (handle == NULL) { | 154 if (handle == NULL) { |
155 path = PATH_MESAGL_LDG; | 155 path = PATH_MESAGL_LDG; |
156 handle = SDL_LoadObject (path); | 156 handle = SDL_LoadObject(path); |
157 } | 157 } |
158 | 158 |
159 if (handle == NULL) { | 159 if (handle == NULL) { |
160 path = PATH_TINYGL_LDG; | 160 path = PATH_TINYGL_LDG; |
161 handle = SDL_LoadObject (path); | 161 handle = SDL_LoadObject(path); |
162 } | 162 } |
163 } | 163 } |
164 | 164 |
165 if (handle == NULL) { | 165 if (handle == NULL) { |
166 SDL_SetError ("Could not load OpenGL library"); | 166 SDL_SetError("Could not load OpenGL library"); |
167 return -1; | 167 return -1; |
168 } | 168 } |
169 | 169 |
170 this->gl_data->glGetIntegerv = SDL_LoadFunction (handle, "glGetIntegerv"); | 170 this->gl_data->glGetIntegerv = SDL_LoadFunction(handle, "glGetIntegerv"); |
171 this->gl_data->glFinish = SDL_LoadFunction (handle, "glFinish"); | 171 this->gl_data->glFinish = SDL_LoadFunction(handle, "glFinish"); |
172 this->gl_data->glFlush = SDL_LoadFunction (handle, "glFlush"); | 172 this->gl_data->glFlush = SDL_LoadFunction(handle, "glFlush"); |
173 | 173 |
174 cancel_load = SDL_FALSE; | 174 cancel_load = SDL_FALSE; |
175 if (this->gl_data->glGetIntegerv == NULL) { | 175 if (this->gl_data->glGetIntegerv == NULL) { |
176 cancel_load = SDL_TRUE; | 176 cancel_load = SDL_TRUE; |
177 } else { | 177 } else { |
180 (this->gl_data->glFlush == NULL)) { | 180 (this->gl_data->glFlush == NULL)) { |
181 cancel_load = SDL_TRUE; | 181 cancel_load = SDL_TRUE; |
182 } | 182 } |
183 } | 183 } |
184 if (cancel_load) { | 184 if (cancel_load) { |
185 SDL_SetError ("Could not retrieve OpenGL functions"); | 185 SDL_SetError("Could not retrieve OpenGL functions"); |
186 SDL_UnloadObject (handle); | 186 SDL_UnloadObject(handle); |
187 /* Restore pointers to static library */ | 187 /* Restore pointers to static library */ |
188 SDL_AtariGL_InitPointers (this); | 188 SDL_AtariGL_InitPointers(this); |
189 return -1; | 189 return -1; |
190 } | 190 } |
191 | 191 |
192 /* Load functions pointers (osmesa.ldg) */ | 192 /* Load functions pointers (osmesa.ldg) */ |
193 this->gl_data->OSMesaCreateContextExt = | 193 this->gl_data->OSMesaCreateContextExt = |
194 SDL_LoadFunction (handle, "OSMesaCreateContextExt"); | 194 SDL_LoadFunction(handle, "OSMesaCreateContextExt"); |
195 this->gl_data->OSMesaDestroyContext = | 195 this->gl_data->OSMesaDestroyContext = |
196 SDL_LoadFunction (handle, "OSMesaDestroyContext"); | 196 SDL_LoadFunction(handle, "OSMesaDestroyContext"); |
197 this->gl_data->OSMesaMakeCurrent = | 197 this->gl_data->OSMesaMakeCurrent = |
198 SDL_LoadFunction (handle, "OSMesaMakeCurrent"); | 198 SDL_LoadFunction(handle, "OSMesaMakeCurrent"); |
199 this->gl_data->OSMesaPixelStore = | 199 this->gl_data->OSMesaPixelStore = |
200 SDL_LoadFunction (handle, "OSMesaPixelStore"); | 200 SDL_LoadFunction(handle, "OSMesaPixelStore"); |
201 this->gl_data->OSMesaGetProcAddress = | 201 this->gl_data->OSMesaGetProcAddress = |
202 SDL_LoadFunction (handle, "OSMesaGetProcAddress"); | 202 SDL_LoadFunction(handle, "OSMesaGetProcAddress"); |
203 | 203 |
204 /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */ | 204 /* Load old functions pointers (mesa_gl.ldg, tiny_gl.ldg) */ |
205 this->gl_data->OSMesaCreateLDG = | 205 this->gl_data->OSMesaCreateLDG = |
206 SDL_LoadFunction (handle, "OSMesaCreateLDG"); | 206 SDL_LoadFunction(handle, "OSMesaCreateLDG"); |
207 this->gl_data->OSMesaDestroyLDG = | 207 this->gl_data->OSMesaDestroyLDG = |
208 SDL_LoadFunction (handle, "OSMesaDestroyLDG"); | 208 SDL_LoadFunction(handle, "OSMesaDestroyLDG"); |
209 | 209 |
210 gl_oldmesa = 0; | 210 gl_oldmesa = 0; |
211 | 211 |
212 if ((this->gl_data->OSMesaCreateContextExt == NULL) || | 212 if ((this->gl_data->OSMesaCreateContextExt == NULL) || |
213 (this->gl_data->OSMesaDestroyContext == NULL) || | 213 (this->gl_data->OSMesaDestroyContext == NULL) || |
215 (this->gl_data->OSMesaPixelStore == NULL) || | 215 (this->gl_data->OSMesaPixelStore == NULL) || |
216 (this->gl_data->OSMesaGetProcAddress == NULL)) { | 216 (this->gl_data->OSMesaGetProcAddress == NULL)) { |
217 /* Hum, maybe old library ? */ | 217 /* Hum, maybe old library ? */ |
218 if ((this->gl_data->OSMesaCreateLDG == NULL) || | 218 if ((this->gl_data->OSMesaCreateLDG == NULL) || |
219 (this->gl_data->OSMesaDestroyLDG == NULL)) { | 219 (this->gl_data->OSMesaDestroyLDG == NULL)) { |
220 SDL_SetError ("Could not retrieve OSMesa functions"); | 220 SDL_SetError("Could not retrieve OSMesa functions"); |
221 SDL_UnloadObject (handle); | 221 SDL_UnloadObject(handle); |
222 /* Restore pointers to static library */ | 222 /* Restore pointers to static library */ |
223 SDL_AtariGL_InitPointers (this); | 223 SDL_AtariGL_InitPointers(this); |
224 return -1; | 224 return -1; |
225 } else { | 225 } else { |
226 gl_oldmesa = 1; | 226 gl_oldmesa = 1; |
227 } | 227 } |
228 } | 228 } |
229 | 229 |
230 this->gl_config.dll_handle = handle; | 230 this->gl_config.dll_handle = handle; |
231 if (path) { | 231 if (path) { |
232 SDL_strlcpy (this->gl_config.driver_path, path, | 232 SDL_strlcpy(this->gl_config.driver_path, path, |
233 SDL_arraysize (this->gl_config.driver_path)); | 233 SDL_arraysize(this->gl_config.driver_path)); |
234 } else { | 234 } else { |
235 *this->gl_config.driver_path = '\0'; | 235 *this->gl_config.driver_path = '\0'; |
236 } | 236 } |
237 | 237 |
238 #endif | 238 #endif |
243 return -1; | 243 return -1; |
244 #endif | 244 #endif |
245 } | 245 } |
246 | 246 |
247 void * | 247 void * |
248 SDL_AtariGL_GetProcAddress (_THIS, const char *proc) | 248 SDL_AtariGL_GetProcAddress(_THIS, const char *proc) |
249 { | 249 { |
250 void *func = NULL; | 250 void *func = NULL; |
251 #if SDL_VIDEO_OPENGL | 251 #if SDL_VIDEO_OPENGL |
252 | 252 |
253 if (this->gl_config.dll_handle) { | 253 if (this->gl_config.dll_handle) { |
254 func = SDL_LoadFunction (this->gl_config.dll_handle, (void *) proc); | 254 func = SDL_LoadFunction(this->gl_config.dll_handle, (void *) proc); |
255 } else if (this->gl_data->OSMesaGetProcAddress) { | 255 } else if (this->gl_data->OSMesaGetProcAddress) { |
256 func = this->gl_data->OSMesaGetProcAddress (proc); | 256 func = this->gl_data->OSMesaGetProcAddress(proc); |
257 } | 257 } |
258 #endif | 258 #endif |
259 return func; | 259 return func; |
260 } | 260 } |
261 | 261 |
262 int | 262 int |
263 SDL_AtariGL_GetAttribute (_THIS, SDL_GLattr attrib, int *value) | 263 SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int *value) |
264 { | 264 { |
265 #if SDL_VIDEO_OPENGL | 265 #if SDL_VIDEO_OPENGL |
266 GLenum mesa_attrib; | 266 GLenum mesa_attrib; |
267 SDL_Surface *surface; | 267 SDL_Surface *surface; |
268 | 268 |
307 break; | 307 break; |
308 default: | 308 default: |
309 return -1; | 309 return -1; |
310 } | 310 } |
311 | 311 |
312 this->gl_data->glGetIntegerv (mesa_attrib, value); | 312 this->gl_data->glGetIntegerv(mesa_attrib, value); |
313 return 0; | 313 return 0; |
314 #else | 314 #else |
315 return -1; | 315 return -1; |
316 #endif | 316 #endif |
317 } | 317 } |
318 | 318 |
319 int | 319 int |
320 SDL_AtariGL_MakeCurrent (_THIS) | 320 SDL_AtariGL_MakeCurrent(_THIS) |
321 { | 321 { |
322 #if SDL_VIDEO_OPENGL | 322 #if SDL_VIDEO_OPENGL |
323 SDL_Surface *surface; | 323 SDL_Surface *surface; |
324 GLenum type; | 324 GLenum type; |
325 | 325 |
333 return -1; | 333 return -1; |
334 } | 334 } |
335 } | 335 } |
336 | 336 |
337 if (!gl_active) { | 337 if (!gl_active) { |
338 SDL_SetError ("Invalid OpenGL context"); | 338 SDL_SetError("Invalid OpenGL context"); |
339 return -1; | 339 return -1; |
340 } | 340 } |
341 | 341 |
342 surface = this->screen; | 342 surface = this->screen; |
343 | 343 |
348 type = GL_UNSIGNED_BYTE; | 348 type = GL_UNSIGNED_BYTE; |
349 } | 349 } |
350 | 350 |
351 if (! | 351 if (! |
352 (this->gl_data-> | 352 (this->gl_data-> |
353 OSMesaMakeCurrent (gl_ctx, surface->pixels, type, surface->w, | 353 OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w, |
354 surface->h))) { | 354 surface->h))) { |
355 SDL_SetError ("Can not make OpenGL context current"); | 355 SDL_SetError("Can not make OpenGL context current"); |
356 return -1; | 356 return -1; |
357 } | 357 } |
358 | 358 |
359 /* OSMesa draws upside down */ | 359 /* OSMesa draws upside down */ |
360 this->gl_data->OSMesaPixelStore (OSMESA_Y_UP, 0); | 360 this->gl_data->OSMesaPixelStore(OSMESA_Y_UP, 0); |
361 | 361 |
362 return 0; | 362 return 0; |
363 #else | 363 #else |
364 return -1; | 364 return -1; |
365 #endif | 365 #endif |
366 } | 366 } |
367 | 367 |
368 void | 368 void |
369 SDL_AtariGL_SwapBuffers (_THIS) | 369 SDL_AtariGL_SwapBuffers(_THIS) |
370 { | 370 { |
371 #if SDL_VIDEO_OPENGL | 371 #if SDL_VIDEO_OPENGL |
372 if (gl_active) { | 372 if (gl_active) { |
373 if (this->gl_config.dll_handle) { | 373 if (this->gl_config.dll_handle) { |
374 if (this->gl_data->glFinish) { | 374 if (this->gl_data->glFinish) { |
375 this->gl_data->glFinish (); | 375 this->gl_data->glFinish(); |
376 } else if (this->gl_data->glFlush) { | 376 } else if (this->gl_data->glFlush) { |
377 this->gl_data->glFlush (); | 377 this->gl_data->glFlush(); |
378 } | 378 } |
379 } else { | 379 } else { |
380 this->gl_data->glFinish (); | 380 this->gl_data->glFinish(); |
381 } | 381 } |
382 gl_copyshadow (this, this->screen); | 382 gl_copyshadow(this, this->screen); |
383 gl_convert (this, this->screen); | 383 gl_convert(this, this->screen); |
384 } | 384 } |
385 #endif | 385 #endif |
386 } | 386 } |
387 | 387 |
388 void | 388 void |
389 SDL_AtariGL_InitPointers (_THIS) | 389 SDL_AtariGL_InitPointers(_THIS) |
390 { | 390 { |
391 #if SDL_VIDEO_OPENGL | 391 #if SDL_VIDEO_OPENGL |
392 this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; | 392 this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; |
393 this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext; | 393 this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext; |
394 this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; | 394 this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; |
405 } | 405 } |
406 | 406 |
407 /*--- Private functions ---*/ | 407 /*--- Private functions ---*/ |
408 | 408 |
409 static void | 409 static void |
410 SDL_AtariGL_UnloadLibrary (_THIS) | 410 SDL_AtariGL_UnloadLibrary(_THIS) |
411 { | 411 { |
412 #if SDL_VIDEO_OPENGL | 412 #if SDL_VIDEO_OPENGL |
413 if (this->gl_config.dll_handle) { | 413 if (this->gl_config.dll_handle) { |
414 SDL_UnloadObject (this->gl_config.dll_handle); | 414 SDL_UnloadObject(this->gl_config.dll_handle); |
415 this->gl_config.dll_handle = NULL; | 415 this->gl_config.dll_handle = NULL; |
416 | 416 |
417 /* Restore pointers to static library */ | 417 /* Restore pointers to static library */ |
418 SDL_AtariGL_InitPointers (this); | 418 SDL_AtariGL_InitPointers(this); |
419 } | 419 } |
420 #endif | 420 #endif |
421 } | 421 } |
422 | 422 |
423 /*--- Creation of an OpenGL context using new/old functions ---*/ | 423 /*--- Creation of an OpenGL context using new/old functions ---*/ |
424 | 424 |
425 #if SDL_VIDEO_OPENGL | 425 #if SDL_VIDEO_OPENGL |
426 static int | 426 static int |
427 InitNew (_THIS, SDL_Surface * current) | 427 InitNew(_THIS, SDL_Surface * current) |
428 { | 428 { |
429 GLenum osmesa_format; | 429 GLenum osmesa_format; |
430 SDL_PixelFormat *pixel_format; | 430 SDL_PixelFormat *pixel_format; |
431 Uint32 redmask; | 431 Uint32 redmask; |
432 int recreatecontext; | 432 int recreatecontext; |
506 (gl_curstencil == this->gl_config.stencil_size) && | 506 (gl_curstencil == this->gl_config.stencil_size) && |
507 (gl_curaccum == newaccumsize)) { | 507 (gl_curaccum == newaccumsize)) { |
508 recreatecontext = 0; | 508 recreatecontext = 0; |
509 } | 509 } |
510 if (recreatecontext) { | 510 if (recreatecontext) { |
511 SDL_AtariGL_Quit (this, SDL_FALSE); | 511 SDL_AtariGL_Quit(this, SDL_FALSE); |
512 | 512 |
513 gl_ctx = | 513 gl_ctx = |
514 this->gl_data->OSMesaCreateContextExt (osmesa_format, | 514 this->gl_data->OSMesaCreateContextExt(osmesa_format, |
515 this->gl_config. | 515 this->gl_config. |
516 depth_size, | 516 depth_size, |
517 this->gl_config. | 517 this->gl_config. |
518 stencil_size, | 518 stencil_size, |
519 newaccumsize, NULL); | 519 newaccumsize, NULL); |
520 | 520 |
521 if (gl_ctx) { | 521 if (gl_ctx) { |
522 gl_curformat = osmesa_format; | 522 gl_curformat = osmesa_format; |
523 gl_curdepth = this->gl_config.depth_size; | 523 gl_curdepth = this->gl_config.depth_size; |
524 gl_curstencil = this->gl_config.stencil_size; | 524 gl_curstencil = this->gl_config.stencil_size; |
534 return (gl_ctx != NULL); | 534 return (gl_ctx != NULL); |
535 } | 535 } |
536 | 536 |
537 | 537 |
538 static int | 538 static int |
539 InitOld (_THIS, SDL_Surface * current) | 539 InitOld(_THIS, SDL_Surface * current) |
540 { | 540 { |
541 GLenum osmesa_format; | 541 GLenum osmesa_format; |
542 SDL_PixelFormat *pixel_format; | 542 SDL_PixelFormat *pixel_format; |
543 Uint32 redmask; | 543 Uint32 redmask; |
544 int recreatecontext, tinygl_present; | 544 int recreatecontext, tinygl_present; |
656 } | 656 } |
657 } | 657 } |
658 break; | 658 break; |
659 default: | 659 default: |
660 if (tinygl_present) { | 660 if (tinygl_present) { |
661 SDL_AtariGL_Quit (this, SDL_FALSE); | 661 SDL_AtariGL_Quit(this, SDL_FALSE); |
662 return 0; | 662 return 0; |
663 } | 663 } |
664 gl_pixelsize = 1; | 664 gl_pixelsize = 1; |
665 gl_copyshadow = CopyShadowDirect; | 665 gl_copyshadow = CopyShadowDirect; |
666 osmesa_format = OSMESA_COLOR_INDEX; | 666 osmesa_format = OSMESA_COLOR_INDEX; |
673 (gl_curformat == osmesa_format) && | 673 (gl_curformat == osmesa_format) && |
674 (gl_curwidth == current->w) && (gl_curheight == current->h)) { | 674 (gl_curwidth == current->w) && (gl_curheight == current->h)) { |
675 recreatecontext = 0; | 675 recreatecontext = 0; |
676 } | 676 } |
677 if (recreatecontext) { | 677 if (recreatecontext) { |
678 SDL_AtariGL_Quit (this, SDL_FALSE); | 678 SDL_AtariGL_Quit(this, SDL_FALSE); |
679 | 679 |
680 gl_shadow = | 680 gl_shadow = |
681 this->gl_data->OSMesaCreateLDG (osmesa_format, GL_UNSIGNED_BYTE, | 681 this->gl_data->OSMesaCreateLDG(osmesa_format, GL_UNSIGNED_BYTE, |
682 current->w, current->h); | 682 current->w, current->h); |
683 | 683 |
684 if (gl_shadow) { | 684 if (gl_shadow) { |
685 gl_curformat = osmesa_format; | 685 gl_curformat = osmesa_format; |
686 gl_curwidth = current->w; | 686 gl_curwidth = current->w; |
687 gl_curheight = current->h; | 687 gl_curheight = current->h; |
696 } | 696 } |
697 | 697 |
698 /*--- Conversions routines from shadow buffer to the screen ---*/ | 698 /*--- Conversions routines from shadow buffer to the screen ---*/ |
699 | 699 |
700 static void | 700 static void |
701 CopyShadowNull (_THIS, SDL_Surface * surface) | 701 CopyShadowNull(_THIS, SDL_Surface * surface) |
702 { | 702 { |
703 } | 703 } |
704 | 704 |
705 static void | 705 static void |
706 CopyShadowDirect (_THIS, SDL_Surface * surface) | 706 CopyShadowDirect(_THIS, SDL_Surface * surface) |
707 { | 707 { |
708 int y, srcpitch, dstpitch; | 708 int y, srcpitch, dstpitch; |
709 Uint8 *srcline, *dstline; | 709 Uint8 *srcline, *dstline; |
710 | 710 |
711 srcline = gl_shadow; | 711 srcline = gl_shadow; |
716 srcline += (surface->h - 1) * srcpitch; | 716 srcline += (surface->h - 1) * srcpitch; |
717 srcpitch = -srcpitch; | 717 srcpitch = -srcpitch; |
718 } | 718 } |
719 | 719 |
720 for (y = 0; y < surface->h; y++) { | 720 for (y = 0; y < surface->h; y++) { |
721 SDL_memcpy (dstline, srcline, srcpitch); | 721 SDL_memcpy(dstline, srcline, srcpitch); |
722 | 722 |
723 srcline += srcpitch; | 723 srcline += srcpitch; |
724 dstline += dstpitch; | 724 dstline += dstpitch; |
725 } | 725 } |
726 } | 726 } |
727 | 727 |
728 static void | 728 static void |
729 CopyShadowRGBTo555 (_THIS, SDL_Surface * surface) | 729 CopyShadowRGBTo555(_THIS, SDL_Surface * surface) |
730 { | 730 { |
731 int x, y, srcpitch, dstpitch; | 731 int x, y, srcpitch, dstpitch; |
732 Uint16 *dstline, *dstcol; | 732 Uint16 *dstline, *dstcol; |
733 Uint8 *srcline, *srccol; | 733 Uint8 *srcline, *srccol; |
734 | 734 |
757 dstline += dstpitch; | 757 dstline += dstpitch; |
758 } | 758 } |
759 } | 759 } |
760 | 760 |
761 static void | 761 static void |
762 CopyShadowRGBTo565 (_THIS, SDL_Surface * surface) | 762 CopyShadowRGBTo565(_THIS, SDL_Surface * surface) |
763 { | 763 { |
764 int x, y, srcpitch, dstpitch; | 764 int x, y, srcpitch, dstpitch; |
765 Uint16 *dstline, *dstcol; | 765 Uint16 *dstline, *dstcol; |
766 Uint8 *srcline, *srccol; | 766 Uint8 *srcline, *srccol; |
767 | 767 |
791 dstline += dstpitch; | 791 dstline += dstpitch; |
792 } | 792 } |
793 } | 793 } |
794 | 794 |
795 static void | 795 static void |
796 CopyShadowRGBSwap (_THIS, SDL_Surface * surface) | 796 CopyShadowRGBSwap(_THIS, SDL_Surface * surface) |
797 { | 797 { |
798 int x, y, srcpitch, dstpitch; | 798 int x, y, srcpitch, dstpitch; |
799 Uint8 *dstline, *dstcol; | 799 Uint8 *dstline, *dstcol; |
800 Uint8 *srcline, *srccol; | 800 Uint8 *srcline, *srccol; |
801 | 801 |
823 dstline += dstpitch; | 823 dstline += dstpitch; |
824 } | 824 } |
825 } | 825 } |
826 | 826 |
827 static void | 827 static void |
828 CopyShadowRGBToARGB (_THIS, SDL_Surface * surface) | 828 CopyShadowRGBToARGB(_THIS, SDL_Surface * surface) |
829 { | 829 { |
830 int x, y, srcpitch, dstpitch; | 830 int x, y, srcpitch, dstpitch; |
831 Uint32 *dstline, *dstcol; | 831 Uint32 *dstline, *dstcol; |
832 Uint8 *srcline, *srccol; | 832 Uint8 *srcline, *srccol; |
833 | 833 |
858 dstline += dstpitch; | 858 dstline += dstpitch; |
859 } | 859 } |
860 } | 860 } |
861 | 861 |
862 static void | 862 static void |
863 CopyShadowRGBToABGR (_THIS, SDL_Surface * surface) | 863 CopyShadowRGBToABGR(_THIS, SDL_Surface * surface) |
864 { | 864 { |
865 int x, y, srcpitch, dstpitch; | 865 int x, y, srcpitch, dstpitch; |
866 Uint32 *dstline, *dstcol; | 866 Uint32 *dstline, *dstcol; |
867 Uint8 *srcline, *srccol; | 867 Uint8 *srcline, *srccol; |
868 | 868 |
893 dstline += dstpitch; | 893 dstline += dstpitch; |
894 } | 894 } |
895 } | 895 } |
896 | 896 |
897 static void | 897 static void |
898 CopyShadowRGBToBGRA (_THIS, SDL_Surface * surface) | 898 CopyShadowRGBToBGRA(_THIS, SDL_Surface * surface) |
899 { | 899 { |
900 int x, y, srcpitch, dstpitch; | 900 int x, y, srcpitch, dstpitch; |
901 Uint32 *dstline, *dstcol; | 901 Uint32 *dstline, *dstcol; |
902 Uint8 *srcline, *srccol; | 902 Uint8 *srcline, *srccol; |
903 | 903 |
928 dstline += dstpitch; | 928 dstline += dstpitch; |
929 } | 929 } |
930 } | 930 } |
931 | 931 |
932 static void | 932 static void |
933 CopyShadowRGBToRGBA (_THIS, SDL_Surface * surface) | 933 CopyShadowRGBToRGBA(_THIS, SDL_Surface * surface) |
934 { | 934 { |
935 int x, y, srcpitch, dstpitch; | 935 int x, y, srcpitch, dstpitch; |
936 Uint32 *dstline, *dstcol; | 936 Uint32 *dstline, *dstcol; |
937 Uint8 *srcline, *srccol; | 937 Uint8 *srcline, *srccol; |
938 | 938 |
963 dstline += dstpitch; | 963 dstline += dstpitch; |
964 } | 964 } |
965 } | 965 } |
966 | 966 |
967 static void | 967 static void |
968 CopyShadow8888To555 (_THIS, SDL_Surface * surface) | 968 CopyShadow8888To555(_THIS, SDL_Surface * surface) |
969 { | 969 { |
970 int x, y, srcpitch, dstpitch; | 970 int x, y, srcpitch, dstpitch; |
971 Uint16 *dstline, *dstcol; | 971 Uint16 *dstline, *dstcol; |
972 Uint32 *srcline, *srccol; | 972 Uint32 *srcline, *srccol; |
973 | 973 |
998 dstline += dstpitch; | 998 dstline += dstpitch; |
999 } | 999 } |
1000 } | 1000 } |
1001 | 1001 |
1002 static void | 1002 static void |
1003 CopyShadow8888To565 (_THIS, SDL_Surface * surface) | 1003 CopyShadow8888To565(_THIS, SDL_Surface * surface) |
1004 { | 1004 { |
1005 int x, y, srcpitch, dstpitch; | 1005 int x, y, srcpitch, dstpitch; |
1006 Uint16 *dstline, *dstcol; | 1006 Uint16 *dstline, *dstcol; |
1007 Uint32 *srcline, *srccol; | 1007 Uint32 *srcline, *srccol; |
1008 | 1008 |
1036 } | 1036 } |
1037 | 1037 |
1038 /*--- Conversions routines in the screen ---*/ | 1038 /*--- Conversions routines in the screen ---*/ |
1039 | 1039 |
1040 static void | 1040 static void |
1041 ConvertNull (_THIS, SDL_Surface * surface) | 1041 ConvertNull(_THIS, SDL_Surface * surface) |
1042 { | 1042 { |
1043 } | 1043 } |
1044 | 1044 |
1045 static void | 1045 static void |
1046 Convert565To555be (_THIS, SDL_Surface * surface) | 1046 Convert565To555be(_THIS, SDL_Surface * surface) |
1047 { | 1047 { |
1048 int x, y, pitch; | 1048 int x, y, pitch; |
1049 unsigned short *line, *pixel; | 1049 unsigned short *line, *pixel; |
1050 | 1050 |
1051 line = surface->pixels; | 1051 line = surface->pixels; |
1061 line += pitch; | 1061 line += pitch; |
1062 } | 1062 } |
1063 } | 1063 } |
1064 | 1064 |
1065 static void | 1065 static void |
1066 Convert565To555le (_THIS, SDL_Surface * surface) | 1066 Convert565To555le(_THIS, SDL_Surface * surface) |
1067 { | 1067 { |
1068 int x, y, pitch; | 1068 int x, y, pitch; |
1069 unsigned short *line, *pixel; | 1069 unsigned short *line, *pixel; |
1070 | 1070 |
1071 line = surface->pixels; | 1071 line = surface->pixels; |
1074 pixel = line; | 1074 pixel = line; |
1075 for (x = 0; x < surface->w; x++) { | 1075 for (x = 0; x < surface->w; x++) { |
1076 unsigned short color = *pixel; | 1076 unsigned short color = *pixel; |
1077 | 1077 |
1078 color = (color & 0x1f) | ((color >> 1) & 0xffe0); | 1078 color = (color & 0x1f) | ((color >> 1) & 0xffe0); |
1079 *pixel++ = SDL_Swap16 (color); | 1079 *pixel++ = SDL_Swap16(color); |
1080 } | 1080 } |
1081 | 1081 |
1082 line += pitch; | 1082 line += pitch; |
1083 } | 1083 } |
1084 } | 1084 } |
1085 | 1085 |
1086 static void | 1086 static void |
1087 Convert565le (_THIS, SDL_Surface * surface) | 1087 Convert565le(_THIS, SDL_Surface * surface) |
1088 { | 1088 { |
1089 int x, y, pitch; | 1089 int x, y, pitch; |
1090 unsigned short *line, *pixel; | 1090 unsigned short *line, *pixel; |
1091 | 1091 |
1092 line = surface->pixels; | 1092 line = surface->pixels; |
1094 for (y = 0; y < surface->h; y++) { | 1094 for (y = 0; y < surface->h; y++) { |
1095 pixel = line; | 1095 pixel = line; |
1096 for (x = 0; x < surface->w; x++) { | 1096 for (x = 0; x < surface->w; x++) { |
1097 unsigned short color = *pixel; | 1097 unsigned short color = *pixel; |
1098 | 1098 |
1099 *pixel++ = SDL_Swap16 (color); | 1099 *pixel++ = SDL_Swap16(color); |
1100 } | 1100 } |
1101 | 1101 |
1102 line += pitch; | 1102 line += pitch; |
1103 } | 1103 } |
1104 } | 1104 } |
1105 | 1105 |
1106 static void | 1106 static void |
1107 ConvertBGRAToABGR (_THIS, SDL_Surface * surface) | 1107 ConvertBGRAToABGR(_THIS, SDL_Surface * surface) |
1108 { | 1108 { |
1109 int x, y, pitch; | 1109 int x, y, pitch; |
1110 unsigned long *line, *pixel; | 1110 unsigned long *line, *pixel; |
1111 | 1111 |
1112 line = surface->pixels; | 1112 line = surface->pixels; |