Pro OpenGL ES for iOS
CHAPTER 4: Turning On the Lights (^97) Figure 4-3. Simulated lighting from below (left) and a higher polygon count to simulate s ...
98 CHAPTER 4: Turning On the Lights^ Listing 4-1. Initializing the lights -(void)initLighting { GLfloat diffuse[]={0.0,1.0,0.0,1 ...
CHAPTER 4: Turning On the Lights (^99) What is a vertex normal? Face normals are normalized vectors that are orthogonal (perpend ...
100 CHAPTER 4: Turning On the Lights^ // Color data GLubyte *cPtr = m_ColorData = (GLubyte*)malloc(sizeof(GLubyte) * 4 * ((m_Sli ...
CHAPTER 4: Turning On the Lights (^101) // Get x-y-z for the first vertex of stack. vPtr[0] = m_ScalecosPhi0 cosTheta; vPtr[1] ...
102 CHAPTER 4: Turning On the Lights^ What’s happening here: In line 1, the normal array is allocated with one three-component ...
CHAPTER 4: Turning On the Lights (^103) same normal, you can dump the normal array and use glNormal3f() instead, saving a little ...
104 CHAPTER 4: Turning On the Lights^ Figure 4-6. ‘‘Stacked’’ triangle pairs In Strip 0, Triangle 1 will be drawn using vertices ...
CHAPTER 4: Turning On the Lights (^105) Figure 4-7. From left to right, smooth shading a sphere with 20 stacks and 20 slices, fl ...
106 CHAPTER 4: Turning On the Lights^ GLfloat halfcyan[]={0.0,.5,.5,1.0}; //Lights go here. glLightfv(SS_SUNLIGHT,GL_POSITION,po ...
CHAPTER 4: Turning On the Lights (^107) Figure 4-8. Without green material defined (left) and with it defined (right) Let’s do o ...
108 CHAPTER 4: Turning On the Lights^ Note The first value to glMaterial* must always be GL_FRONT_AND_BACK. In normal OpenGL, yo ...
CHAPTER 4: Turning On the Lights (^109) Ambient Lighting It’s time for some fun with the ambient lighting. Add the following lin ...
110 CHAPTER 4: Turning On the Lights^ The default value is a dim gray formed by a color with red=.2, green=.2, and blue=.2. This ...
CHAPTER 4: Turning On the Lights (^111) glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, yellow); Because the yellow is at full inte ...
112 CHAPTER 4: Turning On the Lights^ Attenuation In the real world, of course, light decreases the further an object is from th ...
CHAPTER 4: Turning On the Lights (^113) Figure 4-12. The light’s x distance is 10 (left) and 50 (right), with a constant attenua ...
114 CHAPTER 4: Turning On the Lights^ GLfloat direction[]={1.0,0.0,0.0}; glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, direction); Fig ...
CHAPTER 4: Turning On the Lights (^115) Name Purpose GL_SPOT_EXPONENT Specifies the rate of falloff from the center of a spotlig ...
116 CHAPTER 4: Turning On the Lights^ Figure 4-14. For a perfectly diffuse surface, the reflected intensity of an incoming beam ...
«
1
2
3
4
5
6
7
8
9
10
»
Free download pdf