19682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* 29682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL - Simple DirectMedia Layer 39682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Copyright (C) 1997-2012 Sam Lantinga 49682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 59682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is free software; you can redistribute it and/or 69682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall modify it under the terms of the GNU Library General Public 79682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License as published by the Free Software Foundation; either 89682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall version 2 of the License, or (at your option) any later version. 99682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 109682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall This library is distributed in the hope that it will be useful, 119682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall but WITHOUT ANY WARRANTY; without even the implied warranty of 129682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 139682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Library General Public License for more details. 149682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 159682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall You should have received a copy of the GNU Library General Public 169682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall License along with this library; if not, write to the Free 179682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 189682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 199682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Sam Lantinga 209682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall slouken@libsdl.org 219682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall*/ 229682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "SDL_config.h" 239682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 249682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Atari OSMesa.ldg implementation of SDL OpenGL support */ 259682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 269682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#ifndef _SDL_ATARIGL_H_ 279682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define _SDL_ATARIGL_H_ 289682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 299682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 309682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include <GL/osmesa.h> 319682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 329682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 339682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#include "../SDL_sysvideo.h" 349682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 359682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Hidden "this" pointer for the video functions */ 369682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define _THIS SDL_VideoDevice *this 379682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 389682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallstruct SDL_PrivateGLData { 399682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 409682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int gl_active; /* to stop switching drivers while we have a valid context */ 419682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 429682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int gl_oldmesa; /* Old OpenGL support ? */ 439682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 449682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int gl_pixelsize; /* for CopyShadow functions */ 459682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 469682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall SDL_bool gl_upsidedown; /* Some implementations draw upside down */ 479682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 489682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall Uint8 *gl_shadow; /* Shadow buffer for old implementations */ 499682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 509682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* for unsupported OSMesa buffer formats */ 519682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*ConvertSurface)(_THIS, SDL_Surface *surface); 529682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 539682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* to convert the shadow buffer to the screen format */ 549682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*CopyShadow)(_THIS, SDL_Surface *surface); 559682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 569682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#if SDL_VIDEO_OPENGL 579682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSMesaContext ctx; 589682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 599682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* OpenGL functions */ 609682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*glGetIntegerv)( GLenum pname, GLint *value ); 619682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*glFinish)(void); 629682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*glFlush)(void); 639682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 649682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* osmesa.ldg */ 659682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall OSMesaContext (*OSMesaCreateContextExt)( GLenum format, GLint depthBits, GLint stencilBits, GLint accumBits, OSMesaContext sharelist); 669682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*OSMesaDestroyContext)( OSMesaContext ctx ); 679682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLboolean (*OSMesaMakeCurrent)( OSMesaContext ctx, void *buffer, GLenum type, GLsizei width, GLsizei height ); 689682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*OSMesaPixelStore)( GLint pname, GLint value ); 699682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void * (*OSMesaGetProcAddress)( const char *funcName ); 709682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 719682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* mesa_gl.ldg, tiny_gl.ldg */ 729682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void *(*OSMesaCreateLDG)( long format, long type, long width, long height ); 739682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall void (*OSMesaDestroyLDG)(void); 749682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 759682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall /* Info needed to compare existing context with new asked one */ 769682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall int width, height; 779682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLenum format; 789682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall GLint depth,stencil,accum; 799682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif 809682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall}; 819682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 829682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* Variable names */ 839682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_active (this->gl_data->gl_active) 849682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_ctx (this->gl_data->ctx) 859682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_oldmesa (this->gl_data->gl_oldmesa) 869682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_pixelsize (this->gl_data->gl_pixelsize) 879682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_upsidedown (this->gl_data->gl_upsidedown) 889682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_shadow (this->gl_data->gl_shadow) 899682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_convert (this->gl_data->ConvertSurface) 909682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_copyshadow (this->gl_data->CopyShadow) 919682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_curformat (this->gl_data->format) 929682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_curdepth (this->gl_data->depth) 939682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_curstencil (this->gl_data->stencil) 949682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_curaccum (this->gl_data->accum) 959682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_curwidth (this->gl_data->width) 969682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#define gl_curheight (this->gl_data->height) 979682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 989682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall/* OpenGL functions */ 999682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern int SDL_AtariGL_Init(_THIS, SDL_Surface *current); 1009682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SDL_AtariGL_Quit(_THIS, SDL_bool unload); 1019682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SDL_AtariGL_InitPointers(_THIS); 1029682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1039682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern int SDL_AtariGL_LoadLibrary(_THIS, const char *path); 1049682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void *SDL_AtariGL_GetProcAddress(_THIS, const char *proc); 1059682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern int SDL_AtariGL_GetAttribute(_THIS, SDL_GLattr attrib, int* value); 1069682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern int SDL_AtariGL_MakeCurrent(_THIS); 1079682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hallextern void SDL_AtariGL_SwapBuffers(_THIS); 1089682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall 1099682c8870b8ff5e4ac2e4c70b759f791c6f38c1fJesse Hall#endif /* _SDL_ATARIGL_H_ */ 110