Game Development Reference
In-Depth Information
So if we put this together we get the following code:
void CGLView::OnDraw(CDC* pDC)
{
GLfloat flt,v[4];
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
//Set the light properties
flt=GetDocument()->m_ambient;
v[0]=flt; v[1]=flt; v[2]=flt; v[3]=1.0f;
glLightfv(GL_LIGHT0, GL_AMBIENT, v);
flt=GetDocument()->m_diffuse;
v[0]=flt; v[1]=flt; v[2]=flt; v[3]=1.0f;
glLightfv(GL_LIGHT0, GL_DIFFUSE, v);
//Set the material properties
flt=GetDocument()->m_emission;
v[0]=flt; v[1]=flt; v[2]=flt; v[3]=1.0f;
glMaterialfv(GL_FRONT, GL_EMISSION, v);
flt=GetDocument()->m_specular;
v[0]=flt; v[1]=flt; v[2]=flt; v[3]=1.0f;
glMaterialfv(GL_FRONT, GL_SPECULAR, v);
flt=GetDocument()->m_shininess;
glMaterialf(GL_FRONT, GL_SHININESS, flt);
GetDocument()->GetColour(v);
glMaterialfv(GL_FRONT, GL_DIFFUSE, v);
glTranslatef(0.0f, 0.0f, -zvalue);
glRotatef(rot[0], 1.0f, 0.0f, 0.0f);
glRotatef(rot[1], 0.0f, 1.0f, 0.0f);
glRotatef(rot[2], 0.0f, 0.0f, 1.0f);
GetDocument()->GetPosition(v);
glLightfv(GL_LIGHT0, GL_POSITION, v);
DrawSphere(48,32,15.0);
SwapBuffers(m_hDC);
}
Search Nedrilad ::




Custom Search