OpenGL ES Libraries

(New page: = 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...)
Line 1: Line 1:
-
= OpenGL ES 2.x Game Development on Nokia N900 =
+
= OpenGL ES 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.
+
Want to start developing a game for the Nokia N900 using OpenGL ES 2.0 but don't know where to start?
-
== Requirements ==
+
Here is some information about the various libraries and APIs that are available on the N900.
-
 
+
-
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 ==
== Library Support ==
-
Here are the library options I have found that could be used:
+
Here is a partial list of library options:
=== SDL ===
=== SDL ===
-
Apparently SDL 1.3 supports OpenGL ES 1.x (not sure about 2.x) however I haven't really tried it.
+
Apparently SDL 1.3 supports OpenGL ES 1.x (not sure about 2.x).
=== OpenGL ES 1.x utilies ===
=== OpenGL ES 1.x utilies ===
Line 27: Line 23:
=== Clutter ===
=== Clutter ===
-
libclutter supports OpenGL ES 2.x however from what I've read seems more for toolkits and applications with user interface elements.
+
libclutter supports OpenGL ES 2.x. It seems oriented towards toolkits and applications with user interface elements.
-
=== X11 ===
+
=== Xlib (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.
+
You could go with plain Xlib (X11) and utilise the EGL library for context creation along with OpenGL ES. This is what the Bounce Evolution game uses.
 +
 
 +
This is probably the fastest method as you have control over everything. However programming with pure Xlib is more work.  
 +
You can use OpenGL ES version 1 or 2 directly without worrying about the version that is supported by the library.
=== PVRShell ===
=== 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.
+
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.
== Notes ==
== Notes ==
 +
When you create a X11 window the hildon compositor should be disabled. This can be done by setting the property _HILDON_NON_COMPOSITED_WINDOW. There is an example Xlib application with this property set available at http://exoticorn.de/simpleglv2.tgz (http://talk.maemo.org/showthread.php?t=37356&page=2).
-
I ended up using X11 (xlib) and EGL for programming. This seemed to me to be the best option as I have direct control over everything and don't have to worry about what the API supports. I found a simple example that helped me get running quickly from the Maemo Forums (http://talk.maemo.org/showthread.php?t=37356). The thread also discusses how the hildon compositor should be disabled on the window created by setting the property _HILDON_NON_COMPOSITED_WINDOW. I have modified the example in that thread with this setting as well as a few other minor changes.
+
It appears that OpenGL ES 1.x code gets translated into OpenGL ES 2.x code using an emulation library on the Nokia N900. Is this true? If so is there a performance impact?
-
 
+
-
From what I have read, OpenGL ES 1.x code gets translated into OpenGL ES 2.x code using an emulation library on the Nokia N900. I'm not sure of the performance impact of doing this.
+
OpenGL and OpenGL ES are very different and are not compatible.  
OpenGL and OpenGL ES are very different and are not compatible.  
Line 48: Line 46:
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.  
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.  
-
WARNING: OpenGL ES doesn't run natively on a desktop computer. It is possible to get some kind of emulation library from the Khronos OpenGL ES 2.0 SDK however I decided against using it and now run the applications directly on the device.
+
WARNING: OpenGL ES doesn't run natively on a desktop computer. It is possible to get some kind of emulation library from the Khronos OpenGL ES 2.0 SDK so that you can test on a desktop computer.
OpenGL ES 1.x and OpenGL ES 2.x are also different. OpenGL ES 1.x has a fixed pipeline whereas OpenGL ES 2.x uses shaders. The matrix stack has also been removed and you have to manage it yourself.
OpenGL ES 1.x and OpenGL ES 2.x are also different. OpenGL ES 1.x has a fixed pipeline whereas OpenGL ES 2.x uses shaders. The matrix stack has also been removed and you have to manage it yourself.
-
 
-
While trying out the PVRShell for creating an OpenGL ES 2.x application I encountered something that I'm not sure is an issue or not. When I ran the TrainingCourse/03_IntroducingPVRShell example I received the message: "PVRShell: Warning! Using the SOFTWARE renderer". I looked through the PVRShell source code and found out that it was trying to set the attribute EGL_NATIVE_RENDERABLE to EGL_FALSE when calling eglChooseConfig.
 
-
I've spent some time trying to figure out if it's possible to get this attribute set to EGL_FALSE but haven't been successful. I'm not really sure if having this set to EGL_TRUE really results in software rendering.
 
-
My understanding of the attribute EGL_NATIVE_RENDERABLE is that it refers to whether other native applications have access to and can write to the framebuffer (EGL_TRUE). I'm still not entirely sure what it means.
 
-
The OpenGL ES documentation at http://www.khronos.org/opengles/sdk/1.1/docs/man/eglChooseConfig.xml says this:
 
-
 
-
EGL_NATIVE_RENDERABLE
 
-
 
-
 
-
                        Must be followed by
 
-
                        EGL_DONT_CARE,
 
-
                        EGL_TRUE, or
 
-
                        EGL_FALSE.
 
-
                        If EGL_TRUE is
 
-
                        specified, then only frame buffer configurations
 
-
                        that allow native rendering into the surface will be
 
-
                        considered.  The default value is EGL_DONT_CARE.
 
-
                   
 
-
Does anyone know about this? I thought it might have something to do with the hildon compositor but I've tried even after setting the X11 window attribute to _HILDON_NON_COMPOSITED_WINDOW but still cannot set this to EGL_FALSE.
 
=== Killing hildon ===
=== 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.
+
This doesn't need to be done anymore if the _HILDON_NON_COMPOSITED_WINDOW attribute is set. This is included for reference.
You can kill the hildon window manager with:
You can kill the hildon window manager with:
Line 82: Line 61:
== Installation and Examples ==
== 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.
+
Here are some notes about packages required for OpenGL ES development and some simple examples to help get you started. 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 on scratchbox and the device:
+
Firstly you want to install the following packages on scratchbox.
-
libgles2-sgx-img-dev
+
[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install 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.
+
This is the OpenGL ES 2.x development files required for compiling. Note: you need to add the nokia-binaries repository to install this in scratchbox.
-
opengles-sgx-img-common-dev
+
[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install 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.
+
This installs the EGL library (used for portable context creation, see the docs) and PowerVR development files. It also includes some simple demos. This also requires nokia-binaries.
 +
 
 +
Nokia-N900-42-11:~# apt-get install libgles1-sgx-img opengles-sgx-img-common
 +
 
 +
Installs the required libraries to use OpenGL ES on the N900.
Line 99: Line 82:
You need to install libqt4-opengl-dev.
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
+
It doesn't install any examples, so download 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 <QGLWidget> to #include <QtOpenGL/QGLWidget>. Also, in the hellogl_es2.pro file you should add:
+
You need to modify glwidget.h and change #include <QGLWidget> to #include <QtOpenGL/QGLWidget>. Also, in the hellogl_es2.pro file you should add:
LIBS += -lGLESv2 -lQtOpenGL
LIBS += -lGLESv2 -lQtOpenGL
Line 124: Line 107:
  main: main.o
  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.
+
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.
-
 
+
-
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.
+
There is a nice simple example at the Maemo Talk page (http://talk.maemo.org/showthread.php?t=37356). You can download it from http://exoticorn.de/simpleglv2.tgz
== Resources ==
== Resources ==
-
Here are some resources I found useful.
+
Here are some resources.
*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://www.unrealvoodoo.org/hiteck/projects/maemo/ (NOTE: Links to the git repositories are broken. You can find them  at http://www.unrealvoodoo.org/git/)

Revision as of 04:35, 22 December 2009

Contents

OpenGL ES Game Development on Nokia N900

Want to start developing a game for the Nokia N900 using OpenGL ES 2.0 but don't know where to start?

Here is some information about the various libraries and APIs that are available on the N900.

Library Support

Here is a partial list of library options:

SDL

Apparently SDL 1.3 supports OpenGL ES 1.x (not sure about 2.x).

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. It seems oriented towards toolkits and applications with user interface elements.

Xlib (X11)

You could go with plain Xlib (X11) and utilise the EGL library for context creation along with OpenGL ES. This is what the Bounce Evolution game uses.

This is probably the fastest method as you have control over everything. However programming with pure Xlib is more work. You can use OpenGL ES version 1 or 2 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. It doesn't seem to have much support for handling events.

Notes

When you create a X11 window the hildon compositor should be disabled. This can be done by setting the property _HILDON_NON_COMPOSITED_WINDOW. There is an example Xlib application with this property set available at http://exoticorn.de/simpleglv2.tgz (http://talk.maemo.org/showthread.php?t=37356&page=2).

It appears that OpenGL ES 1.x code gets translated into OpenGL ES 2.x code using an emulation library on the Nokia N900. Is this true? If so is there a performance impact?

OpenGL and OpenGL ES are very different and are not compatible.

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.

WARNING: OpenGL ES doesn't run natively on a desktop computer. It is possible to get some kind of emulation library from the Khronos OpenGL ES 2.0 SDK so that you can test on a desktop computer.

OpenGL ES 1.x and OpenGL ES 2.x are also different. OpenGL ES 1.x has a fixed pipeline whereas OpenGL ES 2.x uses shaders. The matrix stack has also been removed and you have to manage it yourself.

Killing hildon

This doesn't need to be done anymore if the _HILDON_NON_COMPOSITED_WINDOW attribute is set. This is included 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. 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 on scratchbox.

[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install 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 in scratchbox.

[sbox-FREMANTLE_ARMEL: ~] > fakeroot apt-get install opengles-sgx-img-common-dev

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

Nokia-N900-42-11:~# apt-get install libgles1-sgx-img opengles-sgx-img-common

Installs the required libraries to use OpenGL ES on the N900.


Qt Example

You need to install libqt4-opengl-dev.

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

You need to modify glwidget.h and change #include <QGLWidget> to #include <QtOpenGL/QGLWidget>. 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. The rest make use of PowerVR libraries which have to be linked in with the program.

There is a nice simple example at the Maemo Talk page (http://talk.maemo.org/showthread.php?t=37356). You can download it from http://exoticorn.de/simpleglv2.tgz


Resources

Here are some resources.