Version 19 (modified by robert, 4 years ago)

--

OpenGL ES Support

The OpenGL ES port is now sufficiently complete for widespread testing, and is available in source code form from OpenSceneGraph svn/trunk and the latest developer release, !OpenSceneGraph-2.9.6. To enable the OpenGL ES build you'll need to use "ccmake ." from the OpenSceneGraph source directory, to point the build at the GLES and EGL libraries and set the appropriate OSG/GL features on/off, you also use these OSG/GL feature settings to emulate GLES style functionality even when compiling against standard OpenGL. The Cmake variables you'll need to set are:

Cmake settings for OpenGL ES 1.1

OSG_GLU_AVAILABLE OFF
OSG_GL1_AVAILABLE OFF
OSG_GL2_AVAILABLE OFF
OSG_GL3_AVAILABLE OFF
OSG_GLES1_AVAILABLE ON
OSG_GLES2_AVAILABLE OFF
OPENGL_INCLUDE /pathtogles/include/
OPENGL_LIBRARY /pathtogles/lib/libGLES_CM.so
OPENGL_egl_LIBRARY /pathtoegllib/libEGL.so
OSG_GL_DISPLAYLISTS_AVAILABLE OFF
SG_GL_MATRICES_AVAILABLE ON
OSG_GL_VERTEX_FUNCS_AVAILABLE ON
OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE ON
OSG_GL_FIXED_FUNCTION_AVAILABLE ON
OSG_CPP_EXCEPTIONS_AVAILABLE OFF

Cmake settings for OpenGL ES 2.0

OSG_GLU_AVAILABLE OFF
OSG_GL1_AVAILABLE OFF
OSG_GL2_AVAILABLE OFF
OSG_GL3_AVAILABLE OFF
OSG_GLES1_AVAILABLE OFF
OSG_GLES2_AVAILABLE ON
OPENGL_INCLUDE /pathtogles/include/
OPENGL_LIBRARY /pathtogles/lib/libGLESv2.so
OPENGL_egl_LIBRARY /pathtoegllib/libEGL.so
OSG_GL_DISPLAYLISTS_AVAILABLE OFF
SG_GL_MATRICES_AVAILABLE OFF
OSG_GL_VERTEX_FUNCS_AVAILABLE OFF
OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE OFF
OSG_GL_FIXED_FUNCTION_AVAILABLE OFF
OSG_CPP_EXCEPTIONS_AVAILABLE OFF

Cmake settings for Emulating OpenGL ES 1.1 when you only have standard OpenGL available:

OSG_GLU_AVAILABLE OFF
OSG_GL1_AVAILABLE ON
OSG_GL2_AVAILABLE ON
OSG_GL3_AVAILABLE OFF
OSG_GLES1_AVAILABLE OFF
OSG_GLES2_AVAILABLE OFF
OSG_GL_DISPLAYLISTS_AVAILABLE OFF
SG_GL_MATRICES_AVAILABLE ON
OSG_GL_VERTEX_FUNCS_AVAILABLE ON
OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE ON
OSG_GL_FIXED_FUNCTION_AVAILABLE ON
OSG_CPP_EXCEPTIONS_AVAILABLE OFF

Cmake settings for Emulating OpenGL ES 2.0 when you only have standard OpenGL available:

OSG_GLU_AVAILABLE OFF
OSG_GL1_AVAILABLE ON
OSG_GL2_AVAILABLE ON
OSG_GL3_AVAILABLE OFF
OSG_GLES1_AVAILABLE OFF
OSG_GLES2_AVAILABLE OFF
OSG_GL_DISPLAYLISTS_AVAILABLE OFF
SG_GL_MATRICES_AVAILABLE OFF
OSG_GL_VERTEX_FUNCS_AVAILABLE OFF
OSG_GL_VERTEX_ARRAY_FUNCS_AVAILABLE OFF
OSG_GL_FIXED_FUNCTION_AVAILABLE OFF
OSG_CPP_EXCEPTIONS_AVAILABLE OFF

Areas of OpenSceneGraph code base that need refactoring

  • CMake needs to be updated to check for OpenGL, OpenGL ES + GLU versions installed
  • Need a compile time and run time scheme for checking for feature support.

Areas of OpenSceneGraph code base refactoring has now been completed

  • Need support for shader compilation and objects found in GLES 2.0.
  • All GLU related functions must be replaced or disabled.
  • ModelView and Projection matrices need to be implemented using uniforms.
  • glVertexPoint/glColorPointer etc. usages needs remapping to glVertexAttribPointer equivalents.
  • glVertex/glColor etc. usages needs remapping to glVertexAttrib equivalents.
  • Shaders need to be rewritten (potentially at shader compilation time) to use osg_ equivalents of gl_ built in uniforms.
  • All usage of glBegin/glEnd needs replacing with vertex array based codes.
  • Need to enumerate and then disable the OpenGL fixed function code implementation in various StateAttribute subclasses.
  • Need to look at !OpenGL centric #define's that the OpenSceneGraph headers
  • Optional disable of all OpenGL display lists codes

Mini milestones

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.
  • 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.
  • 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.
  • 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.
  • 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.

Pending Mini milestones

  • Improved CMake support for controlling compile options for OpenGL ES/OpenGL targets
  • Runtime checks for OpenGL feature support
  • EGL support under Windows (added to GraphicsWindowWin?32)