Pro OpenGL ES for iOS

(singke) #1

CHAPTER 10: OpenGL ES 2, Shaders, and... (^325)
„ In line 1 allocate an array of structures to carry each of the
components. Here the structure is defined in Planet.h :
struct VAOInterleaved
{
GLfloat xyz[NUM_XYZ_ELS];
GLfloat nxyz[NUM_NXYZ_ELS];
GLfloat rgba[NUM_RGBA_ELS];
GLfloat st[NUM_ST_ELS];
};
„ Lines 2ff scan through all the data and copy it to the interleaved array.
„ Down in the next method, the VAO is created. Much like the earlier
example for the cubes, the only new elements are the addition of the
texture coordinates and the RGBA color data to the mix.
Now with that out of the way, check the results in Figure 10-3.
Figure 10-3. Illuminating the darkness one texel at a time
But What About Specular Reflections?
Just as any other shiny thing (and the earth is shiny in the blue parts), you might expect
to see some sort of reflections of the sun in the water. Well, you’d be right. Figure 10-4
shows a real image of the earth, and right in the middle is the reflection of the sun. Let’s
try it on our own earth.

Free download pdf