comparison src/video/ataricommon/SDL_atarigl.c @ 1361:19418e4422cb

New configure-based build system. Still work in progress, but much improved
author Sam Lantinga <slouken@libsdl.org>
date Thu, 16 Feb 2006 10:11:48 +0000
parents c71e05b4dc2e
children c0a74f199ecf
comparison
equal deleted inserted replaced
1360:70a9cfb4cf1b 1361:19418e4422cb
22 22
23 /* Atari OSMesa.ldg implementation of SDL OpenGL support */ 23 /* Atari OSMesa.ldg implementation of SDL OpenGL support */
24 24
25 /*--- Includes ---*/ 25 /*--- Includes ---*/
26 26
27 #ifdef HAVE_OPENGL 27 #if SDL_VIDEO_OPENGL
28 #include <GL/osmesa.h> 28 #include <GL/osmesa.h>
29 #endif 29 #endif
30 30
31 #include <mint/osbind.h> 31 #include <mint/osbind.h>
32 32
33 #include "SDL_endian.h" 33 #include "SDL_endian.h"
34 #include "SDL_video.h" 34 #include "SDL_video.h"
35 #include "SDL_atarigl_c.h" 35 #include "SDL_atarigl_c.h"
36 #ifdef ENABLE_OSMESA_SHARED 36 #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
37 #include "SDL_loadso.h" 37 #include "SDL_loadso.h"
38 #endif 38 #endif
39 39
40 /*--- Defines ---*/ 40 /*--- Defines ---*/
41 41
47 47
48 /*--- Functions prototypes ---*/ 48 /*--- Functions prototypes ---*/
49 49
50 static void SDL_AtariGL_UnloadLibrary(_THIS); 50 static void SDL_AtariGL_UnloadLibrary(_THIS);
51 51
52 #ifdef HAVE_OPENGL 52 #if SDL_VIDEO_OPENGL
53 static void CopyShadowNull(_THIS, SDL_Surface *surface); 53 static void CopyShadowNull(_THIS, SDL_Surface *surface);
54 static void CopyShadowDirect(_THIS, SDL_Surface *surface); 54 static void CopyShadowDirect(_THIS, SDL_Surface *surface);
55 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface); 55 static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface);
56 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface); 56 static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface);
57 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface); 57 static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface);
74 74
75 /*--- Public functions ---*/ 75 /*--- Public functions ---*/
76 76
77 int SDL_AtariGL_Init(_THIS, SDL_Surface *current) 77 int SDL_AtariGL_Init(_THIS, SDL_Surface *current)
78 { 78 {
79 #ifdef HAVE_OPENGL 79 #if SDL_VIDEO_OPENGL
80 if (gl_oldmesa) { 80 if (gl_oldmesa) {
81 gl_active = InitOld(this, current); 81 gl_active = InitOld(this, current);
82 } else { 82 } else {
83 gl_active = InitNew(this, current); 83 gl_active = InitNew(this, current);
84 } 84 }
87 return (gl_active); 87 return (gl_active);
88 } 88 }
89 89
90 void SDL_AtariGL_Quit(_THIS, SDL_bool unload) 90 void SDL_AtariGL_Quit(_THIS, SDL_bool unload)
91 { 91 {
92 #ifdef HAVE_OPENGL 92 #if SDL_VIDEO_OPENGL
93 if (gl_oldmesa) { 93 if (gl_oldmesa) {
94 /* Old mesa implementations */ 94 /* Old mesa implementations */
95 if (this->gl_data->OSMesaDestroyLDG) { 95 if (this->gl_data->OSMesaDestroyLDG) {
96 this->gl_data->OSMesaDestroyLDG(); 96 this->gl_data->OSMesaDestroyLDG();
97 } 97 }
111 111
112 if (unload) { 112 if (unload) {
113 SDL_AtariGL_UnloadLibrary(this); 113 SDL_AtariGL_UnloadLibrary(this);
114 } 114 }
115 115
116 #endif /* HAVE_OPENGL */ 116 #endif /* SDL_VIDEO_OPENGL */
117 gl_active = 0; 117 gl_active = 0;
118 } 118 }
119 119
120 int SDL_AtariGL_LoadLibrary(_THIS, const char *path) 120 int SDL_AtariGL_LoadLibrary(_THIS, const char *path)
121 { 121 {
122 #ifdef HAVE_OPENGL 122 #if SDL_VIDEO_OPENGL
123 123
124 #ifdef ENABLE_OSMESA_SHARED 124 #if SDL_VIDEO_OPENGL_OSMESA_DYNAMIC
125 void *handle; 125 void *handle;
126 SDL_bool cancel_load; 126 SDL_bool cancel_load;
127 127
128 if (gl_active) { 128 if (gl_active) {
129 SDL_SetError("OpenGL context already created"); 129 SDL_SetError("OpenGL context already created");
235 } 235 }
236 236
237 void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc) 237 void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
238 { 238 {
239 void *func = NULL; 239 void *func = NULL;
240 #ifdef HAVE_OPENGL 240 #if SDL_VIDEO_OPENGL
241 241
242 if (this->gl_config.dll_handle) { 242 if (this->gl_config.dll_handle) {
243 func = SDL_LoadFunction(this->gl_config.dll_handle, (void *)proc); 243 func = SDL_LoadFunction(this->gl_config.dll_handle, (void *)proc);
244 } else if (this->gl_data->OSMesaGetProcAddress) { 244 } else if (this->gl_data->OSMesaGetProcAddress) {
245 func = this->gl_data->OSMesaGetProcAddress(proc); 245 func = this->gl_data->OSMesaGetProcAddress(proc);
249 return func; 249 return func;
250 } 250 }
251 251
252 int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value) 252 int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
253 { 253 {
254 #ifdef HAVE_OPENGL 254 #if SDL_VIDEO_OPENGL
255 GLenum mesa_attrib; 255 GLenum mesa_attrib;
256 SDL_Surface *surface; 256 SDL_Surface *surface;
257 257
258 if (!gl_active) { 258 if (!gl_active) {
259 return -1; 259 return -1;
305 #endif 305 #endif
306 } 306 }
307 307
308 int SDL_AtariGL_MakeCurrent(_THIS) 308 int SDL_AtariGL_MakeCurrent(_THIS)
309 { 309 {
310 #ifdef HAVE_OPENGL 310 #if SDL_VIDEO_OPENGL
311 SDL_Surface *surface; 311 SDL_Surface *surface;
312 GLenum type; 312 GLenum type;
313 313
314 if (gl_oldmesa && gl_active) { 314 if (gl_oldmesa && gl_active) {
315 return 0; 315 return 0;
349 #endif 349 #endif
350 } 350 }
351 351
352 void SDL_AtariGL_SwapBuffers(_THIS) 352 void SDL_AtariGL_SwapBuffers(_THIS)
353 { 353 {
354 #ifdef HAVE_OPENGL 354 #if SDL_VIDEO_OPENGL
355 if (gl_active) { 355 if (gl_active) {
356 if (this->gl_config.dll_handle) { 356 if (this->gl_config.dll_handle) {
357 if (this->gl_data->glFinish) { 357 if (this->gl_data->glFinish) {
358 this->gl_data->glFinish(); 358 this->gl_data->glFinish();
359 } else if (this->gl_data->glFlush) { 359 } else if (this->gl_data->glFlush) {
368 #endif 368 #endif
369 } 369 }
370 370
371 void SDL_AtariGL_InitPointers(_THIS) 371 void SDL_AtariGL_InitPointers(_THIS)
372 { 372 {
373 #if defined(HAVE_OPENGL) 373 #if SDL_VIDEO_OPENGL
374 this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt; 374 this->gl_data->OSMesaCreateContextExt = OSMesaCreateContextExt;
375 this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext; 375 this->gl_data->OSMesaDestroyContext = OSMesaDestroyContext;
376 this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent; 376 this->gl_data->OSMesaMakeCurrent = OSMesaMakeCurrent;
377 this->gl_data->OSMesaPixelStore = OSMesaPixelStore; 377 this->gl_data->OSMesaPixelStore = OSMesaPixelStore;
378 this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress; 378 this->gl_data->OSMesaGetProcAddress = OSMesaGetProcAddress;
388 388
389 /*--- Private functions ---*/ 389 /*--- Private functions ---*/
390 390
391 static void SDL_AtariGL_UnloadLibrary(_THIS) 391 static void SDL_AtariGL_UnloadLibrary(_THIS)
392 { 392 {
393 #if defined(HAVE_OPENGL) 393 #if SDL_VIDEO_OPENGL
394 if (this->gl_config.dll_handle) { 394 if (this->gl_config.dll_handle) {
395 SDL_UnloadObject(this->gl_config.dll_handle); 395 SDL_UnloadObject(this->gl_config.dll_handle);
396 this->gl_config.dll_handle = NULL; 396 this->gl_config.dll_handle = NULL;
397 397
398 /* Restore pointers to static library */ 398 /* Restore pointers to static library */
401 #endif 401 #endif
402 } 402 }
403 403
404 /*--- Creation of an OpenGL context using new/old functions ---*/ 404 /*--- Creation of an OpenGL context using new/old functions ---*/
405 405
406 #ifdef HAVE_OPENGL 406 #if SDL_VIDEO_OPENGL
407 static int InitNew(_THIS, SDL_Surface *current) 407 static int InitNew(_THIS, SDL_Surface *current)
408 { 408 {
409 GLenum osmesa_format; 409 GLenum osmesa_format;
410 SDL_PixelFormat *pixel_format; 410 SDL_PixelFormat *pixel_format;
411 Uint32 redmask; 411 Uint32 redmask;
1082 1082
1083 line += pitch; 1083 line += pitch;
1084 } 1084 }
1085 } 1085 }
1086 1086
1087 #endif /* HAVE_OPENGL */ 1087 #endif /* SDL_VIDEO_OPENGL */