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