build-scripts/g++-fat.sh
author Sam Lantinga
Tue, 10 Jan 2017 08:54:33 -0800
changeset 10806 36f40b8cc979
parent 10176 3115d38204aa
permissions -rwxr-xr-x
Fixed bugs 2570, 3145, improved OpenGL ES context support on Windows and X11

Mark Callow

The attached patch does the following for the X11 and Windows platforms, the only ones where SDL attempts to use context_create_es_profile:

- Adds SDL_HINT_OPENGL_ES_DRIVER by which the application can
say to use the OpenGL ES driver & EGL rather than the Open GL
driver. (For bug #2570)
- Adds code to {WIN,X11}_GL_InitExtensions to determine the maximum
OpenGL ES version supported by the OpenGL driver (for bug #3145)
- Modifies the test that determines whether to use the OpenGL
driver or the real OpenGL ES driver to take into account the
hint, the requested and supported ES version and whether ES 1.X
is being requested. (For bug #2570 & bug #3145)
- Enables the testgles2 test for __WINDOWS__ and __LINUX__ and adds
the test to the VisualC projects.

With the fix in place I have run testdraw2, testgl and testgles2 without any issues and have run my own apps that use OpenGL, OpenGL ES 3 and OpenGL ES 1.1.
     1 #!/bin/sh
     2 #
     3 # Build Universal binaries on Mac OS X, thanks Ryan!
     4 #
     5 # Usage: ./configure CXX="sh g++-fat.sh" && make && rm -rf x86 x64
     6 
     7 DEVELOPER="`xcode-select -print-path`/Platforms/MacOSX.platform/Developer"
     8 
     9 # Intel 32-bit compiler flags (10.6 runtime compatibility)
    10 GCC_COMPILE_X86="g++ -arch i386 -mmacosx-version-min=10.6 \
    11 -I/usr/local/include"
    12 
    13 GCC_LINK_X86="-mmacosx-version-min=10.6"
    14 
    15 # Intel 64-bit compiler flags (10.6 runtime compatibility)
    16 GCC_COMPILE_X64="g++ -arch x86_64 -mmacosx-version-min=10.6 \
    17 -I/usr/local/include"
    18 
    19 GCC_LINK_X64="-mmacosx-version-min=10.6"
    20 
    21 # Output both PowerPC and Intel object files
    22 args="$*"
    23 compile=yes
    24 link=yes
    25 while test x$1 != x; do
    26     case $1 in
    27         --version) exec g++ $1;;
    28         -v) exec g++ $1;;
    29         -V) exec g++ $1;;
    30         -print-prog-name=*) exec g++ $1;;
    31         -print-search-dirs) exec g++ $1;;
    32         -E) GCC_COMPILE_X86="$GCC_COMPILE_X86 -E"
    33             GCC_COMPILE_X64="$GCC_COMPILE_X64 -E"
    34             compile=no; link=no;;
    35         -c) link=no;;
    36         -o) output=$2;;
    37         *.c|*.cc|*.cpp|*.S|*.m|*.mm) source=$1;;
    38     esac
    39     shift
    40 done
    41 if test x$link = xyes; then
    42     GCC_COMPILE_X86="$GCC_COMPILE_X86 $GCC_LINK_X86"
    43     GCC_COMPILE_X64="$GCC_COMPILE_X64 $GCC_LINK_X64"
    44 fi
    45 if test x"$output" = x; then
    46     if test x$link = xyes; then
    47         output=a.out
    48     elif test x$compile = xyes; then
    49         output=`echo $source | sed -e 's|.*/||' -e 's|\(.*\)\.[^\.]*|\1|'`.o
    50     fi
    51 fi
    52 
    53 # Compile X86 32-bit
    54 if test x"$output" != x; then
    55     dir=x86/`dirname $output`
    56     if test -d $dir; then
    57         :
    58     else
    59         mkdir -p $dir
    60     fi
    61 fi
    62 set -- $args
    63 while test x$1 != x; do
    64     if test -f "x86/$1" && test "$1" != "$output"; then
    65         x86_args="$x86_args x86/$1"
    66     else
    67         x86_args="$x86_args $1"
    68     fi
    69     shift
    70 done
    71 $GCC_COMPILE_X86 $x86_args || exit $?
    72 if test x"$output" != x; then
    73     cp $output x86/$output
    74 fi
    75 
    76 # Compile X86 32-bit
    77 if test x"$output" != x; then
    78     dir=x64/`dirname $output`
    79     if test -d $dir; then
    80         :
    81     else
    82         mkdir -p $dir
    83     fi
    84 fi
    85 set -- $args
    86 while test x$1 != x; do
    87     if test -f "x64/$1" && test "$1" != "$output"; then
    88         x64_args="$x64_args x64/$1"
    89     else
    90         x64_args="$x64_args $1"
    91     fi
    92     shift
    93 done
    94 $GCC_COMPILE_X64 $x64_args || exit $?
    95 if test x"$output" != x; then
    96     cp $output x64/$output
    97 fi
    98 
    99 if test x"$output" != x; then
   100     lipo -create -o $output x86/$output x64/$output
   101 fi