Skip to content

Commit

Permalink
Some Atari OpenGL implementations draw upside down
Browse files Browse the repository at this point in the history
  • Loading branch information
pmandin committed Dec 4, 2004
1 parent 933d386 commit a77e8a1
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 7 deletions.
46 changes: 46 additions & 0 deletions src/video/ataricommon/SDL_atarigl.c
Expand Up @@ -425,6 +425,7 @@ static int InitNew(_THIS, SDL_Surface *current)
/* Init OpenGL context using OSMesa */
gl_convert = ConvertNull;
gl_copyshadow = CopyShadowNull;
gl_upsidedown = SDL_FALSE;

pixel_format = current->format;
redmask = pixel_format->Rmask;
Expand Down Expand Up @@ -539,6 +540,7 @@ static int InitOld(_THIS, SDL_Surface *current)
/* Init OpenGL context using OSMesa */
gl_convert = ConvertNull;
gl_copyshadow = CopyShadowNull;
gl_upsidedown = SDL_FALSE;

pixel_format = current->format;
redmask = pixel_format->Rmask;
Expand All @@ -556,6 +558,7 @@ static int InitOld(_THIS, SDL_Surface *current)
}
} else {
gl_pixelsize = 4;
gl_upsidedown = SDL_TRUE;
osmesa_format = OSMESA_ARGB;
if (redmask == 31<<10) {
gl_copyshadow = CopyShadow8888To555;
Expand All @@ -577,6 +580,7 @@ static int InitOld(_THIS, SDL_Surface *current)
}
} else {
gl_pixelsize = 4;
gl_upsidedown = SDL_TRUE;
osmesa_format = OSMESA_ARGB;
gl_copyshadow = CopyShadow8888To565;
if (redmask != 31<<11) {
Expand All @@ -595,6 +599,7 @@ static int InitOld(_THIS, SDL_Surface *current)
}
} else {
gl_copyshadow = CopyShadowDirect;
gl_upsidedown = SDL_TRUE;
if (redmask == 255<<16) {
osmesa_format = OSMESA_RGB;
} else {
Expand All @@ -616,6 +621,7 @@ static int InitOld(_THIS, SDL_Surface *current)
}
} else {
gl_pixelsize = 4;
gl_upsidedown = SDL_TRUE;
gl_copyshadow = CopyShadowDirect;
if (redmask == 255<<16) {
osmesa_format = OSMESA_ARGB;
Expand Down Expand Up @@ -685,6 +691,10 @@ static void CopyShadowDirect(_THIS, SDL_Surface *surface)
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);
Expand All @@ -704,6 +714,10 @@ static void CopyShadowRGBTo555(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -732,6 +746,10 @@ static void CopyShadowRGBTo565(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -761,6 +779,10 @@ static void CopyShadowRGBSwap(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -788,6 +810,10 @@ static void CopyShadowRGBToARGB(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -818,6 +844,10 @@ static void CopyShadowRGBToABGR(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -848,6 +878,10 @@ static void CopyShadowRGBToBGRA(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -878,6 +912,10 @@ static void CopyShadowRGBToRGBA(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -908,6 +946,10 @@ static void CopyShadow8888To555(_THIS, SDL_Surface *surface)
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;
Expand Down Expand Up @@ -938,6 +980,10 @@ static void CopyShadow8888To565(_THIS, SDL_Surface *surface)
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;
Expand Down
17 changes: 10 additions & 7 deletions src/video/ataricommon/SDL_atarigl_c.h
Expand Up @@ -40,6 +40,8 @@ struct SDL_PrivateGLData {

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 */
Expand Down Expand Up @@ -75,19 +77,20 @@ struct SDL_PrivateGLData {
};

/* 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);
Expand Down

0 comments on commit a77e8a1

Please sign in to comment.