Factorize OSMesa OpenGL code for Atari drivers
authorPatrice Mandin <patmandin@gmail.com>
Thu, 25 Nov 2004 15:47:49 +0000
changeset 989475166d13b44
parent 988 24b5c3ad4852
child 990 8e20c48a9c13
Factorize OSMesa OpenGL code for Atari drivers
configure.in
src/video/SDL_video.c
src/video/ataricommon/Makefile.am
src/video/ataricommon/SDL_atarigl.c
src/video/ataricommon/SDL_atarigl_c.h
src/video/gem/SDL_gemvideo.c
src/video/gem/SDL_gemvideo.h
src/video/xbios/SDL_xbios.c
src/video/xbios/SDL_xbios.h
     1.1 --- a/configure.in	Mon Nov 22 20:37:41 2004 +0000
     1.2 +++ b/configure.in	Thu Nov 25 15:47:49 2004 +0000
     1.3 @@ -1130,14 +1130,22 @@
     1.4  }
     1.5  
     1.6  dnl Check for Mesa offscreen rendering
     1.7 -CheckOSMesa()
     1.8 +CheckAtariOSMesa()
     1.9  {
    1.10 -    if test x$enable_video = xyes -a x$enable_video_opengl = xyes; then
    1.11 -        AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
    1.12 -        AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
    1.13 -        if test x$have_osmesa_hdr = xyes -a x$have_osmesa_lib = xyes; then
    1.14 -    	    CFLAGS="$CFLAGS -DHAVE_OPENGL"
    1.15 -			SYSTEM_LIBS="$SYSTEM_LIBS -lOSMesa"
    1.16 +    if test "x$enable_video" = "xyes" -a "x$enable_video_opengl" = "xyes"; then
    1.17 +        AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
    1.18 +        if test "x$OSMESA_CONFIG" = "xno" -o "x$enable_atari_ldg" = "xno"; then
    1.19 +            AC_CHECK_HEADER(GL/osmesa.h, have_osmesa_hdr=yes)
    1.20 +            AC_CHECK_LIB(OSMesa, OSMesaCreateContext, have_osmesa_lib=yes, have_osmesa_lib=no, -lm)
    1.21 +            if test "x$have_osmesa_hdr" = "xyes" -a "x$have_osmesa_lib" = "xyes"; then
    1.22 +    	        CFLAGS="$CFLAGS -DHAVE_OPENGL"
    1.23 +		    	SYSTEM_LIBS="$SYSTEM_LIBS -lOSMesa"
    1.24 +            fi
    1.25 +        else
    1.26 +            OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
    1.27 +            OSMESA_LIBS=`$OSMESA_CONFIG --libs`
    1.28 +        	CFLAGS="$CFLAGS -DHAVE_OPENGL $OSMESA_CFLAGS"
    1.29 +            SYSTEM_LIBS="$SYSTEM_LIBS $OSMESA_LIBS"
    1.30          fi
    1.31      fi
    1.32  }
    1.33 @@ -2584,8 +2592,8 @@
    1.34          CheckAtariGemVideo
    1.35          CheckAtariAudio
    1.36          CheckAtariLdg
    1.37 +		CheckAtariOSMesa
    1.38          CheckPTH
    1.39 -		CheckOSMesa
    1.40          # Set up files for the audio library
    1.41          if test x$enable_threads = xyes -a x$enable_pth = xyes; then
    1.42              if test x$enable_audio = xyes; then
     2.1 --- a/src/video/SDL_video.c	Mon Nov 22 20:37:41 2004 +0000
     2.2 +++ b/src/video/SDL_video.c	Thu Nov 25 15:47:49 2004 +0000
     2.3 @@ -747,6 +747,8 @@
     2.4  #define __SDL_NOGETPROCADDR__
     2.5  #elif defined(__QNXNTO__) && (_NTO_VERSION < 630)
     2.6  #define __SDL_NOGETPROCADDR__
     2.7 +#elif defined(__MINT__)
     2.8 +#define __SDL_NOGETPROCADDR__
     2.9  #endif
    2.10  #ifdef __SDL_NOGETPROCADDR__
    2.11      #define SDL_PROC(ret,func,params) video->func=func;
     3.1 --- a/src/video/ataricommon/Makefile.am	Mon Nov 22 20:37:41 2004 +0000
     3.2 +++ b/src/video/ataricommon/Makefile.am	Thu Nov 25 15:47:49 2004 +0000
     3.3 @@ -12,6 +12,8 @@
     3.4  	SDL_atarieddi_s.h	\
     3.5  	SDL_atarievents.c	\
     3.6  	SDL_atarievents_c.h	\
     3.7 +	SDL_atarigl.c	\
     3.8 +	SDL_atarigl_c.h	\
     3.9  	SDL_atarikeys.h	\
    3.10  	SDL_atarimxalloc.c	\
    3.11  	SDL_atarimxalloc_c.h	\
     4.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     4.2 +++ b/src/video/ataricommon/SDL_atarigl.c	Thu Nov 25 15:47:49 2004 +0000
     4.3 @@ -0,0 +1,331 @@
     4.4 +/*
     4.5 +    SDL - Simple DirectMedia Layer
     4.6 +    Copyright (C) 1997-2004 Sam Lantinga
     4.7 +
     4.8 +    This library is free software; you can redistribute it and/or
     4.9 +    modify it under the terms of the GNU Library General Public
    4.10 +    License as published by the Free Software Foundation; either
    4.11 +    version 2 of the License, or (at your option) any later version.
    4.12 +
    4.13 +    This library is distributed in the hope that it will be useful,
    4.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    4.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    4.16 +    Library General Public License for more details.
    4.17 +
    4.18 +    You should have received a copy of the GNU Library General Public
    4.19 +    License along with this library; if not, write to the Free
    4.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    4.21 +
    4.22 +    Sam Lantinga
    4.23 +    slouken@libsdl.org
    4.24 +*/
    4.25 +
    4.26 +/* Atari OSMesa.ldg implementation of SDL OpenGL support */
    4.27 +
    4.28 +/*--- Includes ---*/
    4.29 +
    4.30 +#ifdef HAVE_OPENGL
    4.31 +#include <GL/osmesa.h>
    4.32 +#endif
    4.33 +
    4.34 +#include "SDL_video.h"
    4.35 +#include "SDL_error.h"
    4.36 +#include "SDL_endian.h"
    4.37 +#include "SDL_atarigl_c.h"
    4.38 +
    4.39 +/*--- Variables ---*/
    4.40 +
    4.41 +/*--- Functions prototypes ---*/
    4.42 +
    4.43 +static void ConvertNull(SDL_Surface *surface);
    4.44 +static void Convert565To555be(SDL_Surface *surface);
    4.45 +static void Convert565To555le(SDL_Surface *surface);
    4.46 +static void Convert565le(SDL_Surface *surface);
    4.47 +static void ConvertBGRAToABGR(SDL_Surface *surface);
    4.48 +
    4.49 +/*--- Public functions ---*/
    4.50 +
    4.51 +int SDL_AtariGL_Init(_THIS, SDL_Surface *current)
    4.52 +{
    4.53 +#ifdef HAVE_OPENGL
    4.54 +	GLenum osmesa_format;
    4.55 +	SDL_PixelFormat *pixel_format;
    4.56 +	Uint32	redmask;
    4.57 +
    4.58 +	SDL_AtariGL_Quit(this);	/* Destroy previous context if exist */
    4.59 +
    4.60 +	/* Init OpenGL context using OSMesa */
    4.61 +	gl_convert = ConvertNull;
    4.62 +
    4.63 +	pixel_format = current->format;
    4.64 +	redmask = pixel_format->Rmask;
    4.65 +	switch (pixel_format->BitsPerPixel) {
    4.66 +		case 15:
    4.67 +			/* 1555, big and little endian, unsupported */
    4.68 +			osmesa_format = OSMESA_RGB_565;
    4.69 +			if (redmask == 31<<10) {
    4.70 +				gl_convert = Convert565To555be;
    4.71 +			} else {
    4.72 +				gl_convert = Convert565To555le;
    4.73 +			}
    4.74 +			break;
    4.75 +		case 16:
    4.76 +			if (redmask == 31<<11) {
    4.77 +				osmesa_format = OSMESA_RGB_565;
    4.78 +			} else {
    4.79 +				/* 565, little endian, unsupported */
    4.80 +				osmesa_format = OSMESA_RGB_565;
    4.81 +				gl_convert = Convert565le;
    4.82 +			}
    4.83 +			break;
    4.84 +		case 24:
    4.85 +			if (redmask == 255<<16) {
    4.86 +				osmesa_format = OSMESA_RGB;
    4.87 +			} else {
    4.88 +				osmesa_format = OSMESA_BGR;
    4.89 +			}
    4.90 +			break;
    4.91 +		case 32:
    4.92 +			if (redmask == 255<<16) {
    4.93 +				osmesa_format = OSMESA_ARGB;
    4.94 +			} else if (redmask == 255<<8) {
    4.95 +				osmesa_format = OSMESA_BGRA;
    4.96 +			} else if (redmask == 255<<24) {
    4.97 +				osmesa_format = OSMESA_RGBA;
    4.98 +			} else {
    4.99 +				/* ABGR format unsupported */
   4.100 +				osmesa_format = OSMESA_BGRA;
   4.101 +				gl_convert = ConvertBGRAToABGR;
   4.102 +			}
   4.103 +			break;
   4.104 +		default:
   4.105 +			osmesa_format = OSMESA_COLOR_INDEX;
   4.106 +			break;
   4.107 +	}
   4.108 +
   4.109 +	gl_ctx = OSMesaCreateContextExt( osmesa_format, this->gl_config.depth_size,
   4.110 +		this->gl_config.stencil_size, this->gl_config.accum_red_size +
   4.111 +		this->gl_config.accum_green_size + this->gl_config.accum_blue_size +
   4.112 +		this->gl_config.accum_alpha_size, NULL );
   4.113 +
   4.114 +	gl_active = (gl_ctx != NULL);
   4.115 +	return (gl_active);
   4.116 +#else
   4.117 +	return 0;
   4.118 +#endif
   4.119 +}
   4.120 +
   4.121 +void SDL_AtariGL_Quit(_THIS)
   4.122 +{
   4.123 +#ifdef HAVE_OPENGL
   4.124 +	/* Shutdown OpenGL context */
   4.125 +	if (gl_ctx) {
   4.126 +		OSMesaDestroyContext(gl_ctx);
   4.127 +		gl_ctx = NULL;
   4.128 +	}
   4.129 +#endif
   4.130 +	gl_active = 0;
   4.131 +}
   4.132 +
   4.133 +int SDL_AtariGL_LoadLibrary(_THIS, const char *path)
   4.134 +{
   4.135 +#ifdef HAVE_OPENGL
   4.136 +	/* Library is always opened */
   4.137 +	this->gl_config.driver_loaded = 1;
   4.138 +#endif
   4.139 +	return 0;
   4.140 +}
   4.141 +
   4.142 +void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc)
   4.143 +{
   4.144 +	void *func = NULL;
   4.145 +#ifdef HAVE_OPENGL
   4.146 +	if (gl_ctx != NULL) {
   4.147 +		func = OSMesaGetProcAddress(proc);
   4.148 +	}
   4.149 +#endif
   4.150 +	return func;
   4.151 +}
   4.152 +
   4.153 +int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
   4.154 +{
   4.155 +#ifdef HAVE_OPENGL
   4.156 +	GLenum mesa_attrib;
   4.157 +	SDL_Surface *surface;
   4.158 +
   4.159 +	if (gl_ctx == NULL) {
   4.160 +		return -1;
   4.161 +	}
   4.162 +
   4.163 +	switch(attrib) {
   4.164 +		case SDL_GL_RED_SIZE:
   4.165 +			mesa_attrib = GL_RED_BITS;
   4.166 +			break;
   4.167 +		case SDL_GL_GREEN_SIZE:
   4.168 +			mesa_attrib = GL_GREEN_BITS;
   4.169 +			break;
   4.170 +		case SDL_GL_BLUE_SIZE:
   4.171 +			mesa_attrib = GL_BLUE_BITS;
   4.172 +			break;
   4.173 +		case SDL_GL_ALPHA_SIZE:
   4.174 +			mesa_attrib = GL_ALPHA_BITS;
   4.175 +			break;
   4.176 +		case SDL_GL_DOUBLEBUFFER:
   4.177 +			surface = this->screen;
   4.178 +			*value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF);
   4.179 +			return 0;
   4.180 +		case SDL_GL_DEPTH_SIZE:
   4.181 +			mesa_attrib = GL_DEPTH_BITS;
   4.182 +			break;
   4.183 +		case SDL_GL_STENCIL_SIZE:
   4.184 +			mesa_attrib = GL_STENCIL_BITS;
   4.185 +			break;
   4.186 +		case SDL_GL_ACCUM_RED_SIZE:
   4.187 +			mesa_attrib = GL_ACCUM_RED_BITS;
   4.188 +			break;
   4.189 +		case SDL_GL_ACCUM_GREEN_SIZE:
   4.190 +			mesa_attrib = GL_ACCUM_GREEN_BITS;
   4.191 +			break;
   4.192 +		case SDL_GL_ACCUM_BLUE_SIZE:
   4.193 +			mesa_attrib = GL_ACCUM_BLUE_BITS;
   4.194 +			break;
   4.195 +		case SDL_GL_ACCUM_ALPHA_SIZE:
   4.196 +			mesa_attrib = GL_ACCUM_ALPHA_BITS;
   4.197 +			break;
   4.198 +		default :
   4.199 +			return -1;
   4.200 +	}
   4.201 +
   4.202 +	glGetIntegerv(mesa_attrib, value);
   4.203 +	return 0;
   4.204 +#else
   4.205 +	return -1;
   4.206 +#endif
   4.207 +}
   4.208 +
   4.209 +int SDL_AtariGL_MakeCurrent(_THIS)
   4.210 +{
   4.211 +#ifdef HAVE_OPENGL
   4.212 +	SDL_Surface *surface;
   4.213 +	GLenum type;
   4.214 +
   4.215 +	if (gl_ctx == NULL) {
   4.216 +		SDL_SetError("Invalid OpenGL context");
   4.217 +		return -1;
   4.218 +	}
   4.219 +
   4.220 +	surface = this->screen;
   4.221 +	
   4.222 +	if ((surface->format->BitsPerPixel == 15) || (surface->format->BitsPerPixel == 16)) {
   4.223 +		type = GL_UNSIGNED_SHORT_5_6_5;
   4.224 +	} else {
   4.225 +		type = GL_UNSIGNED_BYTE;
   4.226 +	}
   4.227 +
   4.228 +	if (!OSMesaMakeCurrent(gl_ctx, surface->pixels, type, surface->w, surface->h)) {
   4.229 +		SDL_SetError("Can not make OpenGL context current");
   4.230 +		return -1;
   4.231 +	}
   4.232 +
   4.233 +	/* OSMesa draws upside down */
   4.234 +	OSMesaPixelStore(OSMESA_Y_UP, 0);
   4.235 +
   4.236 +	return 0;
   4.237 +#else
   4.238 +	return -1;
   4.239 +#endif
   4.240 +}
   4.241 +
   4.242 +void SDL_AtariGL_SwapBuffers(_THIS)
   4.243 +{
   4.244 +#ifdef HAVE_OPENGL
   4.245 +	if (gl_ctx == NULL) {
   4.246 +		return;
   4.247 +	}
   4.248 +
   4.249 +	gl_convert(this->screen);
   4.250 +#endif
   4.251 +}
   4.252 +
   4.253 +/*--- Private functions ---*/
   4.254 +
   4.255 +static void ConvertNull(SDL_Surface *surface)
   4.256 +{
   4.257 +}
   4.258 +
   4.259 +static void Convert565To555be(SDL_Surface *surface)
   4.260 +{
   4.261 +	int x,y, pitch;
   4.262 +	unsigned short *line, *pixel;
   4.263 +
   4.264 +	line = surface->pixels;
   4.265 +	pitch = surface->pitch >> 1;
   4.266 +	for (y=0; y<surface->h; y++) {
   4.267 +		pixel = line;
   4.268 +		for (x=0; x<surface->w; x++) {
   4.269 +			unsigned short color = *pixel;
   4.270 +
   4.271 +			*pixel++ = (color & 0x1f)|((color>>1) & 0xffe0);
   4.272 +		}
   4.273 +
   4.274 +		line += pitch;
   4.275 +	}
   4.276 +}
   4.277 +
   4.278 +static void Convert565To555le(SDL_Surface *surface)
   4.279 +{
   4.280 +	int x,y, pitch;
   4.281 +	unsigned short *line, *pixel;
   4.282 +
   4.283 +	line = surface->pixels;
   4.284 +	pitch = surface->pitch >>1;
   4.285 +	for (y=0; y<surface->h; y++) {
   4.286 +		pixel = line;
   4.287 +		for (x=0; x<surface->w; x++) {
   4.288 +			unsigned short color = *pixel;
   4.289 +
   4.290 +			color = (color & 0x1f)|((color>>1) & 0xffe0);
   4.291 +			*pixel++ = SDL_Swap16(color);
   4.292 +		}
   4.293 +
   4.294 +		line += pitch;
   4.295 +	}
   4.296 +}
   4.297 +
   4.298 +static void Convert565le(SDL_Surface *surface)
   4.299 +{
   4.300 +	int x,y, pitch;
   4.301 +	unsigned short *line, *pixel;
   4.302 +
   4.303 +	line = surface->pixels;
   4.304 +	pitch = surface->pitch >>1;
   4.305 +	for (y=0; y<surface->h; y++) {
   4.306 +		pixel = line;
   4.307 +		for (x=0; x<surface->w; x++) {
   4.308 +			unsigned short color = *pixel;
   4.309 +
   4.310 +			*pixel++ = SDL_Swap16(color);
   4.311 +		}
   4.312 +
   4.313 +		line += pitch;
   4.314 +	}
   4.315 +}
   4.316 +
   4.317 +static void ConvertBGRAToABGR(SDL_Surface *surface)
   4.318 +{
   4.319 +	int x,y, pitch;
   4.320 +	unsigned long *line, *pixel;
   4.321 +
   4.322 +	line = surface->pixels;
   4.323 +	pitch = surface->pitch >>2;
   4.324 +	for (y=0; y<surface->h; y++) {
   4.325 +		pixel = line;
   4.326 +		for (x=0; x<surface->w; x++) {
   4.327 +			unsigned long color = *pixel;
   4.328 +
   4.329 +			*pixel++ = (color<<24)|(color>>8);
   4.330 +		}
   4.331 +
   4.332 +		line += pitch;
   4.333 +	}
   4.334 +}
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/src/video/ataricommon/SDL_atarigl_c.h	Thu Nov 25 15:47:49 2004 +0000
     5.3 @@ -0,0 +1,62 @@
     5.4 +/*
     5.5 +    SDL - Simple DirectMedia Layer
     5.6 +    Copyright (C) 1997-2004 Sam Lantinga
     5.7 +
     5.8 +    This library is free software; you can redistribute it and/or
     5.9 +    modify it under the terms of the GNU Library General Public
    5.10 +    License as published by the Free Software Foundation; either
    5.11 +    version 2 of the License, or (at your option) any later version.
    5.12 +
    5.13 +    This library is distributed in the hope that it will be useful,
    5.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    5.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    5.16 +    Library General Public License for more details.
    5.17 +
    5.18 +    You should have received a copy of the GNU Library General Public
    5.19 +    License along with this library; if not, write to the Free
    5.20 +    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
    5.21 +
    5.22 +    Sam Lantinga
    5.23 +    slouken@libsdl.org
    5.24 +*/
    5.25 +
    5.26 +/* Atari OSMesa.ldg implementation of SDL OpenGL support */
    5.27 +
    5.28 +#ifndef _SDL_ATARIGL_H_
    5.29 +#define _SDL_ATARIGL_H_
    5.30 +
    5.31 +#ifdef HAVE_OPENGL
    5.32 +#include <GL/osmesa.h>
    5.33 +#endif
    5.34 +
    5.35 +#include "SDL_sysvideo.h"
    5.36 +#define _THIS   SDL_VideoDevice *this
    5.37 +
    5.38 +struct SDL_PrivateGLData {
    5.39 +	/* to stop switching drivers while we have a valid context */
    5.40 +    int gl_active; 
    5.41 +
    5.42 +	/* for unsupported OSMesa buffer formats */
    5.43 +	void (*ConvertSurface)(SDL_Surface *surface);	
    5.44 +
    5.45 +#ifdef HAVE_OPENGL
    5.46 +	OSMesaContext	ctx;
    5.47 +#endif
    5.48 +};
    5.49 +
    5.50 +/* Old variable names */
    5.51 +#define gl_active	(this->gl_data->gl_active)
    5.52 +#define gl_ctx		(this->gl_data->ctx)
    5.53 +#define gl_convert	(this->gl_data->ConvertSurface)
    5.54 +
    5.55 +/* OpenGL functions */
    5.56 +extern int SDL_AtariGL_Init(_THIS, SDL_Surface *current);
    5.57 +extern void SDL_AtariGL_Quit(_THIS);
    5.58 +
    5.59 +extern int SDL_AtariGL_LoadLibrary(_THIS, const char *path);
    5.60 +extern void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc);
    5.61 +extern int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
    5.62 +extern int SDL_AtariGL_MakeCurrent(_THIS);
    5.63 +extern void SDL_AtariGL_SwapBuffers(_THIS);
    5.64 +
    5.65 +#endif /* _SDL_ATARIGL_H_ */
     6.1 --- a/src/video/gem/SDL_gemvideo.c	Mon Nov 22 20:37:41 2004 +0000
     6.2 +++ b/src/video/gem/SDL_gemvideo.c	Thu Nov 25 15:47:49 2004 +0000
     6.3 @@ -37,10 +37,6 @@
     6.4  #include <stdlib.h>
     6.5  #include <string.h>
     6.6  
     6.7 -#ifdef HAVE_OPENGL
     6.8 -#include <GL/osmesa.h>
     6.9 -#endif
    6.10 -
    6.11  /* Mint includes */
    6.12  #include <gem.h>
    6.13  #include <gemx.h>
    6.14 @@ -60,6 +56,8 @@
    6.15  #include "SDL_ataric2p_s.h"
    6.16  #include "SDL_atarieddi_s.h"
    6.17  #include "SDL_atarimxalloc_c.h"
    6.18 +#include "SDL_atarigl_c.h"
    6.19 +
    6.20  #include "SDL_gemvideo.h"
    6.21  #include "SDL_gemevents_c.h"
    6.22  #include "SDL_gemmouse_c.h"
    6.23 @@ -114,19 +112,7 @@
    6.24  
    6.25  #ifdef HAVE_OPENGL
    6.26  /* OpenGL functions */
    6.27 -static int GEM_GL_LoadLibrary(_THIS, const char *path);
    6.28 -static void *GEM_GL_GetProcAddress(_THIS, const char *proc);
    6.29 -static int GEM_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
    6.30 -static int GEM_GL_MakeCurrent(_THIS);
    6.31  static void GEM_GL_SwapBuffers(_THIS);
    6.32 -
    6.33 -static void GEM_GL_ConvertNull(SDL_Surface *surface);
    6.34 -static void GEM_GL_Convert565To555be(SDL_Surface *surface);
    6.35 -static void GEM_GL_Convert565To555le(SDL_Surface *surface);
    6.36 -static void GEM_GL_Convert565le(SDL_Surface *surface);
    6.37 -static void GEM_GL_ConvertBGRAToABGR(SDL_Surface *surface);
    6.38 -
    6.39 -static void (*GEM_GL_Convert)(SDL_Surface *surface);
    6.40  #endif
    6.41  
    6.42  /* GEM driver bootstrap functions */
    6.43 @@ -157,6 +143,8 @@
    6.44  		memset(device, 0, (sizeof *device));
    6.45  		device->hidden = (struct SDL_PrivateVideoData *)
    6.46  				malloc((sizeof *device->hidden));
    6.47 +		device->gl_data = (struct SDL_PrivateGLData *)
    6.48 +				malloc((sizeof *device->gl_data));
    6.49  	}
    6.50  	if ( (device == NULL) || (device->hidden == NULL) ) {
    6.51  		SDL_OutOfMemory();
    6.52 @@ -166,6 +154,7 @@
    6.53  		return(0);
    6.54  	}
    6.55  	memset(device->hidden, 0, (sizeof *device->hidden));
    6.56 +	memset(device->gl_data, 0, sizeof(*device->gl_data));
    6.57  
    6.58  	/* Set the function pointers */
    6.59  	device->VideoInit = GEM_VideoInit;
    6.60 @@ -200,10 +189,10 @@
    6.61  
    6.62  #ifdef HAVE_OPENGL
    6.63  	/* OpenGL functions */
    6.64 -	device->GL_LoadLibrary = GEM_GL_LoadLibrary;
    6.65 -	device->GL_GetProcAddress = GEM_GL_GetProcAddress;
    6.66 -	device->GL_GetAttribute = GEM_GL_GetAttribute;
    6.67 -	device->GL_MakeCurrent = GEM_GL_MakeCurrent;
    6.68 +	device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
    6.69 +	device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
    6.70 +	device->GL_GetAttribute = SDL_AtariGL_GetAttribute;
    6.71 +	device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
    6.72  	device->GL_SwapBuffers = GEM_GL_SwapBuffers;
    6.73  #endif
    6.74  
    6.75 @@ -483,10 +472,6 @@
    6.76  	printf("sdl:video:gem: VideoInit(): done\n");
    6.77  #endif
    6.78  
    6.79 -#ifdef HAVE_OPENGL
    6.80 -	this->gl_config.driver_loaded = 1;
    6.81 -#endif
    6.82 -
    6.83  	/* We're done! */
    6.84  	return(0);
    6.85  }
    6.86 @@ -507,11 +492,7 @@
    6.87  static void GEM_FreeBuffers(_THIS)
    6.88  {
    6.89  #ifdef HAVE_OPENGL
    6.90 -	/* Shutdown OpenGL context */
    6.91 -	if (GEM_ctx) {
    6.92 -		OSMesaDestroyContext(GEM_ctx);
    6.93 -		GEM_ctx = NULL;
    6.94 -	}
    6.95 +	SDL_AtariGL_Quit(this);
    6.96  #endif
    6.97  
    6.98  	/* Release buffer */
    6.99 @@ -760,59 +741,10 @@
   6.100  
   6.101  #ifdef HAVE_OPENGL
   6.102  	if (flags & SDL_OPENGL) {
   6.103 -		GLenum format = OSMESA_COLOR_INDEX;	/* 8 bits */
   6.104 -
   6.105 -		/* Init OpenGL context using OSMesa */
   6.106 -		GEM_GL_Convert = GEM_GL_ConvertNull;
   6.107 -		switch (VDI_bpp) {
   6.108 -			case 15:
   6.109 -				/* 1555, big and little endian, unsupported */
   6.110 -				format = OSMESA_RGB_565;
   6.111 -				if (VDI_redmask == 31<<10) {
   6.112 -					GEM_GL_Convert = GEM_GL_Convert565To555be;
   6.113 -				} else {
   6.114 -					GEM_GL_Convert = GEM_GL_Convert565To555le;
   6.115 -				}
   6.116 -				break;
   6.117 -			case 16:
   6.118 -				if (VDI_redmask == 31<<11) {
   6.119 -					format = OSMESA_RGB_565;
   6.120 -				} else {
   6.121 -					/* 565, little endian, unsupported */
   6.122 -					format = OSMESA_RGB_565;
   6.123 -					GEM_GL_Convert = GEM_GL_Convert565le;
   6.124 -				}
   6.125 -				break;
   6.126 -			case 24:
   6.127 -				if (VDI_redmask == 255<<16) {
   6.128 -					format = OSMESA_RGB;
   6.129 -				} else {
   6.130 -					format = OSMESA_BGR;
   6.131 -				}
   6.132 -				break;
   6.133 -			case 32:
   6.134 -				if (VDI_redmask == 255<<16) {
   6.135 -					format = OSMESA_ARGB;
   6.136 -				} else if (VDI_redmask == 255<<8) {
   6.137 -					format = OSMESA_BGRA;
   6.138 -				} else if (VDI_redmask == 255<<24) {
   6.139 -					format = OSMESA_RGBA;
   6.140 -				} else {
   6.141 -					/* ABGR format unsupported */
   6.142 -					format = OSMESA_BGRA;
   6.143 -					GEM_GL_Convert = GEM_GL_ConvertBGRAToABGR;
   6.144 -				}
   6.145 -				break;
   6.146 -		}
   6.147 -
   6.148 -		GEM_ctx = OSMesaCreateContextExt( format, this->gl_config.depth_size,
   6.149 -			this->gl_config.stencil_size, this->gl_config.accum_red_size +
   6.150 -			this->gl_config.accum_green_size + this->gl_config.accum_blue_size +
   6.151 -			this->gl_config.accum_alpha_size, NULL );
   6.152 -		if (!GEM_ctx) {
   6.153 +		if (!SDL_AtariGL_Init(this, current)) {
   6.154  			GEM_FreeBuffers(this);
   6.155 -			SDL_SetError("OSMesaCreateContext failed");
   6.156 -			return(NULL);
   6.157 +			SDL_SetError("Can not create OpenGL context");
   6.158 +			return NULL;
   6.159  		}
   6.160  
   6.161  		modeflags |= SDL_OPENGL;
   6.162 @@ -1356,188 +1288,14 @@
   6.163  
   6.164  #ifdef HAVE_OPENGL
   6.165  
   6.166 -static int GEM_GL_LoadLibrary(_THIS, const char *path)
   6.167 +static void GEM_GL_SwapBuffers(_THIS)
   6.168  {
   6.169 -	/* Library is always opened */
   6.170 -	this->gl_config.driver_loaded = 1;
   6.171 -
   6.172 -	return 0;
   6.173 -}
   6.174 -
   6.175 -static void *GEM_GL_GetProcAddress(_THIS, const char *proc)
   6.176 -{
   6.177 -	void *func = NULL;
   6.178 -
   6.179 -	if (GEM_ctx != NULL) {
   6.180 -		func = OSMesaGetProcAddress(proc);
   6.181 +	if (gl_ctx == NULL) {
   6.182 +		return;
   6.183  	}
   6.184  
   6.185 -	return func;
   6.186 -}
   6.187 -
   6.188 -static int GEM_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
   6.189 -{
   6.190 -	GLenum mesa_attrib;
   6.191 -
   6.192 -	if (GEM_ctx == NULL) {
   6.193 -		return -1;
   6.194 -	}
   6.195 -
   6.196 -	switch(attrib) {
   6.197 -		case SDL_GL_RED_SIZE:
   6.198 -			mesa_attrib = GL_RED_BITS;
   6.199 -			break;
   6.200 -		case SDL_GL_GREEN_SIZE:
   6.201 -			mesa_attrib = GL_GREEN_BITS;
   6.202 -			break;
   6.203 -		case SDL_GL_BLUE_SIZE:
   6.204 -			mesa_attrib = GL_BLUE_BITS;
   6.205 -			break;
   6.206 -		case SDL_GL_ALPHA_SIZE:
   6.207 -			mesa_attrib = GL_ALPHA_BITS;
   6.208 -			break;
   6.209 -		case SDL_GL_DOUBLEBUFFER:
   6.210 -			mesa_attrib = GL_DOUBLEBUFFER;
   6.211 -			break;
   6.212 -		case SDL_GL_DEPTH_SIZE:
   6.213 -			mesa_attrib = GL_DEPTH_BITS;
   6.214 -			break;
   6.215 -		case SDL_GL_STENCIL_SIZE:
   6.216 -			mesa_attrib = GL_STENCIL_BITS;
   6.217 -			break;
   6.218 -		case SDL_GL_ACCUM_RED_SIZE:
   6.219 -			mesa_attrib = GL_ACCUM_RED_BITS;
   6.220 -			break;
   6.221 -		case SDL_GL_ACCUM_GREEN_SIZE:
   6.222 -			mesa_attrib = GL_ACCUM_GREEN_BITS;
   6.223 -			break;
   6.224 -		case SDL_GL_ACCUM_BLUE_SIZE:
   6.225 -			mesa_attrib = GL_ACCUM_BLUE_BITS;
   6.226 -			break;
   6.227 -		case SDL_GL_ACCUM_ALPHA_SIZE:
   6.228 -			mesa_attrib = GL_ACCUM_ALPHA_BITS;
   6.229 -			break;
   6.230 -		default :
   6.231 -			return -1;
   6.232 -	}
   6.233 -
   6.234 -	glGetIntegerv(mesa_attrib, value);
   6.235 -	return 0;
   6.236 -}
   6.237 -
   6.238 -static int GEM_GL_MakeCurrent(_THIS)
   6.239 -{
   6.240 -	SDL_Surface *surface;
   6.241 -	GLenum type;
   6.242 -
   6.243 -	if (GEM_ctx == NULL) {
   6.244 -		return -1;
   6.245 -	}
   6.246 -
   6.247 -	surface = this->screen;
   6.248 -	
   6.249 -	if ((surface->format->BitsPerPixel == 15) || (surface->format->BitsPerPixel == 16)) {
   6.250 -		type = GL_UNSIGNED_SHORT_5_6_5;
   6.251 -	} else {
   6.252 -		type = GL_UNSIGNED_BYTE;
   6.253 -	}
   6.254 -
   6.255 -	if (!OSMesaMakeCurrent(GEM_ctx, surface->pixels, type, surface->w, surface->h)) {
   6.256 -		SDL_SetError("Can not make OpenGL context current");
   6.257 -		return -1;
   6.258 -	}
   6.259 -
   6.260 -	/* OSMesa draws upside down */
   6.261 -	OSMesaPixelStore(OSMESA_Y_UP, 0);
   6.262 -
   6.263 -	return 0;
   6.264 -}
   6.265 -
   6.266 -static void GEM_GL_SwapBuffers(_THIS)
   6.267 -{
   6.268 -	GEM_GL_Convert(this->screen);
   6.269 +	gl_convert(this->screen);
   6.270  	GEM_FlipHWSurface(this, this->screen);
   6.271  }
   6.272  
   6.273 -static void GEM_GL_ConvertNull(SDL_Surface *surface)
   6.274 -{
   6.275 -}
   6.276 -
   6.277 -static void GEM_GL_Convert565To555be(SDL_Surface *surface)
   6.278 -{
   6.279 -	int x,y, pitch;
   6.280 -	unsigned short *line, *pixel;
   6.281 -
   6.282 -	line = surface->pixels;
   6.283 -	pitch = surface->pitch >> 1;
   6.284 -	for (y=0; y<surface->h; y++) {
   6.285 -		pixel = line;
   6.286 -		for (x=0; x<surface->w; x++) {
   6.287 -			unsigned short color = *pixel;
   6.288 -
   6.289 -			*pixel++ = (color & 0x1f)|((color>>1) & 0xffe0);
   6.290 -		}
   6.291 -
   6.292 -		line += pitch;
   6.293 -	}
   6.294 -}
   6.295 -
   6.296 -static void GEM_GL_Convert565To555le(SDL_Surface *surface)
   6.297 -{
   6.298 -	int x,y, pitch;
   6.299 -	unsigned short *line, *pixel;
   6.300 -
   6.301 -	line = surface->pixels;
   6.302 -	pitch = surface->pitch >>1;
   6.303 -	for (y=0; y<surface->h; y++) {
   6.304 -		pixel = line;
   6.305 -		for (x=0; x<surface->w; x++) {
   6.306 -			unsigned short color = *pixel;
   6.307 -
   6.308 -			color = (color & 0x1f)|((color>>1) & 0xffe0);
   6.309 -			*pixel++ = SDL_Swap16(color);
   6.310 -		}
   6.311 -
   6.312 -		line += pitch;
   6.313 -	}
   6.314 -}
   6.315 -
   6.316 -static void GEM_GL_Convert565le(SDL_Surface *surface)
   6.317 -{
   6.318 -	int x,y, pitch;
   6.319 -	unsigned short *line, *pixel;
   6.320 -
   6.321 -	line = surface->pixels;
   6.322 -	pitch = surface->pitch >>1;
   6.323 -	for (y=0; y<surface->h; y++) {
   6.324 -		pixel = line;
   6.325 -		for (x=0; x<surface->w; x++) {
   6.326 -			unsigned short color = *pixel;
   6.327 -
   6.328 -			*pixel++ = SDL_Swap16(color);
   6.329 -		}
   6.330 -
   6.331 -		line += pitch;
   6.332 -	}
   6.333 -}
   6.334 -
   6.335 -static void GEM_GL_ConvertBGRAToABGR(SDL_Surface *surface)
   6.336 -{
   6.337 -	int x,y, pitch;
   6.338 -	unsigned long *line, *pixel;
   6.339 -
   6.340 -	line = surface->pixels;
   6.341 -	pitch = surface->pitch >>2;
   6.342 -	for (y=0; y<surface->h; y++) {
   6.343 -		pixel = line;
   6.344 -		for (x=0; x<surface->w; x++) {
   6.345 -			unsigned long color = *pixel;
   6.346 -
   6.347 -			*pixel++ = (color<<24)|(color>>8);
   6.348 -		}
   6.349 -
   6.350 -		line += pitch;
   6.351 -	}
   6.352 -}
   6.353 -
   6.354  #endif
     7.1 --- a/src/video/gem/SDL_gemvideo.h	Mon Nov 22 20:37:41 2004 +0000
     7.2 +++ b/src/video/gem/SDL_gemvideo.h	Thu Nov 25 15:47:49 2004 +0000
     7.3 @@ -28,10 +28,6 @@
     7.4  #ifndef _SDL_gemvideo_h
     7.5  #define _SDL_gemvideo_h
     7.6  
     7.7 -#ifdef HAVE_OPENGL
     7.8 -#include <GL/osmesa.h>
     7.9 -#endif
    7.10 -
    7.11  #include "SDL_sysvideo.h"
    7.12  #include "SDL_mutex.h"
    7.13  
    7.14 @@ -89,10 +85,6 @@
    7.15  	SDL_bool fullscreen;		/* Fullscreen or windowed mode ? */
    7.16  	SDL_Rect *SDL_modelist[SDL_NUMMODES+1];	/* Mode list */
    7.17  	SDL_Surface *icon;			/* The icon */
    7.18 -
    7.19 -#ifdef HAVE_OPENGL
    7.20 -	OSMesaContext	ctx;		/* OSMesa OpenGL context */
    7.21 -#endif
    7.22  };
    7.23  
    7.24  /* Hidden structure -> variables names */
    7.25 @@ -139,8 +131,6 @@
    7.26  #define GEM_buffer2			(this->hidden->buffer2)
    7.27  #define GEM_bufops			(this->hidden->buf2scr_ops)
    7.28  
    7.29 -#define GEM_ctx				(this->hidden->ctx)
    7.30 -
    7.31  #define VDI_FBMASK(amask, rmask, gmask, bmask) \
    7.32  	VDI_alphamask = (amask); \
    7.33  	VDI_redmask = (rmask); \
     8.1 --- a/src/video/xbios/SDL_xbios.c	Mon Nov 22 20:37:41 2004 +0000
     8.2 +++ b/src/video/xbios/SDL_xbios.c	Thu Nov 25 15:47:49 2004 +0000
     8.3 @@ -37,10 +37,6 @@
     8.4  #include <sys/stat.h>
     8.5  #include <unistd.h>
     8.6  
     8.7 -#ifdef HAVE_OPENGL
     8.8 -#include <GL/osmesa.h>
     8.9 -#endif
    8.10 -
    8.11  /* Mint includes */
    8.12  #include <mint/cookie.h>
    8.13  #include <mint/osbind.h>
    8.14 @@ -57,6 +53,7 @@
    8.15  #include "SDL_ataric2p_s.h"
    8.16  #include "SDL_atarievents_c.h"
    8.17  #include "SDL_atarimxalloc_c.h"
    8.18 +#include "SDL_atarigl_c.h"
    8.19  #include "SDL_xbios.h"
    8.20  
    8.21  #define XBIOS_VID_DRIVER_NAME "xbios"
    8.22 @@ -80,10 +77,6 @@
    8.23  
    8.24  #ifdef HAVE_OPENGL
    8.25  /* OpenGL functions */
    8.26 -static int XBIOS_GL_LoadLibrary(_THIS, const char *path);
    8.27 -static void *XBIOS_GL_GetProcAddress(_THIS, const char *proc);
    8.28 -static int XBIOS_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value);
    8.29 -static int XBIOS_GL_MakeCurrent(_THIS);
    8.30  static void XBIOS_GL_SwapBuffers(_THIS);
    8.31  #endif
    8.32  
    8.33 @@ -196,6 +189,8 @@
    8.34  		memset(device, 0, (sizeof *device));
    8.35  		device->hidden = (struct SDL_PrivateVideoData *)
    8.36  				malloc((sizeof *device->hidden));
    8.37 +		device->gl_data = (struct SDL_PrivateGLData *)
    8.38 +				malloc((sizeof *device->gl_data));
    8.39  	}
    8.40  	if ( (device == NULL) || (device->hidden == NULL) ) {
    8.41  		SDL_OutOfMemory();
    8.42 @@ -205,6 +200,7 @@
    8.43  		return(0);
    8.44  	}
    8.45  	memset(device->hidden, 0, (sizeof *device->hidden));
    8.46 +	memset(device->gl_data, 0, sizeof(*device->gl_data));
    8.47  
    8.48  	/* Video functions */
    8.49  	device->VideoInit = XBIOS_VideoInit;
    8.50 @@ -221,10 +217,10 @@
    8.51  
    8.52  #ifdef HAVE_OPENGL
    8.53  	/* OpenGL functions */
    8.54 -	device->GL_LoadLibrary = XBIOS_GL_LoadLibrary;
    8.55 -	device->GL_GetProcAddress = XBIOS_GL_GetProcAddress;
    8.56 -	device->GL_GetAttribute = XBIOS_GL_GetAttribute;
    8.57 -	device->GL_MakeCurrent = XBIOS_GL_MakeCurrent;
    8.58 +	device->GL_LoadLibrary = SDL_AtariGL_LoadLibrary;
    8.59 +	device->GL_GetProcAddress = SDL_AtariGL_GetProcAddress;
    8.60 +	device->GL_GetAttribute = SDL_AtariGL_GetAttribute;
    8.61 +	device->GL_MakeCurrent = SDL_AtariGL_MakeCurrent;
    8.62  	device->GL_SwapBuffers = XBIOS_GL_SwapBuffers;
    8.63  #endif
    8.64  
    8.65 @@ -415,10 +411,6 @@
    8.66  	/* Init chunky to planar routine */
    8.67  	SDL_Atari_C2pConvert = SDL_Atari_C2pConvert8;
    8.68  
    8.69 -#ifdef HAVE_OPENGL
    8.70 -	this->gl_config.driver_loaded = 1;
    8.71 -#endif
    8.72 -
    8.73  	/* We're done! */
    8.74  	return(0);
    8.75  }
    8.76 @@ -439,11 +431,7 @@
    8.77  	int i;
    8.78  
    8.79  #ifdef HAVE_OPENGL
    8.80 -	/* Shutdown OpenGL context */
    8.81 -	if (XBIOS_ctx) {
    8.82 -		OSMesaDestroyContext(XBIOS_ctx);
    8.83 -		XBIOS_ctx = NULL;
    8.84 -	}
    8.85 +	SDL_AtariGL_Quit(this);
    8.86  #endif
    8.87  
    8.88  	for (i=0;i<2;i++) {
    8.89 @@ -583,23 +571,10 @@
    8.90  
    8.91  #ifdef HAVE_OPENGL
    8.92  	if (flags & SDL_OPENGL) {
    8.93 -		GLenum format;
    8.94 -
    8.95 -		/* Init OpenGL context using OSMesa */
    8.96 -		if (new_depth == 8) {
    8.97 -			format = OSMESA_COLOR_INDEX;
    8.98 -		} else {
    8.99 -			format = OSMESA_RGB_565;
   8.100 -		}
   8.101 -
   8.102 -		XBIOS_ctx = OSMesaCreateContextExt( format, this->gl_config.depth_size,
   8.103 -			this->gl_config.stencil_size, this->gl_config.accum_red_size +
   8.104 -			this->gl_config.accum_green_size + this->gl_config.accum_blue_size +
   8.105 -			this->gl_config.accum_alpha_size, NULL );
   8.106 -		if (!XBIOS_ctx) {
   8.107 +		if (!SDL_AtariGL_Init(this, current)) {
   8.108  			XBIOS_FreeBuffers(this);
   8.109 -			SDL_SetError("OSMesaCreateContext failed");
   8.110 -			return(NULL);
   8.111 +			SDL_SetError("Can not create OpenGL context");
   8.112 +			return NULL;
   8.113  		}
   8.114  
   8.115  		modeflags |= SDL_OPENGL;
   8.116 @@ -899,113 +874,14 @@
   8.117  
   8.118  #ifdef HAVE_OPENGL
   8.119  
   8.120 -/* OpenGL functions */
   8.121 -static int XBIOS_GL_LoadLibrary(_THIS, const char *path)
   8.122 -{
   8.123 -	/* Library is always opened */
   8.124 -	this->gl_config.driver_loaded = 1;
   8.125 -
   8.126 -	return 0;
   8.127 -}
   8.128 -
   8.129 -static void *XBIOS_GL_GetProcAddress(_THIS, const char *proc)
   8.130 -{
   8.131 -	void *func = NULL;
   8.132 -
   8.133 -	if (XBIOS_ctx != NULL) {
   8.134 -		func = OSMesaGetProcAddress(proc);
   8.135 -	}
   8.136 -
   8.137 -	return func;
   8.138 -}
   8.139 -
   8.140 -static int XBIOS_GL_GetAttribute(_THIS, SDL_GLattr attrib, int* value)
   8.141 -{
   8.142 -	GLenum mesa_attrib;
   8.143 -	SDL_Surface *surface;
   8.144 -
   8.145 -	if (XBIOS_ctx == NULL) {
   8.146 -		return -1;
   8.147 -	}
   8.148 -
   8.149 -	switch(attrib) {
   8.150 -		case SDL_GL_RED_SIZE:
   8.151 -			mesa_attrib = GL_RED_BITS;
   8.152 -			break;
   8.153 -		case SDL_GL_GREEN_SIZE:
   8.154 -			mesa_attrib = GL_GREEN_BITS;
   8.155 -			break;
   8.156 -		case SDL_GL_BLUE_SIZE:
   8.157 -			mesa_attrib = GL_BLUE_BITS;
   8.158 -			break;
   8.159 -		case SDL_GL_ALPHA_SIZE:
   8.160 -			mesa_attrib = GL_ALPHA_BITS;
   8.161 -			break;
   8.162 -		case SDL_GL_DOUBLEBUFFER:
   8.163 -			surface = this->screen;
   8.164 -			*value = ((surface->flags & SDL_DOUBLEBUF)==SDL_DOUBLEBUF);
   8.165 -			return 0;
   8.166 -		case SDL_GL_DEPTH_SIZE:
   8.167 -			mesa_attrib = GL_DEPTH_BITS;
   8.168 -			break;
   8.169 -		case SDL_GL_STENCIL_SIZE:
   8.170 -			mesa_attrib = GL_STENCIL_BITS;
   8.171 -			break;
   8.172 -		case SDL_GL_ACCUM_RED_SIZE:
   8.173 -			mesa_attrib = GL_ACCUM_RED_BITS;
   8.174 -			break;
   8.175 -		case SDL_GL_ACCUM_GREEN_SIZE:
   8.176 -			mesa_attrib = GL_ACCUM_GREEN_BITS;
   8.177 -			break;
   8.178 -		case SDL_GL_ACCUM_BLUE_SIZE:
   8.179 -			mesa_attrib = GL_ACCUM_BLUE_BITS;
   8.180 -			break;
   8.181 -		case SDL_GL_ACCUM_ALPHA_SIZE:
   8.182 -			mesa_attrib = GL_ACCUM_ALPHA_BITS;
   8.183 -			break;
   8.184 -		default :
   8.185 -			return -1;
   8.186 -	}
   8.187 -
   8.188 -	glGetIntegerv(mesa_attrib, value);
   8.189 -	return 0;
   8.190 -}
   8.191 -
   8.192 -static int XBIOS_GL_MakeCurrent(_THIS)
   8.193 -{
   8.194 -	SDL_Surface *surface;
   8.195 -	GLenum type;
   8.196 -
   8.197 -	if (XBIOS_ctx == NULL) {
   8.198 -		return -1;
   8.199 -	}
   8.200 -
   8.201 -	surface = this->screen;
   8.202 -	if ((surface->format->BitsPerPixel) == 8) {
   8.203 -		type = GL_UNSIGNED_BYTE;
   8.204 -	} else {
   8.205 -		type = GL_UNSIGNED_SHORT_5_6_5;
   8.206 -	}
   8.207 -
   8.208 -	if (!OSMesaMakeCurrent(XBIOS_ctx, surface->pixels, type, surface->w, surface->h)) {
   8.209 -		SDL_SetError("Can not make OpenGL context current");
   8.210 -		return -1;
   8.211 -	}
   8.212 -
   8.213 -	/* OSMesa draws upside down */
   8.214 -	OSMesaPixelStore(OSMESA_Y_UP, 0);
   8.215 -
   8.216 -	return 0;
   8.217 -}
   8.218 -
   8.219  static void XBIOS_GL_SwapBuffers(_THIS)
   8.220  {
   8.221 -	if (XBIOS_ctx == NULL) {
   8.222 +	if (gl_ctx == NULL) {
   8.223  		return;
   8.224  	}
   8.225  
   8.226  	XBIOS_FlipHWSurface(this, this->screen);
   8.227 -	XBIOS_GL_MakeCurrent(this);
   8.228 +	SDL_AtariGL_MakeCurrent(this);
   8.229  }
   8.230  
   8.231  #endif
     9.1 --- a/src/video/xbios/SDL_xbios.h	Mon Nov 22 20:37:41 2004 +0000
     9.2 +++ b/src/video/xbios/SDL_xbios.h	Thu Nov 25 15:47:49 2004 +0000
     9.3 @@ -28,10 +28,6 @@
     9.4  #ifndef _SDL_xbios_h
     9.5  #define _SDL_xbios_h
     9.6  
     9.7 -#ifdef HAVE_OPENGL
     9.8 -#include <GL/osmesa.h>
     9.9 -#endif
    9.10 -
    9.11  #include "SDL_types.h"
    9.12  #include "SDL_sysvideo.h"
    9.13  
    9.14 @@ -73,9 +69,6 @@
    9.15  	int frame_number;		/* Number of frame for double buffer */
    9.16  	int pitch;				/* Destination line width for C2P */
    9.17  	int width, height;		/* Screen size for centered C2P */
    9.18 -#ifdef HAVE_OPENGL
    9.19 -	OSMesaContext ctx;		/* OpenGL OSMesa context */
    9.20 -#endif
    9.21  
    9.22  	SDL_Rect *SDL_modelist[NUM_MODELISTS][SDL_NUMMODES+1];
    9.23  	xbiosmode_t *videomodes[NUM_MODELISTS][SDL_NUMMODES+1];
    9.24 @@ -130,8 +123,5 @@
    9.25  #define XBIOS_pitch			(this->hidden->pitch)
    9.26  #define XBIOS_width			(this->hidden->width)
    9.27  #define XBIOS_height		(this->hidden->height)
    9.28 -#ifdef HAVE_OPENGL
    9.29 -#define XBIOS_ctx			(this->hidden->ctx)
    9.30 -#endif
    9.31  
    9.32  #endif /* _SDL_xbios_h */