Loading a Cube Map into OpenGL

In the accompanying online resources for this chapter, you’ll find the example cube map separated into six separate textures in the /res/drawable-nodpi/ folder, one for each face of the cube. Let’s add a new method to our TextureHelper class to load these textures into an OpenGL cube map. We’ll call this method loadCubeMap, and we’ll start off with the following code:

Skybox/src/com/particles/android/util/TextureHelper.java
 
public​ ​static​ ​int​ loadCubeMap(​Context​ context, ​int​​[]​ cubeResources) {
 
final​ ​int​​[]​ textureObjectIds = ​new​ ​int​[1];
 
glGenTextures(1, textureObjectIds, 0);
 
 
if​ (textureObjectIds[0] == 0) {
 
if​ (LoggerConfig.ON) {
 
Log.w(TAG, ​"Could not generate a new OpenGL texture ...

Get OpenGL ES 2 for Android now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.