Introduction

FreeGLUT can initialize an OpenGL ES (GLES) context. It works under platforms that supports EGL:

FreeGLUT ES is provided as a separate library, because OpenGL ES has a distinct, incompatible library for each version (e.g. -lGLESv1_CM and -lGLESv2).

The following explains how to use FreeGLUT ES under Mesa EGL.

Compiling

Here's how to compile FreeGLUT for GLES2:

cd /usr/src/freeglut-3.0.0/
mkdir native-gles2/ && cd native-gles2/
cmake \
  -DCMAKE_INSTALL_PREFIX=/tmp/freeglut-native-gles2 \
  -D CMAKE_BUILD_TYPE=Debug \
  -DFREEGLUT_GLES2=ON \
  -DFREEGLUT_BUILD_DEMOS=NO \
  ..
make
make install

For GLES1:

cd /usr/src/freeglut-3.0.0/
mkdir native-gles1/ && cd native-gles1/
cmake \
  -DCMAKE_INSTALL_PREFIX=/tmp/freeglut-native-gles1 \
  -D CMAKE_BUILD_TYPE=Debug \
  -DFREEGLUT_GLES1=ON \
  -DFREEGLUT_BUILD_DEMOS=NO \
  ..
make
make install

Using in your projects

Get the 'freeglut-gles2' module through pkg-config.

If you use CMake, you can do that with:

include(FindPkgConfig)
pkg_check_modules(freeglut REQUIRED freeglut-gles2>=3.0.0)
if(freeglut_FOUND)
  include_directories(${freeglut_STATIC_INCLUDE_DIRS})
  link_directories(${freeglut_STATIC_LIBRARY_DIRS})
  set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${freeglut_STATIC_CFLAGS_OTHER}")
  add_definitions(${freeglut_STATIC_CFLAGS_OTHER})
endif()
cd your_project/
mkdir native-gles2/ && cd native-gles2/
PKG_CONFIG_PATH=/tmp/freeglut-native-gles2/share/pkgconfig/ cmake ..

See for instance progs/test-shapes-gles1/ in the source distribution: it is a standalone CMake app that uses FreeGLUT GLES1.