You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

128 regels
3.7 KiB

  1. # LOL_CHECK_OPENGL()
  2. # ------------------
  3. AC_DEFUN([LOL_CHECK_OPENGL],
  4. [
  5. dnl Find which version of OpenGL to use
  6. ac_cv_my_have_gl="no"
  7. ac_cv_my_stop_looking_for_gl="no"
  8. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  9. LIBS_save="$LIBS"
  10. LIBS="$LIBS -Wl,-framework -Wl,OpenGL"
  11. AC_MSG_CHECKING(for -framework OpenGL)
  12. AC_TRY_LINK([], [],
  13. [AC_MSG_RESULT(yes)
  14. ac_cv_my_have_gl="yes"
  15. GL_LIBS="${GL_LIBS} -framework OpenGL"
  16. CXXFLAGS="${CXXFLAGS} -ObjC++"
  17. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  18. [AC_MSG_RESULT(no)])
  19. LIBS="$LIBS_save"
  20. fi
  21. dnl Use the Raspberry Pi libraries?
  22. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  23. AC_CHECK_HEADERS(bcm_host.h,
  24. [AC_CHECK_LIB(vcos, main,
  25. [ac_cv_my_have_gl="yes"
  26. ac_cv_my_stop_looking_for_gl="yes"
  27. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  28. dnl FIXME: -lEGL does not belong here but the configure test fails
  29. dnl when cross-compiling, so we add it manually here.
  30. GL_LIBS="${GL_LIBS} -lGLESv2 -lEGL -lvcos -lvchiq_arm -lbcm_host"])])
  31. fi
  32. dnl Use the PS3 PSGL?
  33. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  34. AC_CHECK_HEADERS(PSGL/psgl.h,
  35. [ac_cv_my_have_gl="yes"
  36. ac_cv_my_stop_looking_for_gl="yes"])
  37. fi
  38. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  39. PKG_CHECK_MODULES(GLES2, glesv2,
  40. [ac_cv_my_have_gl="yes"
  41. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  42. GL_CFLAGS="${GL_CFLAGS} ${GLES2_CFLAGS}"
  43. GL_LIBS="${GL_LIBS} ${GLES2_LIBS}"],
  44. [:])
  45. fi
  46. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  47. AC_CHECK_HEADER(GLES2/gl2.h,
  48. [ac_cv_my_have_gl="yes"
  49. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  50. AC_CHECK_LIB(GLESv2, glEnable,
  51. [GL_LIBS="${GL_LIBS} -lGLESv2"])])
  52. fi
  53. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  54. PKG_CHECK_MODULES(GL, gl,
  55. [ac_cv_my_have_gl="yes"
  56. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available)],
  57. [:])
  58. fi
  59. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  60. AC_CHECK_LIB(GL, glEnable,
  61. [ac_cv_my_have_gl="yes"
  62. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hackish
  63. GL_LIBS="-lGL"])
  64. fi
  65. if test "x${ac_cv_my_stop_looking_for_gl}" = "xno"; then
  66. AC_CHECK_HEADER(GL/gl.h,
  67. [LIBS_save="$LIBS"
  68. LIBS="$LIBS -lopengl32"
  69. AC_MSG_CHECKING(for glLoadIdentity in -lopengl32)
  70. AC_TRY_LINK([#include <GL/gl.h>],
  71. [glLoadIdentity();],
  72. [ac_cv_my_have_gl="yes"
  73. AC_DEFINE(HAVE_GL_2X, 1, Define to 1 if GL 2.x is available) # FIXME: hack
  74. AC_MSG_RESULT(yes)
  75. GL_LIBS="-lopengl32"],
  76. [AC_MSG_RESULT(no)])
  77. LIBS="$LIBS_save"])
  78. fi
  79. if test "${ac_cv_my_have_gl}" = "no"; then
  80. AC_MSG_ERROR([[No OpenGL or OpenGL ES implementation found]])
  81. fi
  82. dnl Use Glew?
  83. ac_cv_my_have_glew="no"
  84. PKG_CHECK_MODULES(GLEW, glew,
  85. [ac_cv_my_have_glew="yes"
  86. GL_CFLAGS="${GLEW_CFLAGS} ${GL_CFLAGS}"
  87. GL_LIBS="${GLEW_LIBS} ${GL_LIBS}"],
  88. [:])
  89. AC_CHECK_HEADER(glew.h,
  90. [LIBS_save="${LIBS}"
  91. LIBS="${LIBS} -lglew32s ${GL_LIBS}"
  92. AC_MSG_CHECKING(for glewInit in -lglew32s)
  93. AC_TRY_LINK(
  94. [#include <glew.h>],
  95. [glewInit();],
  96. [ac_cv_my_have_glew="yes"
  97. GL_LIBS="-lglew32s ${GL_LIBS}"
  98. AC_MSG_RESULT(yes)],
  99. [AC_MSG_RESULT(no)])
  100. LIBS="${LIBS_save}"])
  101. if test "${ac_cv_my_have_glew}" != "no"; then
  102. AC_DEFINE(HAVE_GLES_2X, 1, Define to 1 if GLES 2.x is available)
  103. AC_DEFINE(USE_GLEW, 1, Define to 1 to use libglew)
  104. fi
  105. AM_CONDITIONAL(USE_GLEW, test "${ac_cv_my_have_glew}" != "no")
  106. dnl Poor man's GL feature detection if all else failed.
  107. save_LIBS="${LIBS}"
  108. LIBS="${LIBS} ${GL_LIBS} ${GLES2_LIBS}"
  109. AC_CHECK_FUNCS(glBegin)
  110. LIBS="${save_LIBS}"
  111. ])# LOL_CHECK_OPENGL