OpenGL ES Libraries

= OpenGL ES 2.x Game Development on Nokia N900 =

I wanted to start developing a game for the Nokia N900 using OpenGL ES 2.0. However I didn't really know where to start and had to learn a lot about the various libraries and APIs that are available on this device. Here is some information that I have obtained that may help.

Requirements
Here are the requirements that I decided: I want to use OpenGL ES 2.x I don't want to use an emulation library

Library Support
Here are the library options I have found that could be used:

SDL
Apparently SDL 1.3 supports OpenGL ES 1.x (not sure about 2.x) however I haven't really tried it.

OpenGL ES 1.x utilies
http://www.unrealvoodoo.org/hiteck/projects/maemo/ 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.

Qt
You can use Qt with OpenGL ES 2.x on the Nokia N900. There is an example application called hellogl_es2 (http://qt.gitorious.org/qt/qt/trees/4.5/examples/opengl/hellogl_es2) which shows how to use OpenGL ES with a QtWidget.

Clutter
libclutter supports OpenGL ES 2.x however from what I've read seems more for toolkits and applications with user interface elements.

X11
You could go with plain X11 (xlib) and utilise the EGL library for context creation along with OpenGL ES. This is what the 'bounce' game uses. Probably the fastest method as you have control over everything. However programming with pure xlib is a bit ugly. This means you can use OpenGL ES directly without worrying about the version that is supported by the library.

PVRShell
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 but I found that it didn't really handle events very well.

Killing hildon
This probably doesn't need to be done anymore if the _HILDON_NON_COMPOSITED_WINDOW attribute is set. I'm including it here just for reference.

You can kill the hildon window manager with: dsmetool -k /usr/bin/hildon-desktop Restore with: dsmetool -t /usr/bin/hildon-desktop

Installation and Examples
Here are some notes about packages required for OpenGL ES development and some simple examples to help get you started. I decided that I would prefer running the applications on the device itself so that compatibility issues are reduced. I still compile with scratchbox. I use the ESBox IDE for development as it makes it much easier to execute the application on the device. It automates copying the binary onto the device and execution. Very handy.

Firstly you want to install the following packages on scratchbox and the device:

libgles2-sgx-img-dev

This is the OpenGL ES 2.x development files required for compiling. Note: you need to add the nokia-binaries repository to install this.

opengles-sgx-img-common-dev

This installs the EGL library (used for portable context creation, see the docs) and PowerVR development files. I just looked and it includes some simple demos also. This also requires nokia-binaries.

Qt Example
You need to install libqt4-opengl-dev.

It doesn't install any examples, so I downloaded the hellogl_es2 example from here: http://qt.gitorious.org/qt/qt/trees/4.5/examples/opengl/hellogl_es2

I also found that in the hellogl_es2 example you need to modify glwidget.h and change #include  to #include . Also, in the hellogl_es2.pro file you should add:

LIBS += -lGLESv2 -lQtOpenGL

Then run: qmake -project

qmake

make

Which will (hopefully) compile hellogl_es2. Then you can copy the binary to the device and run it.

X11 Examples
You can usually compile any X11 examples 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 and OpenGL ES. The rest make use of PowerVR libraries which have to be linked in with the program.

I found a nice simple example at the Maemo Talk page (http://talk.maemo.org/showthread.php?t=37356). I modified it to set _HILDON_NON_COMPOSITED_WINDOW and remove some things as suggested on the forums.

SimpleGL Example

Hopefully this has been useful.

Resources
Here are some resources I found useful.


 * http://www.unrealvoodoo.org/hiteck/projects/maemo/ (NOTE: Links to the git repositories are broken. You can find them at http://www.unrealvoodoo.org/git/)
 * http://qt.gitorious.org/qt/qt/trees/4.5/examples/opengl/hellogl_es2 - hellogl_es2 example for Qt 4.5
 * http://wiki.maemo.org/OpenGL-ES - OpenGL ES page an the maemo wiki with useful information
 * http://www.imgtec.com/powervr/insider/sdk/KhronosOpenGLES2xSGX.asp - Khronos OpenGL ES 2.0 SDK has useful examples and a good way to start
 * http://talk.maemo.org/showthread.php?t=37356 - Thread discussing performance of OpenGL ES
 * http://wiki.maemo.org/Game_development - Page describing game development. However seems more oriented for 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 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.