PDA

View Full Version : Glut textures



laf
04-13-2002, 06:40 AM
How can I bind a texture to a solid glut sphere for example??

jmathies
04-13-2002, 11:39 AM
Originally posted by laf:
How can I bind a texture to a solid glut sphere for example??

From 3.7.6, glut_shapes.c:

void APIENTRY
glutSolidSphere(GLdouble radius, GLint slices, GLint stacks)
{
QUAD_OBJ_INIT();
gluQuadricDrawStyle(quadObj, GLU_FILL);
gluQuadricNormals(quadObj, GLU_SMOOTH);
/* If we ever changed/used the texture or orientation state
of quadObj, we'd need to change it to the defaults here
with gluQuadricTexture and/or gluQuadricOrientation. */
gluSphere(quadObj, radius, slices, stacks);
}

Fromt he docs on gluSphere:

The gluSphere function draws a sphere of the given radius centered around the origin. The sphere is subdivided around the z-axis into slices and along the z-axis into stacks (similar to lines of longitude and latitude).

If the orientation is set to GLU_OUTSIDE (with gluQuadricOrientation), any normals generated point away from the center of the sphere. Otherwise, they point toward the center of the sphere.

If texturing is turned on (with gluQuadricTexture): texture coordinates are generated so that t ranges from 0.0 at z = –radius to 1.0 at z = radius (t increases linearly along longitudinal lines); and s ranges from 0.0 at the positive y-axis, to 0.25 at the positive x-axis, to 0.5 at the positive y-axis, to 0.75 at the positive x-axis, and back to 1.0 at the positive y-axis.

Hope this helps.

Jim

laf
04-14-2002, 02:59 AM
Thanks for your answer. I have already done this way. But my problem is that I have several objects created based on glut (not glu) objects and I rather prefer not to change them all.

Thanks