Pro OpenGL ES for iOS

(singke) #1

CHAPTER 8: Putting It All Together (^267)
glPushMatrix();
glTranslatef(-m_Eyeposition.x,-m_Eyeposition.y,-m_Eyeposition.z); //1
glLightfv(SS_SUNLIGHT,GL_POSITION,sunPos);
glEnable(SS_SUNLIGHT);
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, paleYellow);
[self executePlanet:m_Sun sx:&sun_sx sy:&sun_sy sz:&sun_sz //2
screenRadius:&sun_sr render:FALSE];
glMaterialfv(GL_FRONT_AND_BACK, GL_EMISSION, black);
glPopMatrix();
if((m_LensFlare!=NULL) && (sun_sz>0)) //3
{
float sunWidth=75; //4
sunWidth*=(sun_sr/5.0);
[[OpenGLCreateTexture getObject]renderTextureInRect: //5
CGRectMake(sun_sx-sunWidth/2.0, sun_sy-sunWidth/2.0,sunWidth,sunWidth)
name:m_FlareSource.name depth:-10 r:1.0 g:1.0 b:1.0 a:1.0];
}
glEnable(SS_FILLLIGHT2);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glTranslatef(-m_Eyeposition.x,-m_Eyeposition.y,-m_Eyeposition.z); //6
glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, cyan);
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, white);
[self executePlanet:m_Earth sx:&earth_sx sy:&earth_sy sz:&earth_sz //7
screenRadius:&earth_sr render:TRUE];
glPopMatrix();
if((m_LensFlare!=NULL) && (sun_sz>0)) //8
{
float scale=1.0;
CGRect frame = [[UIScreen mainScreen] bounds];
float delX=frame.size.width/2.0-sun_sx;
float delY=frame.size.height/2.0-sun_sy;
float grazeDist=earth_sr+sun_sr;
float percentVisible=1.0;
float vanishDist=earth_sr-sun_sr;

Free download pdf