OpenGL ES
OpenGL ES is an API that allows programmers to draw 3D graphics on mobile and embedded devices. Hardware accelerated OpenGL ES 1.1 and 2.0 are available on Maemo devices beginning with the N900.
 OpenGL variants
OpenGL ES is a subset of the full OpenGL standard, and therefore the two APIs are not directly compatible. The following diagram shows the relationship of the major OpenGL versions and variants.
OpenGL 1.0 has fixed shaders and fixed function API for using them. OpenGL 2.0 adds programmable shaders, but fixed function pipeline API is still supported for backward compatibility.
In contrast, OpenGL ES 1.1 is based on OpenGL 1.x with some APIs removed and fixed point integer support added. OpenGL ES 2.0 is based on OpenGL 2.0 with the fixed function API removed.
 Porting between OpenGL variants
All versions and variants of OpenGL are not directly compatible, so a certain amount of changes are needed when moving applications from one variant to another. The following diagram summarizes these changes for major OpenGL versions.
OpenGL 1.0 applications work with OpenGL 2.0 but not vice versa. OpenGL 1.0 applications can be ported to OpenGL ES 1.1, but need changes if they are using some of the removed APIs. OpenGL 2.0 application that only uses programmable shaders is possible to port OpenGL ES 2.0, but may still need some work due to , e.g., differences in the shading language versions. Finally, porting OpenGL 1.0 or OpenGL ES 1.1 applications to OpenGL ES 2.0 requires a rewrite to replace fixed function API usage with programmable shaders.
Most desktop Linux OpenGL applications are written using the legacy OpenGL 1.x fixed function pipeline (e.g. usage of glBegin/glEnd and the matrix stack). OpenGL 2.0 introduced programmable shaders, but it still supports the legacy fixed function pipeline. Since in OpenGL ES 2.0 the fixed function pipeline has been completely removed, porting applications from OpenGL 2.0 to OpenGL ES is likely to require a major rewrite of the application's graphics code.
 Getting started
An excellent way to familiarize yourself with OpenGL ES 2.0 is to try the tutorials that can be found in the PowerVR SGX SDK under the TrainingCourse directory.
The SDK libs and headers can be dropped into your Scratchbox X86 environment and run inside the Xephyr X11 window - but you'll need to kill the window manager first!
The examples have their own Makefiles for Linux hosts but you can copy the files to your own directory and try the Makefile below. Reason to use this own Makefile is that the makefiles coming with the SDK compiles examples with x86 libraries part of the SDK and not armel/x86 maemo libraries in scratchbox.
This Makefile at the moment supports the basic and PvrShell examples (01..05) but does not yet support PvrTools examples (06 and above).
To compile some of PowerVR tutorial examples, you can use the following Makefile
CC=g++ CPPFLAGS = -DBUILD_OGLES2 LDLIBS=-lEGL -lX11 -lGLESv2 all:OGLES2Texturing OGLES2BasicTnL OGLES2IntroducingPVRTools OGLES2HelloTriangle_LinuxX11 OGLES2HelloTriangle_LinuxX11:OGLES2HelloTriangle_LinuxX11.o OGLES2Texturing: PVRShellOS.o OGLES2Texturing.o PVRShell.o PVRShellAPI.o OGLES2BasicTnL: PVRShellOS.o OGLES2BasicTnL.o PVRShell.o PVRShellAPI.o OGLES2IntroducingPVRTools: PVRShellOS.o OGLES2IntroducingPVRTools.o PVRShell.o PVRShellAPI.o
You can compile OpenGL ES applications with Scratchbox. The ESBox IDE makes it much easier to execute the application on the device. It automates copying the binary onto the device and execution.
Firstly you want to install the following packages in Scratchbox.
[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install libgles2-sgx-img-dev
This installs the OpenGL ES 2.0 development files required for compiling.
[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install opengles-sgx-img-common-dev
This installs the EGL library (used for portable context creation, see the documentation) and PowerVR development files. It also includes some simple demos.
If you want OpenGL ES 1.x compatibility then install the following package in Scratchbox:
[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install libgles1-sgx-img-dev
Now install the required libraries on the N900:
Nokia-N900-42-11:~# apt-get install libgles1-sgx-img libgles2-sgx-img opengles-sgx-img-common
 Library support
This section includes a partial list of library options for using OpenGL ES.
 SDL 1.2 + SDL-GLES
The N900 ships with SDL 1.2. You can use that and a external library, SDL-GLES (available in extras), to create simple OpenGL ES 1.1 and 2.0 applications.
 SDL 1.3
SDL 1.3 supports OpenGL ES 1.x. This does not seem to work in the N900 as of now.
 OpenGL ES 1.x utilies
Sami Kyöstilä has developed a number of utilities. This includes SDL with OpenGL ES 1.x support, libglutes, python-opengles and several translators to convert OpenGL ES and OpenGL. Note that these utilities are designed for the Nokia N810 and OpenGL ES 1.x.
You can use Qt with OpenGL ES 2.x on the N900.
libclutter supports OpenGL ES 2.x and OpenGL ES 1.1. It is oriented towards toolkits and applications with user interface elements.
 Xlib (X11)
You can use Xlib (X11) and utilize the EGL library for context creation along with OpenGL ES. This is what the Bounce Evolution game uses.
You can use OpenGL ES version 1 or 2 directly without worrying about the version that is supported by the library.
See below for an example Xlib application.
The Khronos OpenGL ES 2.0 SDK includes a simple API for window creation called PVRShell. They also include additional tools for more advanced computer graphics applications. It is much simpler to create an OpenGL ES 2.0 application using PVRShell. It doesn't seem to have much support for handling events.
 Qt Example
You need to install libqt4-opengl-dev:
[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install libqt4-opengl-dev
There is an example application called hellogl_es2. There is also equivalent examples for desktop opengl and opengl_es2. Get it here:
This example shows how to use OpenGL ES embedded in a QtWidget. The example is also good showing what is different between OpenGL versions. hellogl uses plain desktop "glBegin / glEnd" functions with display lists. hellogl_es2 uses vertex attribute pointers and shaders instead of glBegin/glEnd. helloes_gl2 is even more complicated because it uses programmable shaders instead of fixed pipeline in both of the previous examples.
If you try to compile the unmodified version of hellogl_es2 for Maemo, you need to add in
void GLWidget::initializeGL (). Modify glwidget.h and change
#include <QGLWidget> to
setlocale(LC_NUMERIC, "C"); // Reset locale for compilationand after shaders has been compiled line
setlocale(LC_ALL, ""); // restore locale
because locale affects in shader compilation even it should not do.
hellogl_es2.pro and add:
QT += openglThen run:
qmake -project qmake make
Which will (hopefully) compile hellogl_es2. Then you can copy the binary to the device and run it.
 Xlib Examples
You can usually compile any Xlib example with a simple Makefile like:
CC=g++ LDLIBS=-lEGL -lX11 -lGLESv2 all: main main: main.o
In the PowerVR SDK TrainingCourse directory there are a number of examples. The first two use only Xlib. The rest make use of PowerVR libraries which have to be linked in with the program.
There is a simple Xlib example in a separate article.
 SDL-GLES Example
The NeHeGLES examples are available from extras-devel. Within armel-scratchbox, a simple
fakeroot apt-get build-dep nehegles
will install all the necessary libraries. An additional
fakeroot apt-get source nehegles
will then install the sourcecode of the nehegles lessons. A "make" in the nehegles root directory builds all the included lessons as well as the gui. Individual lessons can be recompiled by a simple "make" in their respective directories.
 Python example
On  you can find xlib_wrapper.py and opengltest.py (port of SimpleGL example).
- WARNING: If you try to run an OpenGL application with scratchbox then it will most likely work. This is because it uses the native operating system OpenGL libraries to execute. However, if you try and run it on the device it will not work as it only has OpenGL ES libraries.
- OpenGL ES does not run natively on a desktop computer. It is possible to get some kind of emulation library from the PowerVR Insider SDK  so that you can test on a desktop computer. The OpenGL ES 2.0 emulation library was packaged for use inside the FREMANTLE_X86 scratchbox target (package libgles2-dev, extras-devel non-free repository).
- If you require any kind of performance in Maemo 5, you need to make your window full screen.
 Further reading
Here are some useful resources.
- http://www.unrealvoodoo.org/hiteck/projects/maemo/ - Maemo Experiments
- http://qt.gitorious.org/qt/qt/trees/4.5/examples/opengl/hellogl_es2 - hellogl_es2 example for Qt 4.5
- http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES2xSGX.asp - Khronos OpenGL ES 2.0 SDK has useful examples
- http://talk.maemo.org/showthread.php?t=37356 - Thread discussing performance of OpenGL ES
- Game_development - Page describing game development on Maemo. More oriented towards 2D games but has some useful information
- http://www.forum.nokia.com/info/sw.nokia.com/id/0ea5ec64-2d35-4363-94c0-dd2560c6524b/Get_started_with_Maemo_5.html - If you don't know how to start with Maemo development in general then look here
- http://repository.maemo.org/ - Information about repositories
- http://www.khronos.org/opengles/sdk/docs/man/ - OpenGL ES 2.0 Reference Page
- http://www.khronos.org/opengles/sdk/1.1/docs/man/ - OpenGL ES 1.1 Reference Page. It also has information about EGL
- http://n2.nabble.com/Fremantle-OpenGL-wrapper-td3013572.html - Thread discussing ideas about OpenGL and Maemo
- Kate Alhola's presentation in Bossa 2009 conference about Fremantle and section about OpenGL ES 2.0
- Mobile 3D graphics with OpenGL ES and M3G – Excellent introductory section covering OpenGL basics. Covers OpenGL ES 1.1, not 2.0.
- OpenGL ES 2.0 programming guide – This 'Gold Book' is hardly in the same league as the above book, or the original 'Red Book' - being aimed at folk who already know their OpenGL lingo. It dives into laborious detail as if trying to spew as much of the ES 2.0 spec onto the page as possible. It assumes a Windows audience and the AMD simulator. You may be better off looking at the PowerVR SDK tutorial code than reading this book, then coming back to it for reference and further code examples.
- This page was last modified on 10 October 2010, at 14:04.
- This page has been accessed 57,180 times.