changeset 1005:2ab1cb02a44e

Some Atari OpenGL implementations draw upside down
author Patrice Mandin <patmandin@gmail.com>
date Sat, 04 Dec 2004 20:53:58 +0000
parents d1cd674b2ecd
children 3d9a199d2a70
files src/video/ataricommon/SDL_atarigl.c src/video/ataricommon/SDL_atarigl_c.h
diffstat 2 files changed, 56 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/src/video/ataricommon/SDL_atarigl.c	Sat Dec 04 10:31:16 2004 +0000
+++ b/src/video/ataricommon/SDL_atarigl.c	Sat Dec 04 20:53:58 2004 +0000
@@ -425,6 +425,7 @@
 	/* Init OpenGL context using OSMesa */
 	gl_convert = ConvertNull;
 	gl_copyshadow = CopyShadowNull;
+	gl_upsidedown = SDL_FALSE;
 
 	pixel_format = current->format;
 	redmask = pixel_format->Rmask;
@@ -539,6 +540,7 @@
 	/* Init OpenGL context using OSMesa */
 	gl_convert = ConvertNull;
 	gl_copyshadow = CopyShadowNull;
+	gl_upsidedown = SDL_FALSE;
 
 	pixel_format = current->format;
 	redmask = pixel_format->Rmask;
@@ -556,6 +558,7 @@
 				}
 			} else {
 				gl_pixelsize = 4;
+				gl_upsidedown = SDL_TRUE;
 				osmesa_format = OSMESA_ARGB;
 				if (redmask == 31<<10) {
 					gl_copyshadow = CopyShadow8888To555;
@@ -577,6 +580,7 @@
 				}
 			} else {
 				gl_pixelsize = 4;
+				gl_upsidedown = SDL_TRUE;
 				osmesa_format = OSMESA_ARGB;
 				gl_copyshadow = CopyShadow8888To565;
 				if (redmask != 31<<11) {
@@ -595,6 +599,7 @@
 				}
 			} else {
 				gl_copyshadow = CopyShadowDirect;
+				gl_upsidedown = SDL_TRUE;
 				if (redmask == 255<<16) {
 					osmesa_format = OSMESA_RGB;
 				} else {
@@ -616,6 +621,7 @@
 				}
 			} else {
 				gl_pixelsize = 4;
+				gl_upsidedown = SDL_TRUE;
 				gl_copyshadow = CopyShadowDirect;
 				if (redmask == 255<<16) {
 					osmesa_format = OSMESA_ARGB;
@@ -685,6 +691,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		memcpy(dstline, srcline, srcpitch);
@@ -704,6 +714,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>1;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -732,6 +746,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>1;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -761,6 +779,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -788,6 +810,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>2;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -818,6 +844,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>2;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -848,6 +878,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>2;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -878,6 +912,10 @@
 	srcpitch = surface->w * gl_pixelsize;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>2;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -908,6 +946,10 @@
 	srcpitch = (surface->w * gl_pixelsize) >>2;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>1;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
@@ -938,6 +980,10 @@
 	srcpitch = (surface->w * gl_pixelsize) >> 2;
 	dstline = surface->pixels;
 	dstpitch = surface->pitch >>1;
+	if (gl_upsidedown) {
+		srcline += (surface->h-1)*srcpitch;
+		srcpitch = -srcpitch;
+	}
 
 	for (y=0; y<surface->h; y++) {
 		srccol = srcline;
--- a/src/video/ataricommon/SDL_atarigl_c.h	Sat Dec 04 10:31:16 2004 +0000
+++ b/src/video/ataricommon/SDL_atarigl_c.h	Sat Dec 04 20:53:58 2004 +0000
@@ -40,6 +40,8 @@
 
 	int	gl_pixelsize;	/* for CopyShadow functions */
 
+	SDL_bool gl_upsidedown; /* Some implementations draw upside down */
+
 	Uint8 *gl_shadow;	/* Shadow buffer for old implementations */
 
 	/* for unsupported OSMesa buffer formats */
@@ -75,19 +77,20 @@
 };
 
 /* Variable names */
-#define gl_active	(this->gl_data->gl_active)
-#define gl_ctx		(this->gl_data->ctx)
-#define gl_oldmesa	(this->gl_data->gl_oldmesa)
+#define gl_active		(this->gl_data->gl_active)
+#define gl_ctx			(this->gl_data->ctx)
+#define gl_oldmesa		(this->gl_data->gl_oldmesa)
 #define gl_pixelsize	(this->gl_data->gl_pixelsize)
-#define gl_shadow	(this->gl_data->gl_shadow)
-#define gl_convert	(this->gl_data->ConvertSurface)
+#define gl_upsidedown	(this->gl_data->gl_upsidedown)
+#define gl_shadow		(this->gl_data->gl_shadow)
+#define gl_convert		(this->gl_data->ConvertSurface)
 #define gl_copyshadow	(this->gl_data->CopyShadow)
 #define gl_curformat	(this->gl_data->format)
 #define gl_curdepth		(this->gl_data->depth)
 #define gl_curstencil	(this->gl_data->stencil)
 #define gl_curaccum		(this->gl_data->accum)
-#define gl_curwidth	(this->gl_data->width)
-#define gl_curheight		(this->gl_data->height)
+#define gl_curwidth		(this->gl_data->width)
+#define gl_curheight	(this->gl_data->height)
 
 /* OpenGL functions */
 extern int SDL_AtariGL_Init(_THIS, SDL_Surface *current);