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