acinclude/ax_check_compiler_flags.m4
author Sam Lantinga
Tue, 10 Jan 2017 08:54:33 -0800
changeset 10806 36f40b8cc979
parent 5029 5d7d48157be7
permissions -rw-r--r--
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@5029
     1
# ===========================================================================
slouken@5029
     2
#  http://www.gnu.org/software/autoconf-archive/ax_check_compiler_flags.html
slouken@5029
     3
# ===========================================================================
slouken@5029
     4
#
slouken@5029
     5
# SYNOPSIS
slouken@5029
     6
#
slouken@5029
     7
#   AX_CHECK_COMPILER_FLAGS(FLAGS, [ACTION-SUCCESS], [ACTION-FAILURE])
slouken@5029
     8
#
slouken@5029
     9
# DESCRIPTION
slouken@5029
    10
#
slouken@5029
    11
#   Check whether the given compiler FLAGS work with the current language's
slouken@5029
    12
#   compiler, or whether they give an error. (Warnings, however, are
slouken@5029
    13
#   ignored.)
slouken@5029
    14
#
slouken@5029
    15
#   ACTION-SUCCESS/ACTION-FAILURE are shell commands to execute on
slouken@5029
    16
#   success/failure.
slouken@5029
    17
#
slouken@5029
    18
# LICENSE
slouken@5029
    19
#
slouken@5029
    20
#   Copyright (c) 2009 Steven G. Johnson <stevenj@alum.mit.edu>
slouken@5029
    21
#   Copyright (c) 2009 Matteo Frigo
slouken@5029
    22
#
slouken@5029
    23
#   This program is free software: you can redistribute it and/or modify it
slouken@5029
    24
#   under the terms of the GNU General Public License as published by the
slouken@5029
    25
#   Free Software Foundation, either version 3 of the License, or (at your
slouken@5029
    26
#   option) any later version.
slouken@5029
    27
#
slouken@5029
    28
#   This program is distributed in the hope that it will be useful, but
slouken@5029
    29
#   WITHOUT ANY WARRANTY; without even the implied warranty of
slouken@5029
    30
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
slouken@5029
    31
#   Public License for more details.
slouken@5029
    32
#
slouken@5029
    33
#   You should have received a copy of the GNU General Public License along
slouken@5029
    34
#   with this program. If not, see <http://www.gnu.org/licenses/>.
slouken@5029
    35
#
slouken@5029
    36
#   As a special exception, the respective Autoconf Macro's copyright owner
slouken@5029
    37
#   gives unlimited permission to copy, distribute and modify the configure
slouken@5029
    38
#   scripts that are the output of Autoconf when processing the Macro. You
slouken@5029
    39
#   need not follow the terms of the GNU General Public License when using
slouken@5029
    40
#   or distributing such scripts, even though portions of the text of the
slouken@5029
    41
#   Macro appear in them. The GNU General Public License (GPL) does govern
slouken@5029
    42
#   all other use of the material that constitutes the Autoconf Macro.
slouken@5029
    43
#
slouken@5029
    44
#   This special exception to the GPL applies to versions of the Autoconf
slouken@5029
    45
#   Macro released by the Autoconf Archive. When you make and distribute a
slouken@5029
    46
#   modified version of the Autoconf Macro, you may extend this special
slouken@5029
    47
#   exception to the GPL to apply to your modified version as well.
slouken@5029
    48
slouken@5029
    49
#serial 9
slouken@5029
    50
slouken@5029
    51
AC_DEFUN([AX_CHECK_COMPILER_FLAGS],
slouken@5029
    52
[AC_PREREQ(2.59) dnl for _AC_LANG_PREFIX
slouken@5029
    53
AC_MSG_CHECKING([whether _AC_LANG compiler accepts $1])
slouken@5029
    54
dnl Some hackery here since AC_CACHE_VAL can't handle a non-literal varname:
slouken@5029
    55
AS_LITERAL_IF([$1],
slouken@5029
    56
  [AC_CACHE_VAL(AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1]), [
slouken@5029
    57
      ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
slouken@5029
    58
      _AC_LANG_PREFIX[]FLAGS="$1"
slouken@5029
    59
      AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
slouken@5029
    60
        AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
slouken@5029
    61
        AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
slouken@5029
    62
      _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])],
slouken@5029
    63
  [ax_save_FLAGS=$[]_AC_LANG_PREFIX[]FLAGS
slouken@5029
    64
   _AC_LANG_PREFIX[]FLAGS="$1"
slouken@5029
    65
   AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
slouken@5029
    66
     eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=yes,
slouken@5029
    67
     eval AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])=no)
slouken@5029
    68
   _AC_LANG_PREFIX[]FLAGS=$ax_save_FLAGS])
slouken@5029
    69
eval ax_check_compiler_flags=$AS_TR_SH(ax_cv_[]_AC_LANG_ABBREV[]_flags_[$1])
slouken@5029
    70
AC_MSG_RESULT($ax_check_compiler_flags)
slouken@5029
    71
if test "x$ax_check_compiler_flags" = xyes; then
slouken@5029
    72
	m4_default([$2], :)
slouken@5029
    73
else
slouken@5029
    74
	m4_default([$3], :)
slouken@5029
    75
fi
slouken@5029
    76
])dnl AX_CHECK_COMPILER_FLAGS