test/configure.in
author Sam Lantinga <slouken@libsdl.org>
Sun, 08 Jan 2012 02:23:37 -0500
changeset 6188 e82023802002
parent 3623 9a73fecd9181
child 6250 cce0ddcf6747
permissions -rw-r--r--
Fixed bug 1242 - PATCH: Improve support for OpenGL ES under X11

Scott Percival 2011-07-03 06:41:51 PDT

This submission is aimed at making life easier for OpenGL ES capable devices
running a X11 stack (e.g. Maemo, Meego, TrimSlice, other ARM SoC boards not
running Android). SDL's Pandora support already has the neccesary GLES-to-X11
glue code, however it's all ghetto'd off in Makefile.pandora and not very
flexible.

The patch:
- adds an awesome --enable-video-opengles option to configure
- re-modifies the opengles and opengles2 SDL_renderers to use function pointers
- no idea why this was removed?
- for SDL_Renderers, links in libGLESv1_CM, libGLES_CM (for PowerVR fans) or
libGLESv2 at runtime
- links in libEGL.so at runtime - the old code made an assumption that
eglFunctions could be pulled from the active GLES library, PowerVR for one
doesn't let you do that with their libGLESv2
- allows you to pick which of GLES v1 or v2 to load via
SDL_GL_CONTEXT_MAJOR_VERSION

So far I've tested this on a Nokia N900 (OMAP 3430/SGX 530 running Maemo 5) and
a Toshiba AC100 (Tegra 2 running Ubuntu 10.10). I haven't tested it on... well,
everything that isn't those two, such as a Pandora, iOS or Android device. The
Pandora specific code should be kept intact (fingers crossed), and nothing
painfully drastic has been added to the SDL_renderers. The library loading
sequence in SDL_x11opengles has been updated to accomodate both NVIDIA's
propensity to let developers get away with murder and PowerVR's alternative of
punishing every missed step.

The test apps work okay with GLES or GLES2 as the renderer. For some reason
alpha blending doesn't seem to work on the Tegra 2; last week NVIDIA pushed out
a new set of X11 GLES drivers, so I'll try and investigate once I upgrade
those. Also, this patch adds things to configure.in, include/SDL_config.h.in
and test/configure.in. I didn't know what the policy was re. committing
generated spaghetti from autotools, so ./autogen.sh has to be run again. Sorry.

I think that's about everything, let me know if there's anything I've
overlooked.
     1 dnl Process this file with autoconf to produce a configure script.
     2 AC_INIT(README)
     3 
     4 dnl Detect the canonical build and host environments
     5 AC_CONFIG_AUX_DIRS($srcdir/../build-scripts)
     6 AC_CANONICAL_HOST
     7 
     8 dnl Check for tools
     9 
    10 AC_PROG_CC
    11 
    12 dnl Check for compiler environment
    13 
    14 AC_C_CONST
    15 
    16 dnl Figure out which math library to use
    17 case "$host" in
    18     *-*-cygwin* | *-*-mingw32*)
    19         EXE=".exe"
    20         MATHLIB=""
    21         SYS_GL_LIBS="-lopengl32"
    22         ;;
    23     *-*-beos* | *-*-haiku*)
    24         EXE=""
    25         MATHLIB=""
    26         SYS_GL_LIBS="-lGL"
    27         ;;
    28     *-*-darwin* )
    29         EXE=""
    30         MATHLIB=""
    31         SYS_GL_LIBS="-Wl,-framework,OpenGL"
    32         ;;
    33     *-*-aix*)
    34         EXE=""
    35         if test x$ac_cv_prog_gcc = xyes; then
    36             CFLAGS="-mthreads"
    37         fi
    38         SYS_GL_LIBS=""
    39         ;;
    40     *-*-mint*)
    41         EXE=""
    42         MATHLIB=""
    43         AC_PATH_PROG(OSMESA_CONFIG, osmesa-config, no)
    44         if test "x$OSMESA_CONFIG" = "xyes"; then
    45             OSMESA_CFLAGS=`$OSMESA_CONFIG --cflags`
    46             OSMESA_LIBS=`$OSMESA_CONFIG --libs`
    47             CFLAGS="$CFLAGS $OSMESA_CFLAGS"
    48             SYS_GL_LIBS="$OSMESA_LIBS"
    49         else
    50             SYS_GL_LIBS="-lOSMesa"
    51         fi
    52         ;;
    53     *-*-qnx*)
    54         EXE=""
    55         MATHLIB=""
    56         SYS_GL_LIBS="-lGLES_CM"
    57         ;;
    58     *)
    59         EXE=""
    60         MATHLIB="-lm"
    61         SYS_GL_LIBS="-lGL"
    62         ;;
    63 esac
    64 AC_SUBST(EXE)
    65 AC_SUBST(MATHLIB)
    66 
    67 dnl Check for SDL
    68 SDL_VERSION=1.3.0
    69 AM_PATH_SDL($SDL_VERSION,
    70             :,
    71 	    AC_MSG_ERROR([*** SDL version $SDL_VERSION not found!])
    72 )
    73 CFLAGS="$CFLAGS $SDL_CFLAGS"
    74 LIBS="$LIBS $SDL_LIBS"
    75 
    76 dnl Check for X11 path, needed for OpenGL on some systems
    77 AC_PATH_X
    78 if test x$have_x = xyes; then
    79     if test x$ac_x_includes = xno || test x$ac_x_includes = x; then
    80         :
    81     else
    82         CFLAGS="$CFLAGS -I$ac_x_includes"
    83     fi
    84     if test x$ac_x_libraries = xno || test x$ac_x_libraries = x; then
    85         :
    86     else
    87         XPATH="-L$ac_x_libraries"
    88     fi
    89 fi
    90 
    91 dnl Check for OpenGL
    92 AC_MSG_CHECKING(for OpenGL support)
    93 have_opengl=no
    94 AC_TRY_COMPILE([
    95  #include "SDL_opengl.h"
    96 ],[
    97 ],[
    98 have_opengl=yes
    99 ])
   100 AC_MSG_RESULT($have_opengl)
   101 
   102 dnl Check for OpenGL ES
   103 AC_MSG_CHECKING(for OpenGL ES support)
   104 have_opengles=no
   105 AC_TRY_COMPILE([
   106  #if defined (__IPHONEOS__)
   107     #include <OpenGLES/ES1/gl.h>
   108  #else
   109     #include <GLES/gl.h>
   110  #endif /* __QNXNTO__ */
   111 ],[
   112 ],[
   113 have_opengles=yes
   114 ])
   115 AC_MSG_RESULT($have_opengles)
   116 
   117 GLLIB=""
   118 if test x$have_opengles = xyes; then
   119     CFLAGS="$CFLAGS -DHAVE_OPENGLES"
   120     GLLIB="$XPATH -lGLESv1_CM"
   121 elif test x$have_opengl = xyes; then
   122     CFLAGS="$CFLAGS -DHAVE_OPENGL"
   123     GLLIB="$XPATH $SYS_GL_LIBS"
   124 else
   125     GLLIB=""
   126 fi
   127 
   128 AC_SUBST(GLLIB)
   129 
   130 dnl Check for SDL_ttf
   131 AC_MSG_CHECKING(for SDL_ttf)
   132 have_SDL_ttf=no
   133 AC_TRY_COMPILE([
   134  #include "SDL_ttf.h"
   135 ],[
   136 ],[
   137 have_SDL_ttf=yes
   138 ])
   139 AC_MSG_RESULT($have_SDL_ttf)
   140 
   141 if test x$have_SDL_ttf = xyes; then
   142     CFLAGS="$CFLAGS -DHAVE_SDL_TTF"
   143     SDL_TTF_LIB="-lSDL_ttf"
   144 fi
   145 
   146 AC_SUBST(SDL_TTF_LIB)
   147 
   148 dnl Finally create all the generated files
   149 AC_OUTPUT([Makefile])