Graphics Programs Reference
In-Depth Information
float[] cubeVFA = { // vertex (float) coordinate array
-0.5f,-0.5f,0.5f, 0.5f,-0.5f,0.5f,
0.5f,0.5f,0.5f, -0.5f,0.5f,0.5f,
-0.5f,-0.5f,-0.5f, 0.5f,-0.5f,-0.5f, 0.5f,0.5f,-0.5f, -0.5f,0.5f,-0.5f
};
short[] cubeISA = { // index (short) array
0,4,5, 0,1,5, 5,6,2, 5,1,2,
5,6,7, 5,4,7, 7,6,2, 7,3,2,
7,3,0, 7,4,0, 0,3,2, 0,1,2
};
float[] cubeTFA = { // texture (float) coordinate array
-1,-1,1, 1,-1,1, 1,1,1, -1,1,1,
-1,-1,-1, 1,-1,-1, 1,1,-1, -1,1,-1
};
Loading Images for a Cubemap Texture
Similar to 2D textures ( Listing 5-5 ) , when you generate a texture object for a
cubemap texture, you need to bind its corresponding id to the texture type. For
a
cubemap
texture,
this
is
done
by GLES20.glBindTexture(GLES20.GL_TEXTURE_CUBE_MAP,
_textureId); .
Similarly, to set the texture parameters for using a cubemap texture, the first ar-
gument passed to the GLES20.glTexParameteri method should be
GLES20.GL_TEXTURE_CUBE_MAP .
Because a cubemap texture has six faces, instead of a single call to the
GLUtils.texImage2D method, you need to call this method six times, corres-
ponding to each face. To do so, pass the first argument as a constant ( Listing 5-10 )
specifying the face:
GLES20.GL_TEXTURE_CUBE_MAP_POSITIVE_X
GLES20.GL_TEXTURE_CUBE_MAP_NEGATIVE_X
GLES20.GL_TEXTURE_CUBE_MAP_POSITIVE_Y
Search WWH ::




Custom Search