Game Development Reference
In-Depth Information
Also, GL ES only knows glColor4f as the function to create a color; glColor3f , glColor3d ,
glColor4d or any other color conventions must be converted to glColor4f , like so:
#define glColor4fv(a) glColor4f(a[0], a[1], a[2], a[3])
#define glColor3fv(a) glColor4f(a[0], a[1], a[2], 1.0f)
#define glColor3f(a,b,c) glColor4f(a, b, c, 1.0f)
These are the most common portability caveats you will find between GL and GL ES. The
problem with the preceding approach is that you must change the code to fit the new
platform, which, depending on the size of your engine, resources, and time constraints, may
not be a viable solution. Here is where library wrappers can help.
Using Library Wrappers
In the previous section, you learned how to deal with GL-to-GL ES portability caveats by
changing your code (basically adjusting the immediate mode to use gl arrays instead when
running in a mobile processor). That may take time and consume valuable development
resources. Another way to deal with PC or Mac game code that needs to be ported to
mobile is to simply wrap the code with a GL library wrapper such as NanoGL . I love this library
because it allows you to keep your engine code intact (and I mean zero changes to the
original code). Then, by adding tiny wrappers, you can add support for I/O events such as
screen touch, keyboard, and so on.
NanoGL is truly a life saver, and as a matter of fact, it was written to handle heavy-duty game
engines such as Quake I and Quake II. As you will see in the later chapters of this topic, you
can get these engines running on your phone in no time with zero changes to the original
engine code—all thanks to NanoGL . Sound too good to be true? It probably is. NanoGL has
some of the caveats of the previous section. NanoGL cannot handle display lists or server
state ( glPushAttrib / glPopAttrib ). Besides these caveats, NanoGL should be able to handle
any OpenGL engine you throw at it.
OpenGL ES Compatibility
Android supports several versions of the OpenGL ES API such as:
OpenGL ES 1.0/1.1: Supported by Android 1.0 and higher.
OpenGL ES 2.0: Supported by Android 2.2 (API level 8) and higher.
OpenGL ES 3.0: Supported by Android 4.3 (API level 18) and higher.
OpenGL ES 3.1: Supported by Android 5.0 (API level 21) and higher.
In this chapter, we focus only on the new version 3.1.
 
Search WWH ::




Custom Search