OpenGL-ES
Contents[hide] |
OpenGL ES
Maemo OpenGL ES
Books about OpenGL ES
Excellent introductory section covering OpenGL basics. Covers ES 1.1, not ES 2.0.
The '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.
Other documentation
Imagination Technologies SDK
Other related documentation
- Kate's presentation in Bossa 2009 conference about Fremantle and section about OpenGL ES 2.0
OpenGL variants
- OpenGL 1.0 has fixed shaders and fixed function API to using them
- OpenGL 2.0 adds programmable shaders, but fixed function pipeline API is still there for backward compatibility
- OpenGL 3.1 removes support for old fixed function pipeline, so it is very similar to OpenGL ES 2.0
- OpenGL ES 1.0 is based on OpenGL 1.0 with extra redundant API's removed and fixed point (fractional integer) API added
- OpenGL ES 2.0 is based on OpenGL 2.0, so using programmable shaders is mandatory, since all old fixed function API's have been removed
Porting between OpenGL variants
- OpenGL 1.0 application works with OpenGL 2.0 but not vice versa
- OpenGL 1.0 application is possible to port to OpenGL ES 1.0, but needs work if it is using some of the removed API's
- OpenGL 2.0 application that only uses programmable shaders is possible to port OpenGL ES 2.0, but may still need some work
- Porting OpenGL 1.0 or OpenGL ES 1.0 applications to OpenGL ES 2.0 needs a rewrite to replace fixed function API usage with programmable shaders
What this means in paractice ?
Most of the desktop Linux OpenGL applications are written mostly using the OpenGL1.x style fixed pipeline API's including extensive use of glBegin/glEnd and application level matrix transformation calls. OpenGL2.0 introduces programable shaders that allows moving these tasks to Graphics processor ( GPU ) but does not force it. In OpenGL-ES2.0 the old fixed pipeline API's are removed and can't be used any more. It is mandatory to use programable shaders and some code must be rewritten. The rewritten code can then also take advantage of programable shaders in desktop OpenGL 2.x implementations. Other alternative with less rewriting is to use OpenGL-ES1.0 emulation libraries in maemo. These libraries contain OpenGL-ES1.0 API and fixed OpenGL-ES1.0 emulating shader code.
Compiling under scratchbox
There is an excellent way to familiarize yourself with OpenGL ES 2.0 which is by trying the PowerVR tutorials that can be found in the SDK under the TrainingCourse directory.
Get the SDK here: [1]
The SDK libs and headers can be dropped into your X86 environment and run into the Xephyr X11 window - but you'll need to kill the window manager first!
To compile OpenGL ES 2.0 applications you need to have package "libgles2-dev" installed. It is as standard, part of Fremantle aplha ARMEL but at the moment it is missing from gthe x86 version. We try to get the x86 equivalent OpenGL ES2 emulation library available soon.
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 PoverVR tutorial examples, you can use the following Makefile
CC=g++ CPPFLAGS = -DBUILD_OGLES2 LDFLAGS=-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
Using with QGLWidget
There is in Qt 4.5 ready made example hellogl_es2 that can be found from examples/opengl/hellogl_es2 directory. There is also equivalent examples for desktop opengl and opengl_es2 .
The example is also good showing what is different between OpenGL versions. The hellogl uses plain desktop "glBegin / glEnd" functions with display lists. Hellogl_es2 uses vertex attribute pointers and shaders instead of glBegin/glEnd. The helloes_gl2 is even more complicated because it uses programmable shaders instead fixed pipeline in both of the previous exaples.
If you try compile yourself unmodified version of hellogl_es2 for maemo, you need to add in void GLWidget::initializeGL ()
Line in beginningsetlocale(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