Some Atari OpenGL implementations draw upside down
authorPatrice Mandin <patmandin@gmail.com>
Sat, 04 Dec 2004 20:53:58 +0000
changeset 10052ab1cb02a44e
parent 1004 d1cd674b2ecd
child 1006 3d9a199d2a70
Some Atari OpenGL implementations draw upside down
src/video/ataricommon/SDL_atarigl.c
src/video/ataricommon/SDL_atarigl_c.h
     1.1 --- a/src/video/ataricommon/SDL_atarigl.c	Sat Dec 04 10:31:16 2004 +0000
     1.2 +++ b/src/video/ataricommon/SDL_atarigl.c	Sat Dec 04 20:53:58 2004 +0000
     1.3 @@ -425,6 +425,7 @@
     1.4  	/* Init OpenGL context using OSMesa */
     1.5  	gl_convert = ConvertNull;
     1.6  	gl_copyshadow = CopyShadowNull;
     1.7 +	gl_upsidedown = SDL_FALSE;
     1.8  
     1.9  	pixel_format = current->format;
    1.10  	redmask = pixel_format->Rmask;
    1.11 @@ -539,6 +540,7 @@
    1.12  	/* Init OpenGL context using OSMesa */
    1.13  	gl_convert = ConvertNull;
    1.14  	gl_copyshadow = CopyShadowNull;
    1.15 +	gl_upsidedown = SDL_FALSE;
    1.16  
    1.17  	pixel_format = current->format;
    1.18  	redmask = pixel_format->Rmask;
    1.19 @@ -556,6 +558,7 @@
    1.20  				}
    1.21  			} else {
    1.22  				gl_pixelsize = 4;
    1.23 +				gl_upsidedown = SDL_TRUE;
    1.24  				osmesa_format = OSMESA_ARGB;
    1.25  				if (redmask == 31<<10) {
    1.26  					gl_copyshadow = CopyShadow8888To555;
    1.27 @@ -577,6 +580,7 @@
    1.28  				}
    1.29  			} else {
    1.30  				gl_pixelsize = 4;
    1.31 +				gl_upsidedown = SDL_TRUE;
    1.32  				osmesa_format = OSMESA_ARGB;
    1.33  				gl_copyshadow = CopyShadow8888To565;
    1.34  				if (redmask != 31<<11) {
    1.35 @@ -595,6 +599,7 @@
    1.36  				}
    1.37  			} else {
    1.38  				gl_copyshadow = CopyShadowDirect;
    1.39 +				gl_upsidedown = SDL_TRUE;
    1.40  				if (redmask == 255<<16) {
    1.41  					osmesa_format = OSMESA_RGB;
    1.42  				} else {
    1.43 @@ -616,6 +621,7 @@
    1.44  				}
    1.45  			} else {
    1.46  				gl_pixelsize = 4;
    1.47 +				gl_upsidedown = SDL_TRUE;
    1.48  				gl_copyshadow = CopyShadowDirect;
    1.49  				if (redmask == 255<<16) {
    1.50  					osmesa_format = OSMESA_ARGB;
    1.51 @@ -685,6 +691,10 @@
    1.52  	srcpitch = surface->w * gl_pixelsize;
    1.53  	dstline = surface->pixels;
    1.54  	dstpitch = surface->pitch;
    1.55 +	if (gl_upsidedown) {
    1.56 +		srcline += (surface->h-1)*srcpitch;
    1.57 +		srcpitch = -srcpitch;
    1.58 +	}
    1.59  
    1.60  	for (y=0; y<surface->h; y++) {
    1.61  		memcpy(dstline, srcline, srcpitch);
    1.62 @@ -704,6 +714,10 @@
    1.63  	srcpitch = surface->w * gl_pixelsize;
    1.64  	dstline = surface->pixels;
    1.65  	dstpitch = surface->pitch >>1;
    1.66 +	if (gl_upsidedown) {
    1.67 +		srcline += (surface->h-1)*srcpitch;
    1.68 +		srcpitch = -srcpitch;
    1.69 +	}
    1.70  
    1.71  	for (y=0; y<surface->h; y++) {
    1.72  		srccol = srcline;
    1.73 @@ -732,6 +746,10 @@
    1.74  	srcpitch = surface->w * gl_pixelsize;
    1.75  	dstline = surface->pixels;
    1.76  	dstpitch = surface->pitch >>1;
    1.77 +	if (gl_upsidedown) {
    1.78 +		srcline += (surface->h-1)*srcpitch;
    1.79 +		srcpitch = -srcpitch;
    1.80 +	}
    1.81  
    1.82  	for (y=0; y<surface->h; y++) {
    1.83  		srccol = srcline;
    1.84 @@ -761,6 +779,10 @@
    1.85  	srcpitch = surface->w * gl_pixelsize;
    1.86  	dstline = surface->pixels;
    1.87  	dstpitch = surface->pitch;
    1.88 +	if (gl_upsidedown) {
    1.89 +		srcline += (surface->h-1)*srcpitch;
    1.90 +		srcpitch = -srcpitch;
    1.91 +	}
    1.92  
    1.93  	for (y=0; y<surface->h; y++) {
    1.94  		srccol = srcline;
    1.95 @@ -788,6 +810,10 @@
    1.96  	srcpitch = surface->w * gl_pixelsize;
    1.97  	dstline = surface->pixels;
    1.98  	dstpitch = surface->pitch >>2;
    1.99 +	if (gl_upsidedown) {
   1.100 +		srcline += (surface->h-1)*srcpitch;
   1.101 +		srcpitch = -srcpitch;
   1.102 +	}
   1.103  
   1.104  	for (y=0; y<surface->h; y++) {
   1.105  		srccol = srcline;
   1.106 @@ -818,6 +844,10 @@
   1.107  	srcpitch = surface->w * gl_pixelsize;
   1.108  	dstline = surface->pixels;
   1.109  	dstpitch = surface->pitch >>2;
   1.110 +	if (gl_upsidedown) {
   1.111 +		srcline += (surface->h-1)*srcpitch;
   1.112 +		srcpitch = -srcpitch;
   1.113 +	}
   1.114  
   1.115  	for (y=0; y<surface->h; y++) {
   1.116  		srccol = srcline;
   1.117 @@ -848,6 +878,10 @@
   1.118  	srcpitch = surface->w * gl_pixelsize;
   1.119  	dstline = surface->pixels;
   1.120  	dstpitch = surface->pitch >>2;
   1.121 +	if (gl_upsidedown) {
   1.122 +		srcline += (surface->h-1)*srcpitch;
   1.123 +		srcpitch = -srcpitch;
   1.124 +	}
   1.125  
   1.126  	for (y=0; y<surface->h; y++) {
   1.127  		srccol = srcline;
   1.128 @@ -878,6 +912,10 @@
   1.129  	srcpitch = surface->w * gl_pixelsize;
   1.130  	dstline = surface->pixels;
   1.131  	dstpitch = surface->pitch >>2;
   1.132 +	if (gl_upsidedown) {
   1.133 +		srcline += (surface->h-1)*srcpitch;
   1.134 +		srcpitch = -srcpitch;
   1.135 +	}
   1.136  
   1.137  	for (y=0; y<surface->h; y++) {
   1.138  		srccol = srcline;
   1.139 @@ -908,6 +946,10 @@
   1.140  	srcpitch = (surface->w * gl_pixelsize) >>2;
   1.141  	dstline = surface->pixels;
   1.142  	dstpitch = surface->pitch >>1;
   1.143 +	if (gl_upsidedown) {
   1.144 +		srcline += (surface->h-1)*srcpitch;
   1.145 +		srcpitch = -srcpitch;
   1.146 +	}
   1.147  
   1.148  	for (y=0; y<surface->h; y++) {
   1.149  		srccol = srcline;
   1.150 @@ -938,6 +980,10 @@
   1.151  	srcpitch = (surface->w * gl_pixelsize) >> 2;
   1.152  	dstline = surface->pixels;
   1.153  	dstpitch = surface->pitch >>1;
   1.154 +	if (gl_upsidedown) {
   1.155 +		srcline += (surface->h-1)*srcpitch;
   1.156 +		srcpitch = -srcpitch;
   1.157 +	}
   1.158  
   1.159  	for (y=0; y<surface->h; y++) {
   1.160  		srccol = srcline;
     2.1 --- a/src/video/ataricommon/SDL_atarigl_c.h	Sat Dec 04 10:31:16 2004 +0000
     2.2 +++ b/src/video/ataricommon/SDL_atarigl_c.h	Sat Dec 04 20:53:58 2004 +0000
     2.3 @@ -40,6 +40,8 @@
     2.4  
     2.5  	int	gl_pixelsize;	/* for CopyShadow functions */
     2.6  
     2.7 +	SDL_bool gl_upsidedown; /* Some implementations draw upside down */
     2.8 +
     2.9  	Uint8 *gl_shadow;	/* Shadow buffer for old implementations */
    2.10  
    2.11  	/* for unsupported OSMesa buffer formats */
    2.12 @@ -75,19 +77,20 @@
    2.13  };
    2.14  
    2.15  /* Variable names */
    2.16 -#define gl_active	(this->gl_data->gl_active)
    2.17 -#define gl_ctx		(this->gl_data->ctx)
    2.18 -#define gl_oldmesa	(this->gl_data->gl_oldmesa)
    2.19 +#define gl_active		(this->gl_data->gl_active)
    2.20 +#define gl_ctx			(this->gl_data->ctx)
    2.21 +#define gl_oldmesa		(this->gl_data->gl_oldmesa)
    2.22  #define gl_pixelsize	(this->gl_data->gl_pixelsize)
    2.23 -#define gl_shadow	(this->gl_data->gl_shadow)
    2.24 -#define gl_convert	(this->gl_data->ConvertSurface)
    2.25 +#define gl_upsidedown	(this->gl_data->gl_upsidedown)
    2.26 +#define gl_shadow		(this->gl_data->gl_shadow)
    2.27 +#define gl_convert		(this->gl_data->ConvertSurface)
    2.28  #define gl_copyshadow	(this->gl_data->CopyShadow)
    2.29  #define gl_curformat	(this->gl_data->format)
    2.30  #define gl_curdepth		(this->gl_data->depth)
    2.31  #define gl_curstencil	(this->gl_data->stencil)
    2.32  #define gl_curaccum		(this->gl_data->accum)
    2.33 -#define gl_curwidth	(this->gl_data->width)
    2.34 -#define gl_curheight		(this->gl_data->height)
    2.35 +#define gl_curwidth		(this->gl_data->width)
    2.36 +#define gl_curheight	(this->gl_data->height)
    2.37  
    2.38  /* OpenGL functions */
    2.39  extern int SDL_AtariGL_Init(_THIS, SDL_Surface *current);