Kaynağa Gözat

Fix OpenGL example autotools build for Mac OS X (#143)

* Autoconf: extend OpenGL check for OS X

* Use Mac OS X includes for opengl example
Philipp Zabel 7 yıl önce
ebeveyn
işleme
b3d67932da
2 değiştirilmiş dosya ile 11 ekleme ve 2 silme
  1. 6 2
      configure.ac
  2. 5 0
      examples/opengl/gl.h

+ 6 - 2
configure.ac

@@ -37,7 +37,9 @@ AS_CASE(["$host"],
 		[AC_SUBST(PKG_CONFIG_EXTRA_PATH, "libdata/")
 		AC_SUBST(EXTRA_LD_FLAGS, "-lthr")],
 	[*-kfreebsd*],
-		[AC_SUBST(EXTRA_LD_FLAGS, "-lpthread")])
+		[AC_SUBST(EXTRA_LD_FLAGS, "-lpthread")]
+	[*-darwin*],
+		[AC_MSG_RESULT([$host (Mac OS X)])])
 
 # Oculus Rift Driver
 AC_ARG_ENABLE([driver-oculus-rift],
@@ -151,7 +153,9 @@ AS_IF([test "x$openglexample_enabled" != "xno"], [
 
 				# if that fails, try -lopengl32 (win32)
 				[AC_CHECK_LIB(opengl32, main, [GL_LIBS=-lopengl32],
-					AC_MSG_ERROR([GL not found])
+					[AC_CHECK_HEADERS([OpenGL/gl.h], [GL_LIBS="-framework OpenGL"],
+						AC_MSG_ERROR([GL not found])
+					)]
 				)]
 			)]
 	)

+ 5 - 0
examples/opengl/gl.h

@@ -12,8 +12,13 @@
 
 #include <SDL.h>
 
+#ifndef __APPLE__
 #include <GL/glew.h>
 #include <GL/gl.h>
+#else
+#include <OpenGL/gl.h>
+static inline void glewInit(void) {}
+#endif
 
 typedef struct {
 	int w, h;