Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.
 
 
 

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