|Version 14 (modified by robert, 8 years ago)|
OpenGL ES Support
Note from Robert Osfield, October 5th 2009:
I have been commissioned to port the OpenSceneGraph to OpenGL ES 2.0. This work commenced on the 5th October 2009, and is expected see results merged into a branch of the OpenScenGraph subversion repository in October, with the intention of merging the changes into OpenScenGraph svn/trunk as soon as elements of the code base are suitable for being maintained alongside the rest of the OpenGL code base. OpenGL ES 1.1 support and OpenGL 3.x support is not directly part of the project, but my plan is the re-factor the OpenScenGraph build system and code base to enable relatively straight forward management of multiple OpenGL x.x and OpenGL ES x.x versions, and would welcome collaboration on support of these additional APIs as well as my core task of OpenGL ES 2.0 support.
I will use this page to list development plans, details of the OpenGL ES branch and how to build against it for your intended target API. Right now I'm assembling the various bits of hardware, tools, and API's that I'll need for the task, and will soon move on to design and doing test ports to scope out what will be the best route forward in terms of design and implementation. So watch this space, and also keep track of discussions on this topic on the osg-users list/forum.
Areas of OpenSceneGraph code base that need refactoring
- CMake needs to be updated to check for OpenGL, OpenGL ES + GLU versions installed
- All usage of glBegin/glEnd needs replacing with vertex array based codes.
- glVertexPoint/glColorPointer etc. usages needs remapping to glVertexAttribPointer equivalents.
- glVertex/glColor etc. usages needs remapping to glVertexAttrib equivalents.
- ModelView and Projection matrices need to be implemented using uniforms.
- All GLU related functions must be replaced or disabled.
- Shaders need to be rewritten (potentially at shader compilation time) to use osg_ equivalents of gl_ built in uniforms.
- Need to enumerate and then disable the OpenGL fixed function code implementation in various StateAttribute subclasses.
- Need a compile time and run time scheme for checking for feature support.
- Need support for shader compilation and objects found in GLES 2.0.
- Need to look at !OpenGL centric #define's that the OpenSceneGraph headers
- Optional disable of all OpenGL display lists codes
Areas of OpenSceneGraph code base refactoring has now been completed
- None so far, we're still in the exploratory and design stage :-)
Completed Mini milestones
- Review OpenGL ES 2.0 specs, the ES 2.0 headers and emulator SDK from http://www.imaginationtechnologies.com/.
- Review OpenSceneGraph codebase with a view to pinpointing the potential obstacles to porting.
- Draw up plan for tackling port.
- Get a build of OpenSceneGraph that via CMake option does not build against GLU
- Write an OpenSceneGraph example that does not use the replaces the standard usage of gl_ModelViewMatrix and gl_ProjectMatrix with osg_ maintained equivalents. This will require osg::State to manage the uniforms automatically. Example is called osgvertexattributes and is already checked into svn/trunk.
Mini milestones currently being tackled
- Modify the above example so that it uses OpenSceneGraph generated vertex attributes rather than gl_Vertex. This will require osg::State to remap the conventional vertex/colour arrays to vertex attrib equivalents.
Pending Mini milestones
OpenSceneGraph preparation stage (doesn't directly require GLES target)
- Modify all glBegin/glEnd code usage to use vertex array/vertex attrib arrays instead. Potentially we could use osg::State to mimic glBegin/glEnd usage, or cache an osg::Geometry to do this job for us.
- Modify all glVertex/glColor usage to use vertex attrib equivalents. Potentially we could use use osg::State to do the remapping for us.
- Implement an CMake option(s) that allows disabling of all fixed function StateAttribute::apply() methods that are unsupported by OpenGL ES 2.0 + OpenGL 3.x.
OpenSceneGraph porting to compile against OpenGL ES 2.0 (desktop emulator)
- Modify the include/osg/Config + include/GL to automatically pull in the correct version of GL/GLES that the OpenSceneGraph has been compiled against, and provide #define's that the OpenSceneGraph and end user applications can use to determine which GL type is compiled into the OpenSceneGraph libraries.
- Implement support for EGL in osgViewer.
- Modify osg::Shader to use OpenGL ES 2.0's shader object set up.
- Where possible modify shadeers supplied with OpenSceneGraph distribution or OpenSceneGraph-Data to work with OpenGL ES 2.0.
OpenSceneGraph OpenGLES 2.0 testing and debugging phase
- Test OpenSceneGraph builds and runs against OpenGL 1.x, OpenGL 2.x targets i.e. we haven't broken compatibility with standard desktop systems
- Test OpenSceneGraph builds and runs against OpenGL ES 2.0 desktop emulators and embedded systems.