Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Guide to writing OpenGL and OpenGL ES compatible code? [closed]

I am familiar with the basic differences between OpenGL and OpenGL ES, e.g. no glBegin, glEnd, no quads and so forth.

My question is therefore not about the differences between the two APIs but about writing code that can actually work on both APIs and their various implementations, especially regarding ES, where implementations seem to vary more.

Naturally, that means conforming to features that are both present in the two APIs and identical syntax, nothing too fancy and cutting edge, with OpenGL ES 2 being the lowest common denominator.

like image 874
dtech Avatar asked Apr 25 '12 13:04

dtech


2 Answers

You may be interested in the new OpenGL ES compatibility extension ARB_ES2_compatibility (added to core in OpenGL 4.1)

Of course actually using the extension requires support for newer 4.1 desktop OpenGL but you can read through them and see what was required to get ES support on the desktop and avoid that in your ES code as much as possible. There may be some things that just aren't compatible with older desktop OpenGL versions though, mainly some shader stuff such as floating point precision.

There is also ARB_ES3_compatibility (core in OpenGL 4.3), but it's probably safe to ignore since it's for OpenGL ES 3.0).

like image 64
David C. Bishop Avatar answered Nov 10 '22 00:11

David C. Bishop


According to Khronos OpenGL ES is a subset of desktop OpenGL, so to write compatible code you just need to use OpenGL ES documentation.

A quote from http://www.khronos.org/opengles/

OpenGL® ES is a royalty-free, cross-platform API for full-function 2D and 3D graphics on embedded systems - including consoles, phones, appliances and vehicles. It consists of well-defined subsets of desktop OpenGL

EDIT: As Justin Meiners pointed out in the comments there are actually some differences when it comes to the fine details. David C. Bishop's answer has more info on this.

like image 42
Graeme Hill Avatar answered Nov 10 '22 00:11

Graeme Hill