The only difference between the first lesson and this one is the drawing function. I'll post only it as you can go and get the first one from here and just replace the drawGLScene function.
/**
* The drawing function. Here we will draw the triangle and the quad.
*/
void drawGLScene()
{
// Clear The Screen And The Depth Buffer
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// Reset The Current Modelview Matrix
glLoadIdentity();
// Move Left 1.5 Units And Into The Screen 6.0
glTranslatef(-1.5f, 0.0f, -6.0f);
// Drawing Using Triangles
glBegin(GL_TRIANGLES);
glVertex3f(0.0f, 1.0f, 0.0f); // Top
glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
// Finished Drawing The Triangle
glEnd();
// Move Right 3 Units
glTranslatef(3.0f, 0.0f, 0.0f);
// Draw A Quad
glBegin(GL_QUADS);
glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left
glVertex3f(1.0f, 1.0f, 0.0f); // Top Right
glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right
glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left
// Done Drawing The Quad
glEnd();
}
Don't forget to change the title of the window to "NeHe's First Polygon Tutorial (D version)". Or to something else if you feel like it.
You can download the code from here.
1 comments:
thank you nice sharing
cep programsymbian programnokia programhtml kodlarıbedava cep oyunlarıcilt bakımı
Post a Comment