From 13416c05d6f030d597599b91033ed54603ec1d8b Mon Sep 17 00:00:00 2001 From: beuc Date: Sun, 1 Jun 2014 09:48:51 +0000 Subject: [PATCH 1/5] EGL is always double-buffered git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1688 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/egl/fg_state_egl.c | 3 +++ freeglut/freeglut/src/fg_window.c | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/freeglut/freeglut/src/egl/fg_state_egl.c b/freeglut/freeglut/src/egl/fg_state_egl.c index 59fc9c9..c83ec30 100644 --- a/freeglut/freeglut/src/egl/fg_state_egl.c +++ b/freeglut/freeglut/src/egl/fg_state_egl.c @@ -88,6 +88,9 @@ int fghPlatformGlutGetEGL ( GLenum eWhat ) return 0; return fgPlatformGetConfig( EGL_NATIVE_VISUAL_ID ); + case GLUT_WINDOW_DOUBLEBUFFER: + return 1; /* EGL is always double-buffered */ + default: fgWarning( "glutGet(): missing enum handle %d", eWhat ); break; diff --git a/freeglut/freeglut/src/fg_window.c b/freeglut/freeglut/src/fg_window.c index cf1dff8..adf2a0a 100644 --- a/freeglut/freeglut/src/fg_window.c +++ b/freeglut/freeglut/src/fg_window.c @@ -127,15 +127,19 @@ void fgOpenWindow( SFG_Window* window, const char* title, fgSetWindow( window ); +#ifndef EGL_VERSION_1_0 window->Window.DoubleBuffered = ( fgState.DisplayMode & GLUT_DOUBLE ) ? 1 : 0; -#ifndef EGL_VERSION_1_0 /* No glDrawBuffer/glReadBuffer in GLES */ if ( ! window->Window.DoubleBuffered ) { glDrawBuffer ( GL_FRONT ); glReadBuffer ( GL_FRONT ); } +#else + /* - EGL is always double-buffered */ + /* - No glDrawBuffer/glReadBuffer in GLES */ + window->Window.DoubleBuffered = 1; #endif window->Window.attribute_v_coord = -1; window->Window.attribute_v_normal = -1; From 7fee3a3bb3db671d38a0bb84e3c1d5d176004415 Mon Sep 17 00:00:00 2001 From: beuc Date: Sun, 1 Jun 2014 10:43:01 +0000 Subject: [PATCH 2/5] Update GLES instructions git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1689 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/web-src/docs/gles.php | 60 ++++++++++++++-------------------- 1 file changed, 24 insertions(+), 36 deletions(-) diff --git a/freeglut/web-src/docs/gles.php b/freeglut/web-src/docs/gles.php index a8d2e49..2c90de9 100644 --- a/freeglut/web-src/docs/gles.php +++ b/freeglut/web-src/docs/gles.php @@ -27,63 +27,51 @@ generateHeader($_SERVER['PHP_SELF']); from libraspeberrypi-dev which will shortcut X11 - see [#71] -

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).
- TODO: it seems it's possible to link both without incompatibility, so we need to remove - double-compilation.

+

FreeGLUT ES is provided as a separate library, because OpenGL ES +has a distinct library from plain OpenGL (-lGLESv1_CM +-lGLESv2 instead of -lGL, and different headers too). +We could consider dynamically loading the OpenGL symbols we need, +like libSDL.

-

When compiled for OpenGL ES 2.0, it is possible to use OpenGL ES 3.0 and higher if the device or -driver supports it by calling glutInitContextVersion(3.0, 0.0) before creating a window.

- -

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

+

It is possible to select OpenGL ES 1, 2 or 3 (if the device and +driver supports it) by calling +e.g. glutInitContextVersion(3,0) before creating a +window.

Compiling

-

Here's how to compile FreeGLUT for GLES2:

+

The following explains how to use FreeGLUT ES for Mesa EGL.
+See also the Android page.

First, check README.cmake to install the dependencies for your system.

-
-aptitude install libgles2-mesa-dev
-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:

+

Then:

-aptitude install libgles1-mesa-dev
+apt-get install libgles1-mesa-dev libgles2-mesa-dev
 cd /usr/src/freeglut-3.0.0/
-mkdir native-gles1/ && cd native-gles1/
+mkdir native-gles/ && cd native-gles/
 cmake \
-  -DCMAKE_INSTALL_PREFIX=/tmp/freeglut-native-gles1 \
+  -DCMAKE_INSTALL_PREFIX=/tmp/freeglut-native-gles \
   -D CMAKE_BUILD_TYPE=Debug \
-  -DFREEGLUT_GLES1=ON \
+  -DFREEGLUT_GLES=ON \
   -DFREEGLUT_BUILD_DEMOS=NO \
   ..
-make
+make -j4
 make install
 

Using in your projects

-

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

+

Get the 'freeglut-gles' 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)
+pkg_check_modules(freeglut REQUIRED freeglut-gles>=3.0.0)
 if(freeglut_FOUND)
   include_directories(${freeglut_STATIC_INCLUDE_DIRS})
   link_directories(${freeglut_STATIC_LIBRARY_DIRS})
@@ -94,17 +82,17 @@ endif()
 
 
 cd your_project/
-mkdir native-gles2/ && cd native-gles2/
-PKG_CONFIG_PATH=/tmp/freeglut-native-gles2/share/pkgconfig/ cmake ..
+mkdir native-gles/ && cd native-gles/
+PKG_CONFIG_PATH=/tmp/freeglut-native-gles/share/pkgconfig/ cmake ..
 
-

See for instance:

+

Examples:

  • OpenGL Wikibook's tut04_transform-gles2 - example: it uses a basic Makefile targetting freeglut-gles2
  • + example: it uses a basic Makefile targetting freeglut-gles
  • progs/test-shapes-gles1/ in the source distribution: - it is a standalone CMake app that uses FreeGLUT GLES1.
  • + it is a standalone CMake app that uses FreeGLUT GLES (v1).
From f2a534098c45f039043c4997f7b777d5d24473c9 Mon Sep 17 00:00:00 2001 From: beuc Date: Sun, 1 Jun 2014 11:04:09 +0000 Subject: [PATCH 3/5] Rewrite EGL attributes using our ATTRIB/ATTRIB_VAL macros git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1690 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/freeglut/src/egl/fg_window_egl.c | 57 ++++++++++------------- 1 file changed, 24 insertions(+), 33 deletions(-) diff --git a/freeglut/freeglut/src/egl/fg_window_egl.c b/freeglut/freeglut/src/egl/fg_window_egl.c index ff2cd27..0eff9fb 100644 --- a/freeglut/freeglut/src/egl/fg_window_egl.c +++ b/freeglut/freeglut/src/egl/fg_window_egl.c @@ -3,7 +3,7 @@ * * Window management methods for EGL * - * Copyright (C) 2012 Sylvain Beucler + * Copyright (C) 2012, 2014 Sylvain Beucler * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -27,21 +27,18 @@ #include "fg_internal.h" int fghChooseConfig(EGLConfig* config) { - EGLint attribs[32]; - int i = 0; - attribs[i++] = EGL_SURFACE_TYPE; - attribs[i++] = EGL_WINDOW_BIT; + EGLint attributes[32]; + int where = 0; + ATTRIB_VAL(EGL_SURFACE_TYPE, EGL_WINDOW_BIT); if (fgState.MajorVersion >= 2) { /* * Khronos does not specify a EGL_OPENGL_ES3_BIT outside of the OpenGL extension "EGL_KHR_create_context". There are numerous references on the internet that * say to use EGL_OPENGL_ES3_BIT, followed by many saying they can't find it in any headers. In fact, the offical updated specification for EGL does not have * any references to OpenGL ES 3.0. Tests have shown that EGL_OPENGL_ES2_BIT will work with ES 3.0. */ - attribs[i++] = EGL_RENDERABLE_TYPE; - attribs[i++] = EGL_OPENGL_ES2_BIT; + ATTRIB_VAL(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES2_BIT); } else { - attribs[i++] = EGL_RENDERABLE_TYPE; - attribs[i++] = EGL_OPENGL_ES_BIT; + ATTRIB_VAL(EGL_RENDERABLE_TYPE, EGL_OPENGL_ES_BIT); } /* Technically it's possible to request a standard OpenGL (non-ES) context, but currently our build system assumes EGL => GLES */ @@ -51,29 +48,24 @@ int fghChooseConfig(EGLConfig* config) { /* Only 888 and 565 seem to work. Based on http://qt.gitorious.org/qt/qtbase/source/893deb1a93021cdfabe038cdf1869de33a60cbc9:src/plugins/platforms/qnx/qqnxglcontext.cpp and https://twitter.com/BlackBerryDev/status/380720927475912706 */ - attribs[i++] = EGL_BLUE_SIZE; attribs[i++] = 8; - attribs[i++] = EGL_GREEN_SIZE; attribs[i++] = 8; - attribs[i++] = EGL_RED_SIZE; attribs[i++] = 8; + ATTRIB_VAL(EGL_BLUE_SIZE, 8); + ATTRIB_VAL(EGL_GREEN_SIZE, 8); + ATTRIB_VAL(EGL_RED_SIZE, 8); #else - attribs[i++] = EGL_BLUE_SIZE; attribs[i++] = 1; - attribs[i++] = EGL_GREEN_SIZE; attribs[i++] = 1; - attribs[i++] = EGL_RED_SIZE; attribs[i++] = 1; + ATTRIB_VAL(EGL_BLUE_SIZE, 1); + ATTRIB_VAL(EGL_GREEN_SIZE, 1); + ATTRIB_VAL(EGL_RED_SIZE, 1); #endif - attribs[i++] = EGL_ALPHA_SIZE; - attribs[i++] = (fgState.DisplayMode & GLUT_ALPHA) ? 1 : 0; - attribs[i++] = EGL_DEPTH_SIZE; - attribs[i++] = (fgState.DisplayMode & GLUT_DEPTH) ? 1 : 0; - attribs[i++] = EGL_STENCIL_SIZE; - attribs[i++] = (fgState.DisplayMode & GLUT_STENCIL) ? 1 : 0; - attribs[i++] = EGL_SAMPLE_BUFFERS; - attribs[i++] = (fgState.DisplayMode & GLUT_MULTISAMPLE) ? 1 : 0; - attribs[i++] = EGL_SAMPLES; - attribs[i++] = (fgState.DisplayMode & GLUT_MULTISAMPLE) ? fgState.SampleNumber : 0; - attribs[i++] = EGL_NONE; + ATTRIB_VAL(EGL_ALPHA_SIZE, (fgState.DisplayMode & GLUT_ALPHA) ? 1 : 0); + ATTRIB_VAL(EGL_DEPTH_SIZE, (fgState.DisplayMode & GLUT_DEPTH) ? 1 : 0); + ATTRIB_VAL(EGL_STENCIL_SIZE, (fgState.DisplayMode & GLUT_STENCIL) ? 1 : 0); + ATTRIB_VAL(EGL_SAMPLE_BUFFERS, (fgState.DisplayMode & GLUT_MULTISAMPLE) ? 1 : 0); + ATTRIB_VAL(EGL_SAMPLES, (fgState.DisplayMode & GLUT_MULTISAMPLE) ? fgState.SampleNumber : 0); + ATTRIB(EGL_NONE); EGLint num_config; if (!eglChooseConfig(fgDisplay.pDisplay.egl.Display, - attribs, config, 1, &num_config)) { + attributes, config, 1, &num_config)) { fgWarning("eglChooseConfig: error %x\n", eglGetError()); return 0; } @@ -92,13 +84,12 @@ EGLContext fghCreateNewContextEGL( SFG_Window* window ) { EGLConfig eglConfig = window->Window.pContext.egl.Config; /* On GLES, user specifies the target version with glutInitContextVersion */ - EGLint ctx_attribs[32]; - int i = 0; - ctx_attribs[i++] = EGL_CONTEXT_CLIENT_VERSION; - ctx_attribs[i++] = fgState.MajorVersion; - ctx_attribs[i++] = EGL_NONE; + EGLint attributes[32]; + int where = 0; + ATTRIB_VAL(EGL_CONTEXT_CLIENT_VERSION, fgState.MajorVersion); + ATTRIB(EGL_NONE); - context = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, ctx_attribs); + context = eglCreateContext(eglDisplay, eglConfig, EGL_NO_CONTEXT, attributes); if (context == EGL_NO_CONTEXT) { fgWarning("Cannot initialize EGL context, err=%x\n", eglGetError()); fghContextCreationError(); From 364d6a4cff22abd7795b677ab579eec818add68e Mon Sep 17 00:00:00 2001 From: beuc Date: Sun, 1 Jun 2014 13:37:17 +0000 Subject: [PATCH 4/5] Clarify the problem with Raspberry PI git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1691 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/web-src/docs/gles.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/freeglut/web-src/docs/gles.php b/freeglut/web-src/docs/gles.php index 2c90de9..0de8bb3 100644 --- a/freeglut/web-src/docs/gles.php +++ b/freeglut/web-src/docs/gles.php @@ -23,8 +23,11 @@ generateHeader($_SERVER['PHP_SELF']);
  • BlackBerry 10/BlackBerry PlayBook
  • Unix X11 with Mesa EGL
  • TODO: Raspberry PI: Mesa EGL doesn't work due to X11's fbdev limitation (no GL); - it needs to use bcm_host - from libraspeberrypi-dev which will shortcut X11 - see [#71]
  • + it needs to use libraries from libraspeberrypi-dev which will shortcut X11 + [1] + [2] + [3] +

    FreeGLUT ES is provided as a separate library, because OpenGL ES From c93af8dfeac4ca4629bbd82cdf9c1aed8744d214 Mon Sep 17 00:00:00 2001 From: beuc Date: Sun, 1 Jun 2014 13:55:34 +0000 Subject: [PATCH 5/5] Provide Android binaries for testers git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1692 7f0cb862-5218-0410-a997-914c9d46530a --- freeglut/web-src/docs/android.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/freeglut/web-src/docs/android.php b/freeglut/web-src/docs/android.php index 6be94d8..c240608 100644 --- a/freeglut/web-src/docs/android.php +++ b/freeglut/web-src/docs/android.php @@ -32,6 +32,9 @@ generateHeader($_SERVER['PHP_SELF']);

    Compiling

    +

    Note: a pre-built archive can be found here: + freeglut3-android-modules.tar.gz (2014-06-01 / SVN revision 1686).

    +