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

Adding the Skybox to Our Scene

Now that we have the cube model and shader code written up, let’s add the skybox to our scene. Open up ParticlesRenderer, and add the following members to the top of the class:

Skybox/src/com/particles/android/ParticlesRenderer.java
 
private​ SkyboxShaderProgram skyboxProgram;
 
private​ Skybox skybox;
 
private​ ​int​ skyboxTexture;

At the same time, rename the existing texture member variable from the last chapter to particleTexture. Bring in any missing imports, and then we’ll initialize these new variables in onSurfaceCreated with the following code:

Skybox/src/com/particles/android/ParticlesRenderer.java
 
skyboxProgram = ​new​ SkyboxShaderProgram(context);
 
skybox = ​new​ Skybox();
 
skyboxTexture = TextureHelper.loadCubeMap(context, ...

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