Here’s a quick tutorial on how to texture map the quadric sphere drawn by the gluSphere function. Learnt this while finishing my assignment for the Computer Graphics subject.
GLUquadricObj *qObj = gluNewQuadric(); gluQuadricNormals(qObj, GLU_SMOOTH); gluQuadricTexture(qObj, GL_TRUE); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texID); // texID is the texture ID of a // previously generated texture gluSphere(qObj, 1.0f, 24, 24);
In the above code we generate a quadric object, and specify the type of normals for the quadric object, which in this case is set to smooth shading with the GLU_SMOOTH flag. gluQuadricTexture tells OpenGL to generate texture coordinates for the quadric object automatically. Finally, we bind the desired texture and draw the quadric sphere using gluSphere.
Here’s what you would get:
Hope it helps. Good luck!