Skip to content
This repository has been archived by the owner. It is now read-only.
Permalink
Browse files

glSDL support

  • Loading branch information
slouken committed May 1, 2006
1 parent 151966f commit 0e4dcc23d9d4aaa70c2fcf12a3cf79c291b01c82
Showing with 2,757 additions and 112 deletions.
  1. +1 −0 Makefile.dc
  2. +20 −0 configure.in
  3. +1 −0 include/SDL_config.h.in
  4. +1 −0 include/SDL_config_amiga.h
  5. +1 −0 include/SDL_config_dreamcast.h
  6. +1 −0 include/SDL_config_macos.h
  7. +1 −0 include/SDL_config_macosx.h
  8. +3 −0 include/SDL_config_win32.h
  9. +1 −1 include/SDL_video.h
  10. +1 −1 src/video/SDL_blit.c
  11. +9 −9 src/video/SDL_glfuncs.h
  12. +4 −1 src/video/SDL_sysvideo.h
  13. +14 −11 src/video/SDL_video.c
  14. +1 −1 src/video/bwindow/SDL_BWin.h
  15. +3 −3 src/video/bwindow/SDL_sysvideo.cc
  16. +1 −1 src/video/cybergfx/SDL_cgximage.c
  17. +9 −9 src/video/cybergfx/SDL_cgxvideo.c
  18. +4 −4 src/video/dc/SDL_dcvideo.c
  19. +2 −2 src/video/gem/SDL_gemvideo.c
  20. +2,573 −0 src/video/glsdl/SDL_glsdl.c
  21. +38 −0 src/video/glsdl/SDL_glsdl.h
  22. +1 −1 src/video/maccommon/SDL_macevents.c
  23. +4 −4 src/video/macdsp/SDL_dspvideo.c
  24. +2 −2 src/video/macrom/SDL_romvideo.c
  25. +3 −3 src/video/photon/SDL_ph_image.c
  26. +2 −2 src/video/photon/SDL_ph_modes.c
  27. +2 −2 src/video/photon/SDL_ph_mouse.c
  28. +2 −2 src/video/photon/SDL_ph_video.c
  29. +1 −1 src/video/qtopia/SDL_sysvideo.cc
  30. +8 −8 src/video/quartz/SDL_QuartzVideo.m
  31. +2 −2 src/video/quartz/SDL_QuartzWM.m
  32. +4 −4 src/video/quartz/SDL_QuartzWindow.m
  33. +7 −7 src/video/wincommon/SDL_lowvideo.h
  34. +1 −1 src/video/wincommon/SDL_sysevents.c
  35. +5 −5 src/video/windib/SDL_dibvideo.c
  36. +1 −1 src/video/windx5/SDL_dx5events.c
  37. +8 −8 src/video/windx5/SDL_dx5video.c
  38. +1 −1 src/video/x11/SDL_x11events.c
  39. +1 −1 src/video/x11/SDL_x11image.c
  40. +2 −2 src/video/x11/SDL_x11modes.c
  41. +8 −8 src/video/x11/SDL_x11video.c
  42. +3 −3 src/video/xbios/SDL_xbios.c
  43. +0 −1 test/testblitspeed.c
@@ -55,6 +55,7 @@ SRCS = \
src/video/dummy/SDL_nullevents.c \
src/video/dummy/SDL_nullmouse.c \
src/video/dummy/SDL_nullvideo.c \
src/video/glsdl/SDL_glsdl.c \
src/video/SDL_blit.c \
src/video/SDL_blit_0.c \
src/video/SDL_blit_1.c \
@@ -1459,6 +1459,20 @@ CheckMacGL()
fi
}

dnl Find glSDL
CheckglSDL()
{
AC_ARG_ENABLE(video-glsdl,
[ --enable-video-glsdl use glSDL video driver [default=yes]],
, enable_video_glsdl=yes)
AC_MSG_CHECKING(for glSDL support)
AC_MSG_RESULT($video_opengl)
if test x$video_opengl = xyes -a x$enable_video_glsdl = xyes; then
AC_DEFINE(SDL_VIDEO_DRIVER_GLSDL)
SOURCES="$SOURCES $srcdir/src/video/glsdl/*.c"
fi
}

dnl Check for Mesa offscreen rendering
CheckAtariOSMesa()
{
@@ -2080,6 +2094,7 @@ case "$host" in
CheckQtopia
CheckPicoGUI
CheckOpenGLX11
CheckglSDL
CheckInputEvents
CheckTslib
CheckUSBHID
@@ -2178,6 +2193,7 @@ case "$host" in
CheckPHOTON
CheckX11
CheckOpenGLX11
CheckglSDL
CheckPTHREAD
# Set up files for the audio library
if test x$enable_audio = xyes; then
@@ -2215,6 +2231,7 @@ case "$host" in
CheckDummyAudio
CheckWIN32
CheckWIN32GL
CheckglSDL
CheckDIRECTX
CheckNASM
# Set up files for the audio library
@@ -2279,6 +2296,7 @@ case "$host" in
CheckNASM
CheckBWINDOW
CheckBeGL
CheckglSDL
# Set up files for the audio library
if test x$enable_audio = xyes; then
AC_DEFINE(SDL_AUDIO_DRIVER_BAUDIO)
@@ -2356,6 +2374,7 @@ case "$host" in
CheckX11
CheckMacGL
CheckOpenGLX11
CheckglSDL
CheckPTHREAD
CheckAltivec

@@ -2417,6 +2436,7 @@ case "$host" in
CheckAtariAudio
CheckAtariLdg
CheckAtariOSMesa
CheckglSDL
CheckPTH
# Set up files for the audio library
if test x$enable_threads = xyes -a x$enable_pth = xyes; then
@@ -262,6 +262,7 @@
#undef SDL_VIDEO_DRIVER_GAPI
#undef SDL_VIDEO_DRIVER_GEM
#undef SDL_VIDEO_DRIVER_GGI
#undef SDL_VIDEO_DRIVER_GLSDL
#undef SDL_VIDEO_DRIVER_IPOD
#undef SDL_VIDEO_DRIVER_NANOX
#undef SDL_VIDEO_DRIVER_OS2FS
@@ -73,6 +73,7 @@
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_CYBERGRAPHICS 1
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_GLSDL 1

/* Enable OpenGL support */
#define SDL_VIDEO_OPENGL 1
@@ -102,5 +102,6 @@ typedef unsigned long uintptr_t;
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_DC 1
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_GLSDL 1

#endif /* _SDL_config_dreamcast_h */
@@ -90,6 +90,7 @@ typedef unsigned long uintptr_t;
/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_DRAWSPROCKET 1
#define SDL_VIDEO_DRIVER_GLSDL 1
#define SDL_VIDEO_DRIVER_TOOLBOX 1

/* Enable OpenGL support */
@@ -116,6 +116,7 @@

/* Enable various video drivers */
#define SDL_VIDEO_DRIVER_DUMMY 1
#define SDL_VIDEO_DRIVER_GLSDL 1
#define SDL_VIDEO_DRIVER_QUARTZ 1

/* Enable OpenGL support */
@@ -155,6 +155,9 @@ typedef unsigned int uintptr_t;
#define SDL_VIDEO_DRIVER_DDRAW 1
#endif
#define SDL_VIDEO_DRIVER_DUMMY 1
#ifndef _WIN32_WCE
#define SDL_VIDEO_DRIVER_GLSDL 1
#endif
#define SDL_VIDEO_DRIVER_WINDIB 1

/* Enable OpenGL support */
@@ -124,7 +124,7 @@ typedef struct SDL_Surface {
#define SDL_DOUBLEBUF 0x40000000 /* Set up double-buffered video mode */
#define SDL_FULLSCREEN 0x80000000 /* Surface is a full screen display */
#define SDL_OPENGL 0x00000002 /* Create an OpenGL rendering context */
#define SDL_OPENGLBLIT_OBSOLETE 0x0000000A /* Obsolete, do not use! */
#define SDL_INTERNALOPENGL 0x00000008 /* SDL uses OpenGL internally for this window */
#define SDL_RESIZABLE 0x00000010 /* This video mode may be resized */
#define SDL_NOFRAME 0x00000020 /* No window caption or edge frame */
/* Used internally (read-only) */
@@ -281,7 +281,7 @@ int SDL_CalculateBlit(SDL_Surface *surface)
video->CheckHWBlit(this, surface, surface->map->dst);
}
}

/* Get the blit function index, based on surface mode */
/* { 0 = nothing, 1 = colorkey, 2 = alpha, 3 = colorkey+alpha } */
blit_index = 0;
@@ -30,7 +30,7 @@ SDL_PROC_UNUSED(void,glColor3i,(GLint,GLint,GLint))
SDL_PROC_UNUSED(void,glColor3iv,(const GLint*))
SDL_PROC_UNUSED(void,glColor3s,(GLshort,GLshort,GLshort))
SDL_PROC_UNUSED(void,glColor3sv,(const GLshort*))
SDL_PROC_UNUSED(void,glColor3ub,(GLubyte,GLubyte,GLubyte))
SDL_PROC(void,glColor3ub,(GLubyte,GLubyte,GLubyte))
SDL_PROC_UNUSED(void,glColor3ubv,(const GLubyte*))
SDL_PROC_UNUSED(void,glColor3ui,(GLuint,GLuint,GLuint))
SDL_PROC_UNUSED(void,glColor3uiv,(const GLuint*))
@@ -46,7 +46,7 @@ SDL_PROC_UNUSED(void,glColor4i,(GLint,GLint,GLint,GLint))
SDL_PROC_UNUSED(void,glColor4iv,(const GLint*))
SDL_PROC_UNUSED(void,glColor4s,(GLshort,GLshort,GLshort,GLshort))
SDL_PROC_UNUSED(void,glColor4sv,(const GLshort*))
SDL_PROC_UNUSED(void,glColor4ub,(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
SDL_PROC(void,glColor4ub,(GLubyte red, GLubyte green, GLubyte blue, GLubyte alpha))
SDL_PROC_UNUSED(void,glColor4ubv,(const GLubyte *v))
SDL_PROC_UNUSED(void,glColor4ui,(GLuint red, GLuint green, GLuint blue, GLuint alpha))
SDL_PROC_UNUSED(void,glColor4uiv,(const GLuint *v))
@@ -62,14 +62,14 @@ SDL_PROC_UNUSED(void,glCopyTexSubImage1D,(GLenum target, GLint level, GLint xoff
SDL_PROC_UNUSED(void,glCopyTexSubImage2D,(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLint x, GLint y, GLsizei width, GLsizei height))
SDL_PROC_UNUSED(void,glCullFace,(GLenum mode))
SDL_PROC_UNUSED(void,glDeleteLists,(GLuint list, GLsizei range))
SDL_PROC_UNUSED(void,glDeleteTextures,(GLsizei n, const GLuint *textures))
SDL_PROC(void,glDeleteTextures,(GLsizei n, const GLuint *textures))
SDL_PROC_UNUSED(void,glDepthFunc,(GLenum func))
SDL_PROC_UNUSED(void,glDepthMask,(GLboolean flag))
SDL_PROC_UNUSED(void,glDepthRange,(GLclampd zNear, GLclampd zFar))
SDL_PROC(void,glDisable,(GLenum cap))
SDL_PROC_UNUSED(void,glDisableClientState,(GLenum array))
SDL_PROC_UNUSED(void,glDrawArrays,(GLenum mode, GLint first, GLsizei count))
SDL_PROC_UNUSED(void,glDrawBuffer,(GLenum mode))
SDL_PROC(void,glDrawBuffer,(GLenum mode))
SDL_PROC_UNUSED(void,glDrawElements,(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices))
SDL_PROC_UNUSED(void,glDrawPixels,(GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels))
SDL_PROC_UNUSED(void,glEdgeFlag,(GLboolean flag))
@@ -92,7 +92,7 @@ SDL_PROC_UNUSED(void,glEvalMesh2,(GLenum mode, GLint i1, GLint i2, GLint j1, GLi
SDL_PROC_UNUSED(void,glEvalPoint1,(GLint i))
SDL_PROC_UNUSED(void,glEvalPoint2,(GLint i, GLint j))
SDL_PROC_UNUSED(void,glFeedbackBuffer,(GLsizei size, GLenum type, GLfloat *buffer))
SDL_PROC_UNUSED(void,glFinish,(void))
SDL_PROC(void,glFinish,(void))
SDL_PROC(void,glFlush,(void))
SDL_PROC_UNUSED(void,glFogf,(GLenum pname, GLfloat param))
SDL_PROC_UNUSED(void,glFogfv,(GLenum pname, const GLfloat *params))
@@ -105,9 +105,9 @@ SDL_PROC(void,glGenTextures,(GLsizei n, GLuint *textures))
SDL_PROC_UNUSED(void,glGetBooleanv,(GLenum pname, GLboolean *params))
SDL_PROC_UNUSED(void,glGetClipPlane,(GLenum plane, GLdouble *equation))
SDL_PROC_UNUSED(void,glGetDoublev,(GLenum pname, GLdouble *params))
SDL_PROC_UNUSED(GLenum,glGetError,(void))
SDL_PROC(GLenum,glGetError,(void))
SDL_PROC_UNUSED(void,glGetFloatv,(GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void,glGetIntegerv,(GLenum pname, GLint *params))
SDL_PROC(void,glGetIntegerv,(GLenum pname, GLint *params))
SDL_PROC_UNUSED(void,glGetLightfv,(GLenum light, GLenum pname, GLfloat *params))
SDL_PROC_UNUSED(void,glGetLightiv,(GLenum light, GLenum pname, GLint *params))
SDL_PROC_UNUSED(void,glGetMapdv,(GLenum target, GLenum query, GLdouble *v))
@@ -240,7 +240,7 @@ SDL_PROC_UNUSED(void,glRasterPos4iv,(const GLint *v))
SDL_PROC_UNUSED(void,glRasterPos4s,(GLshort x, GLshort y, GLshort z, GLshort w))
SDL_PROC_UNUSED(void,glRasterPos4sv,(const GLshort *v))
SDL_PROC_UNUSED(void,glReadBuffer,(GLenum mode))
SDL_PROC_UNUSED(void,glReadPixels,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels))
SDL_PROC(void,glReadPixels,(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLvoid *pixels))
SDL_PROC_UNUSED(void,glRectd,(GLdouble x1, GLdouble y1, GLdouble x2, GLdouble y2))
SDL_PROC_UNUSED(void,glRectdv,(const GLdouble *v1, const GLdouble *v2))
SDL_PROC_UNUSED(void,glRectf,(GLfloat x1, GLfloat y1, GLfloat x2, GLfloat y2))
@@ -311,7 +311,7 @@ SDL_PROC(void,glTexParameteri,(GLenum target, GLenum pname, GLint param))
SDL_PROC_UNUSED(void,glTexParameteriv,(GLenum target, GLenum pname, const GLint *params))
SDL_PROC_UNUSED(void,glTexSubImage1D,(GLenum target, GLint level, GLint xoffset, GLsizei width, GLenum format, GLenum type, const GLvoid *pixels))
SDL_PROC(void,glTexSubImage2D,(GLenum target, GLint level, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height, GLenum format, GLenum type, const GLvoid *pixels))
SDL_PROC_UNUSED(void,glTranslated,(GLdouble x, GLdouble y, GLdouble z))
SDL_PROC(void,glTranslated,(GLdouble x, GLdouble y, GLdouble z))
SDL_PROC_UNUSED(void,glTranslatef,(GLfloat x, GLfloat y, GLfloat z))
SDL_PROC_UNUSED(void,glVertex2d,(GLdouble x, GLdouble y))
SDL_PROC_UNUSED(void,glVertex2dv,(const GLdouble *v))
@@ -119,7 +119,7 @@ struct SDL_VideoDevice {

/* The pixel format used when SDL_CreateRGBSurface creates SDL_HWSURFACEs with alpha */
SDL_PixelFormat* displayformatalphapixel;

/* Allocates a surface in video memory */
int (*AllocHWSurface)(_THIS, SDL_Surface *surface);

@@ -407,6 +407,9 @@ extern VideoBootStrap AALIB_bootstrap;
#if SDL_VIDEO_DRIVER_DUMMY
extern VideoBootStrap DUMMY_bootstrap;
#endif
#if SDL_VIDEO_DRIVER_GLSDL
extern VideoBootStrap glSDL_bootstrap;
#endif

/* This is the current video device */
extern SDL_VideoDevice *current_video;
@@ -122,6 +122,9 @@ static VideoBootStrap *bootstrap[] = {
#endif
#if SDL_VIDEO_DRIVER_DUMMY
&DUMMY_bootstrap,
#endif
#if SDL_VIDEO_DRIVER_GLSDL
&glSDL_bootstrap,
#endif
NULL
};
@@ -575,12 +578,6 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
int is_opengl;
SDL_GrabMode saved_grab;

/* Handle obsolete flags */
if ( (flags & SDL_OPENGLBLIT_OBSOLETE) == SDL_OPENGLBLIT_OBSOLETE ) {
SDL_SetError("SDL_OPENGLBLIT is no longer supported");
return(NULL);
}

/* Start up the video driver, if necessary..
WARNING: This is the only function protected this way!
*/
@@ -613,8 +610,12 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
}

/* Check the requested flags */
/* There's no palette in > 8 bits-per-pixel mode */
if ( flags & SDL_INTERNALOPENGL ) {
SDL_SetError("SDL_INTERNALOPENGL is for internal use only");
return(NULL);
}
if ( video_bpp > 8 ) {
/* There's no palette in > 8 bits-per-pixel mode */
flags &= ~SDL_HWPALETTE;
}
#if 0
@@ -632,6 +633,8 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
if ( is_opengl ) {
/* These flags are for 2D video modes only */
flags &= ~(SDL_HWSURFACE|SDL_DOUBLEBUF);
/* This flag tells the backends to treat the surface accordingly */
flags |= SDL_INTERNALOPENGL;
}

/* Reset the keyboard here so event callbacks can run */
@@ -674,7 +677,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
#endif

/* Sam - If we asked for OpenGL mode, and didn't get it, fail */
if ( is_opengl && !(mode->flags & SDL_OPENGL) ) {
if ( is_opengl && !(mode->flags & SDL_INTERNALOPENGL) ) {
mode = NULL;
SDL_SetError("OpenGL not available");
}
@@ -752,7 +755,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)

#if SDL_VIDEO_OPENGL
/* Load GL symbols (before MakeCurrent, where we need glGetString). */
if ( flags & SDL_OPENGL ) {
if ( flags & SDL_INTERNALOPENGL ) {

#if defined(__QNXNTO__) && (_NTO_VERSION < 630)
#define __SDL_NOGETPROCADDR__
@@ -779,7 +782,7 @@ SDL_Surface * SDL_SetVideoMode (int width, int height, int bpp, Uint32 flags)
#endif /* SDL_VIDEO_OPENGL */

/* If we're running OpenGL, make the context current */
if ( (video->screen->flags & SDL_OPENGL) &&
if ( (video->screen->flags & SDL_INTERNALOPENGL) &&
video->GL_MakeCurrent ) {
if ( video->GL_MakeCurrent(this) < 0 ) {
return(NULL);
@@ -1431,7 +1434,7 @@ void SDL_GL_SwapBuffers(void)
SDL_VideoDevice *video = current_video;
SDL_VideoDevice *this = current_video;

if ( video->screen->flags & SDL_OPENGL ) {
if ( video->screen->flags & SDL_INTERNALOPENGL ) {
video->GL_SwapBuffers(this);
} else {
SDL_SetError("OpenGL video mode has not been set");
@@ -219,7 +219,7 @@ class SDL_BWin : public BDirectWindow

retval = 0;
Lock();
if ( flags & SDL_OPENGL ) {
if ( flags & SDL_INTERNALOPENGL ) {
#if SDL_VIDEO_OPENGL
if ( SDL_GLView == NULL ) {
SDL_GLView = new BGLView(Bounds(), "SDL GLView",
@@ -525,7 +525,7 @@ SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current,
current->flags |= SDL_NOFRAME;
SDL_Win->SetLook(B_NO_BORDER_WINDOW_LOOK);
} else {
if ( (flags & SDL_RESIZABLE) && !(flags & SDL_OPENGL) ) {
if ( (flags & SDL_RESIZABLE) && !(flags & SDL_INTERNALOPENGL) ) {
current->flags |= SDL_RESIZABLE;
/* We don't want opaque resizing (TM). :-) */
SDL_Win->SetFlags(B_OUTLINE_RESIZE);
@@ -534,8 +534,8 @@ SDL_Surface *BE_SetVideoMode(_THIS, SDL_Surface *current,
}
}

if ( flags & SDL_OPENGL ) {
current->flags |= SDL_OPENGL;
if ( flags & SDL_INTERNALOPENGL ) {
current->flags |= SDL_INTERNALOPENGL;
current->pitch = 0;
current->pixels = NULL;
_this->UpdateRects = NULL;
@@ -135,7 +135,7 @@ int CGX_ResizeImage(_THIS, SDL_Surface *screen, Uint32 flags)

CGX_DestroyImage(this, screen);

if ( flags & SDL_OPENGL ) { /* No image when using GL */
if ( flags & SDL_INTERNALOPENGL ) { /* No image when using GL */
retval = 0;
} else {
retval = CGX_SetupImage(this, screen);

0 comments on commit 0e4dcc2

Please sign in to comment.