OpenGL-ES

Line 19: Line 19:
=== Other related documentation ===
=== Other related documentation ===
-
* [http://blogs.forum.nokia.com//data/blogs/resources/300003/fremantle_bossa_2009.pdf Kate's presentation in Bossa 2009 conference] about Fremantle and section about OpenGL ES2.0
+
* [http://blogs.forum.nokia.com//data/blogs/resources/300003/fremantle_bossa_2009.pdf Kate's presentation in Bossa 2009 conference] about Fremantle and section about OpenGL ES 2.0
=== OpenGL variants ===
=== OpenGL variants ===
[[image:Opengl.svg]]
[[image:Opengl.svg]]
-
* OpenGL 1.0 has fixed shaders and fixed API to using them
+
* OpenGL 1.0 has fixed shaders and fixed function API to using them
-
* OpenGL 2.0 adds programable shaders but fixed pipeline api is still there for backward compatibility
+
* 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 1.0 is based on OpenGL 1.0 with extra redundant API's removed and fixed point (fractional integer) API added

Revision as of 13:14, 26 March 2009

Contents

OpenGL ES

Maemo OpenGL ES

Books about OpenGL ES

Other documentation

Imagination Technologies SDK

Other related documentation

OpenGL variants

image:Opengl.svg

  • 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

To compile OpenGL ES 2.0 applivations 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 x86 version. We try to get x86 equivalent OpenGL ES2 emulation library available soon.

There is excellent way to familiarize yourself to OpenGL ES 2.0 by trying the PoverVR tutorials that can be found form SDK under TrainingCouse directory. The examples have their own Makefiles for Linux host but you can copy the files to your own directory and try makefile below. Reason to use this own Makefile is thet the makefiles coming with 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 not yet support PvrTools exaples ( 06 and above ).

To compile some of PoverVR tutorial examples, you can use 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 beginning
setlocale(LC_NUMERIC, "C"); // Reset locale for compilation
and after shaders has been compiled line
 setlocale(LC_ALL, ""); // restore locale

because locale affects in shader compilation even it should not do