Delta Engine Blog

All about multiplatform and game development

OpenGL ES 2.0: The many faces of one API

Our Delta Engine supports many platforms, which support many different graphics API's like XNA, DirectX9, DirectX10, DirectX11, OpenGL2, OpenGL3, OpenGL ES 1.1 and OpenGL ES 2.0. Currently I am just working with different flavors of OpenGL ES 2.0 implementations and trying to integrate them all into our Delta Engine. To make it even more interesting, there are at least 4 OpenGL ES 2.0 windows emulators, which we support (we add new ones as soon as we discover them): One from PowerVR, one from Nvidia (Tegra), one from Qualcomm, and one from Mali

 

For each emulator (which roughly corresponds to a specific platform), there is a header file (gl2ext.h) plus the default one from khronos which describes available extensions.

 

My task was to merge all those files into a single file (in C#), which we can use on all platforms. First idea was to convert this by hand, but in sight of evolving platforms, this solution was thrown away quickly. Second idea was to write an automated converter, which is what I am working on right now.

 

Even though these headers should be quite similar in structure and naming (remember, there is khronos which approves all those extensions), there were many differences and inconsistencies. I started with Nvidia Tegra header, which looked real good at first. Next was khronos. They sometimes just omit parameter names from their function prototypes. Really funny... (not!). So I needed to switch parsing the real function declarations instead of prototypes. Would be no problem so far, besides mapping the ugly uppercase function names to their nice camel-cased counterparts. IF they would obey their own naming scheme consistently - which they do not ;)

 

Just some examples:
  • There were sudden lower-case letters: "PFNGLGETTEXLEVELPARAMETERiVNVPROC"
  • Naming inconsistencies: Prototype: "glDrawPathbufferNV" Declaration: "PFNGLDRAWPATHBUFFERPROC" (Note they missed their own NV :) )
  • Missing PROC: "PFNGLFRAMEBUFFERTEXTURE3DOES" instead of "PFNGLFRAMEBUFFERTEXTURE3DOESPROC"
All in all this took way longer than it was planned, but at least it is working now :)