O'Reilly logo

OpenGL ES 2 for Android by Kevin Brothaler

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required