GLES1 and GLES2 versions are now compiled with -DFREEGLUT_GLES1 and -DFREEGLUT_GLES2...
authorSylvain Beucler <beuc@beuc.net>
Fri, 16 Mar 2012 21:30:26 +0000 (21:30 +0000)
committerSylvain Beucler <beuc@beuc.net>
Fri, 16 Mar 2012 21:30:26 +0000 (21:30 +0000)
git-svn-id: svn+ssh://svn.code.sf.net/p/freeglut/code/trunk/freeglut/freeglut@1159 7f0cb862-5218-0410-a997-914c9d46530a

CMakeLists.txt
freeglut.pc.in
include/GL/freeglut_std.h

index b1e2752..aec2c74 100644 (file)
@@ -134,11 +134,17 @@ OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
 OPTION(FREEGLUT_GLES1 "Use OpenGL ES 1.x (requires EGL)" OFF)
 OPTION(FREEGLUT_GLES2 "Use OpenGL ES 2.x (requires EGL) (overrides BUILD_GLES1)" OFF)
 
+# For OpenGL ES (GLES):
+# - compile with -DFREEGLUT_GLES1 and -DFREEGLUT_GLES2 to cleanly
+#   bootstrap headers inclusion in freeglut_std.h; these constants
+#   also need to be defined in client applications (e.g through
+#   pkg-config), but use GLES constants directly for all other needs
+# - define GLES version-specific library
 IF(FREEGLUT_GLES2)
-  ADD_DEFINITIONS(-DGLESv2)
+  ADD_DEFINITIONS(-DFREEGLUT_GLES2)
   LIST(APPEND LIBS GLESv2 EGL)
 ELSEIF(FREEGLUT_GLES1)
-  ADD_DEFINITIONS(-DGLESv1)
+  ADD_DEFINITIONS(-DFREEGLUT_GLES1)
   LIST(APPEND LIBS GLESv1 EGL)
 ELSE()
   FIND_PACKAGE(OpenGL REQUIRED)
@@ -348,12 +354,20 @@ ENDIF()
 # pkg-config support, to install at $(libdir)/pkgconfig
 # Define static build dependencies
 IF(WIN32)
-  SET(LIBS_PRIVATE "-lopengl32 -lwinmm -lgdi32")
+  SET(PC_LIBS_PRIVATE "-lopengl32 -lwinmm -lgdi32")
 ELSEIF(ANDROID)
-  SET(LIBS_PRIVATE "-llog -landroid -lGLESv2 -lEGL")
+  SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv2 -lEGL")
 ELSE()
-  SET(LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL")
+  SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL")
+ENDIF()
+# Client applications need to define FreeGLUT GLES version to
+# bootstrap headers inclusion in freeglut_std.h:
+IF(FREEGLUT_GLES2)
+  SET(PC_CFLAGS "-DFREEGLUT_GLES2")
+ELSEIF(FREEGLUT_GLES1)
+  SET(PC_CFLAGS "-DFREEGLUT_GLES1")
 ENDIF()
 CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/freeglut.pc.in ${CMAKE_BINARY_DIR}/freeglut.pc @ONLY)
 INSTALL(FILES ${CMAKE_BINARY_DIR}/freeglut.pc DESTINATION share/pkgconfig)
-# TODO: change the library name when building for GLES, e.g. -lglut-GLES2
+# TODO: change the library and .pc name when building for GLES,
+# e.g. -lglut-GLES2
index a5425cd..57b9ea0 100644 (file)
@@ -6,5 +6,5 @@ Name: glut
 Description: A freely licensed and improved alternative to the GLUT library
 Version: @VERSION_MAJOR@.@VERSION_MINOR@.@VERSION_PATCH@
 Libs: -L${libdir} -lglut
-Libs.private: @LIBS_PRIVATE@
-Cflags: -I${includedir}
+Libs.private: @PC_LIBS_PRIVATE@
+Cflags: -I${includedir} @PC_CFLAGS@
index 573243a..f77497e 100644 (file)
 /*
  * Always include OpenGL and GLU headers
  */
-#ifdef ANDROID
-/* Use EGL (implies OpenGL ES) */
-/* TODO: EGL/GLES builds should be more generally defined, possibly by
-   generating this file dynamically */
+#ifdef FREEGLUT_GLES2
 #   include <EGL/egl.h>
-/* TODO: we probably need 2 builds: -lGLESv1 and -lGLESv2 */
-/* #include <GLES/gl.h> */
 #   include <GLES2/gl2.h>
-/* TODO: temporary work-around for e.g. glutWireCube */
-#   define GLdouble     GLfloat
+#elif FREEGLUT_GLES1
+#   include <EGL/egl.h>
+#   include <GLES/gl.h>
 #else
 #   include <GL/gl.h>
 #   include <GL/glu.h>
@@ -525,6 +521,11 @@ FGAPI int     FGAPIENTRY glutStrokeLength( void* font, const unsigned char* stri
 /*
  * Geometry functions, see freeglut_geometry.c
  */
+#ifdef EGL_VERSION_1_0
+/* TODO: temporary work-around for missing GLdouble in GLES */
+#   define GLdouble     GLfloat  
+#endif
+
 FGAPI void    FGAPIENTRY glutWireCube( GLdouble size );
 FGAPI void    FGAPIENTRY glutSolidCube( GLdouble size );
 FGAPI void    FGAPIENTRY glutWireSphere( GLdouble radius, GLint slices, GLint stacks );