set(VERSION_PATCH 0)
+# BUILD_SHARED_LIBS is already a standard CMake variable, but we need to
+# re-declare it here so it will show up in the GUI.
+# by default, we want to build both
+OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON)
+OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
+
+# OpenGL ES support
+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)
+
+
SET(FREEGLUT_HEADERS
include/GL/freeglut.h
include/GL/freeglut_ext.h
src/fg_videoresize.c
src/fg_window.c
)
-# Android port requires adding a version of these compatible with
-# OpenGL ES (TODO):
-IF(NOT ANDROID)
+# TODO: OpenGL ES requires a compatible version of these files:
+IF(NOT FREEGLUT_GLES2 AND NOT FREEGLUT_GLES1)
LIST(APPEND FREEGLUT_SRCS
src/fg_font.c
src/fg_geometry.c
src/fg_menu.c
src/fg_teapot.c
+ src/fg_teapot_data.h
+ )
+ELSE()
+ LIST(APPEND FREEGLUT_SRCS
+ src/gles_stubs.c
)
ENDIF()
src/mswin/fg_window_mswin.c
${CMAKE_BINARY_DIR}/freeglut.rc # generated below from freeglut.rc.in
)
- IF (NOT CMAKE_CL_64)
+ IF (MSVC AND NOT CMAKE_CL_64)
# .def file only for 32bit Windows builds
LIST(APPEND FREEGLUT_SRCS
${CMAKE_BINARY_DIR}/freeglutdll.def # generated below from src/freeglutdll.def.in
src/egl/fg_internal_egl.h
src/egl/fg_display_egl.c
src/egl/fg_init_egl.c
+ src/egl/fg_state_egl.c
src/egl/fg_structure_egl.c
+ src/egl/fg_structure_egl.h
src/egl/fg_window_egl.c
+ src/egl/fg_window_egl.h
src/android/native_app_glue/android_native_app_glue.c
src/android/native_app_glue/android_native_app_glue.h
src/android/fg_runtime_android.c
src/android/fg_gamemode_android.c
+ src/android/fg_structure_android.c
+ src/android/fg_init_android.c
src/android/fg_input_devices_android.c
src/android/fg_joystick_android.c
src/android/fg_main_android.c
src/android/fg_spaceball_android.c
src/android/fg_state_android.c
src/android/fg_window_android.c
- src/android/opengles_stubs.c
src/android/fg_internal_android.h
)
ELSE()
)
ENDIF()
-# BUILD_SHARED_LIBS is already a standard CMake variable, but we need to
-# re-declare it here so it will show up in the GUI.
-# by default, we want to build both
-OPTION(BUILD_SHARED_LIBS "Build FreeGLUT shared library." ON)
-OPTION(BUILD_STATIC_LIBS "Build FreeGLUT static library." ON)
-
-# OpenGL ES support
-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)
- LIST(APPEND LIBS GLESv1 EGL)
+ ADD_DEFINITIONS(-DFREEGLUT_GLES1)
+ LIST(APPEND LIBS GLESv1_CM EGL)
ELSE()
FIND_PACKAGE(OpenGL REQUIRED)
LIST(APPEND LIBS ${OPENGL_gl_LIBRARY})
# pkg-config support, to install at $(libdir)/pkgconfig
# Define static build dependencies
IF(WIN32)
- SET(LIBS_PRIVATE "-lopengl32 -lwinmm -lgdi32")
-ELSEIF(ANDROID)
- SET(LIBS_PRIVATE "-llog -landroid -lGLESv2 -lEGL")
+ SET(PC_LIBS_PRIVATE "-lopengl32 -lwinmm -lgdi32")
+ELSEIF(FREEGLUT_GLES2)
+ IF(ANDROID)
+ SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv2 -lEGL")
+ ELSE()
+ SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL")
+ ENDIF()
+ELSEIF(FREEGLUT_GLES1)
+ IF(ANDROID)
+ SET(PC_LIBS_PRIVATE "-llog -landroid -lGLESv1_CM -lEGL")
+ ELSE()
+ SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv1_CM -lEGL")
+ ENDIF()
ELSE()
- SET(LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGLESv2 -lEGL")
+ SET(PC_LIBS_PRIVATE "-lX11 -lXxf86vm -lXrandr -lGL")
+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