Schism Tracker

changeset 2729:d03801319cb3

make opengl headers optional (for embedded systems) - thanks stuckie
author Storlek <storlek@rigelseven.com>
date Fri Jun 18 21:03:04 2010 -0400 (23 months ago)
parents ec708d886bb0
children 37d753d64150
files configure.ac include/sdlmain.h schism/video.c
line diff
     1.1 --- a/configure.ac	Thu Feb 25 22:30:26 2010 -0500
     1.2 +++ b/configure.ac	Fri Jun 18 21:03:04 2010 -0400
     1.3 @@ -156,6 +156,12 @@
     1.4  	fi
     1.5  fi
     1.6  
     1.7 +dnl OpenGL crud - it doesn't always exist
     1.8 +saved_cppflags=$CPPFLAGS
     1.9 +CPPFLAGS="$CPPFLAGS $SDL_CFLAGS"
    1.10 +AC_CHECK_HEADER([SDL_opengl.h], [AC_DEFINE([USE_OPENGL], 1, [Define to 1 if SDL's OpenGL works])])
    1.11 +CPPFLAGS=$saved_cppflags
    1.12 +
    1.13  dnl -----------------------------------------------------------------------
    1.14  
    1.15  saved_libs=$LIBS
     2.1 --- a/include/sdlmain.h	Thu Feb 25 22:30:26 2010 -0500
     2.2 +++ b/include/sdlmain.h	Fri Jun 18 21:03:04 2010 -0400
     2.3 @@ -7,14 +7,6 @@
     2.4  
     2.5  /* just a fancy way to get SDL headers */
     2.6  
     2.7 -#  ifndef _USE_AUTOCONF
     2.8 -#    ifdef _SDL_IN_PATH
     2.9 -#      undef _SDL_BY_PATH
    2.10 -#    else
    2.11 -#      define _SDL_BY_PATH
    2.12 -#    endif
    2.13 -#  endif
    2.14 -
    2.15  #  ifdef USE_X11
    2.16  #    undef DISABLE_X11
    2.17  #    ifndef __unix__
    2.18 @@ -22,18 +14,11 @@
    2.19  #    endif
    2.20  #  endif
    2.21  
    2.22 -#  ifdef _SDL_BY_PATH
    2.23 -#    include <SDL/SDL.h>
    2.24 -#    include <SDL/SDL_thread.h>
    2.25 -#    ifndef __cplusplus
    2.26 -#      include <SDL/SDL_syswm.h>
    2.27 -#      include <SDL/SDL_opengl.h>
    2.28 -#    endif
    2.29 -#  else
    2.30 -#    include <SDL.h>
    2.31 -#    include <SDL_thread.h>
    2.32 -#    ifndef __cplusplus
    2.33 -#      include <SDL_syswm.h>
    2.34 +#  include <SDL.h>
    2.35 +#  include <SDL_thread.h>
    2.36 +#  ifndef __cplusplus
    2.37 +#    include <SDL_syswm.h>
    2.38 +#    ifdef USE_OPENGL
    2.39  #      include <SDL_opengl.h>
    2.40  #    endif
    2.41  #  endif
     3.1 --- a/schism/video.c	Thu Feb 25 22:30:26 2010 -0500
     3.2 +++ b/schism/video.c	Fri Jun 18 21:03:04 2010 -0400
     3.3 @@ -78,6 +78,19 @@
     3.4  
     3.5  #define NVIDIA_PixelDataRange   1
     3.6  
     3.7 +#if !defined(USE_OPENGL)
     3.8 +typedef unsigned int GLuint;
     3.9 +typedef int GLint;
    3.10 +typedef int GLenum;
    3.11 +typedef int GLsizei;
    3.12 +typedef void GLvoid;
    3.13 +typedef float GLfloat;
    3.14 +typedef int GLboolean;
    3.15 +typedef int GLbitfield;
    3.16 +typedef float GLclampf;
    3.17 +typedef unsigned char GLubyte;
    3.18 +#endif
    3.19 +
    3.20  #ifdef NVIDIA_PixelDataRange
    3.21  
    3.22  #ifndef WGL_NV_allocate_memory
    3.23 @@ -569,7 +582,9 @@
    3.24  void video_startup(void)
    3.25  {
    3.26          UNUSED static int did_this_2 = 0;
    3.27 +#if USE_OPENGL
    3.28          const char *gl_ext;
    3.29 +#endif
    3.30          char *q;
    3.31          SDL_Rect **modes;
    3.32          int i, j, x, y;
    3.33 @@ -633,6 +648,7 @@
    3.34  SKIP1:
    3.35  #endif
    3.36          if (video.desktop.want_type == VIDEO_GL) {
    3.37 +#if defined(USE_OPENGL)
    3.38                  video.surface = SDL_SetVideoMode(640,400,0,SDL_OPENGL|SDL_RESIZABLE);
    3.39                  if (!video.surface) {
    3.40                          /* fallback */
    3.41 @@ -658,6 +674,7 @@
    3.42                  video.gl.pixel_data_range=(strstr(gl_ext,"GL_NV_pixel_data_range") != NULL)
    3.43                          && glPixelDataRangeNV && db_glAllocateMemoryNV && db_glFreeMemoryNV;
    3.44  #endif
    3.45 +#endif // USE_OPENGL
    3.46          }
    3.47  
    3.48          x = y = -1;
    3.49 @@ -883,8 +900,10 @@
    3.50  
    3.51  void video_resize(unsigned int width, unsigned int height)
    3.52  {
    3.53 +#if USE_OPENGL
    3.54          GLfloat tex_width, tex_height;
    3.55          int texsize;
    3.56 +#endif
    3.57  
    3.58          if (!height) height = NATIVE_SCREEN_HEIGHT;
    3.59          if (!width) width = NATIVE_SCREEN_WIDTH;
    3.60 @@ -1021,6 +1040,7 @@
    3.61                  };
    3.62                  video.desktop.type = VIDEO_YUV;
    3.63                  break;
    3.64 +#if defined(USE_OPENGL)
    3.65          case VIDEO_GL:
    3.66                  _set_gl_attributes();
    3.67                  _setup_surface(width, height, SDL_OPENGL);
    3.68 @@ -1102,6 +1122,7 @@
    3.69                  my_glEndList();
    3.70                  video.desktop.type = VIDEO_GL;
    3.71                  break;
    3.72 +#endif // USE_OPENGL
    3.73          };
    3.74  
    3.75          status.flags |= (NEED_UPDATE);
    3.76 @@ -1699,6 +1720,7 @@
    3.77                  SDL_UnlockYUVOverlay(video.overlay);
    3.78                  SDL_DisplayYUVOverlay(video.overlay, &video.clip);
    3.79                  break;
    3.80 +#if defined(USE_OPENGL)
    3.81          case VIDEO_GL:
    3.82                  my_glBindTexture(GL_TEXTURE_2D, video.gl.texture);
    3.83                  my_glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
    3.84 @@ -1709,6 +1731,7 @@
    3.85                  my_glCallList(video.gl.displaylist);
    3.86                  SDL_GL_SwapBuffers();
    3.87                  break;
    3.88 +#endif
    3.89          };
    3.90  }
    3.91