To Apply shading to an object. Let's say earth (which was textured using an image). So how to apply smooth shading to that? What are the steps I need to write? Using which functions? Thank you.
Code
void drawScene()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glBindTexture(GL_TEXTURE_2D, textureOfSun);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glEnable(GL_TEXTURE_2D);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glPushMatrix(); // Push matrices
// Draw Sun
gluQuadricTexture(quadricSun,1);
gluSphere(quadricSun,2,20,20);
glPopMatrix();
//Draw Earth
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textureOfEarth);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
//Rotation around Sun
//Revolve of Earth
glPopMatrix();
gluQuadricTexture(quadricEarth,1);
gluSphere(quadricEarth,0.75,20,20);
glutSwapBuffers();
}
This is the rendering part,
void initRendering()
{
glEnable(GL_DEPTH_TEST);
glEnable(GL_NORMALIZE);
glEnable(GL_COLOR_MATERIAL);
quadricSun = gluNewQuadric();
quadricEarth = gluNewQuadric();
textureOfSun = LoadTexture(location1);
textureOfEarth = LoadTexture(location2); /* location1 and 2 says the locations of images */
}