Unifying the OpenGL 3 core profile and OpenGL ES 2
Let's implement a thin abstraction layer on top of OpenGL 3 and OpenGL ES 2, to make our high-level code unaware of the particular GL version that our application runs on. This means that our game code can be completely unaware whether it runs on a mobile or a desktop version of OpenGL. Take a look at the following diagram:
The part that we are going to implement in this chapter is within the High-level API rectangle.
Getting ready
In Chapter 4, Organizing a Virtual Filesystem, we created an example 3_AsyncTexture
, where we learned how to initialize OpenGL ES 2 on Android using Java. Now we use GLView.java
from that example to initialize a rendering context on Android. No EGL from Android NDK is involved, so our examples will run on Android 2.1 and higher.
How to do it…
In the previous recipe, we mentioned the
sLGLAPI
struct. It contains pointers to OpenGL functions that we load at startup dynamically. The declaration can be found inLGLAPI.h...