Texture Mapping

Hi,

I am trying to texturemap a sphere. Someone was saying on this forum that this does not work with just automatic texture coordinates as it is more like the texutre is projected onto the visual part of the sphere rather than actually wrapping it around the sphere. Could anyone help with this or give any tipps please??

have u tried texture mapping ur sphere?

I cannot map the texture onto the sphere.
And bind the texture after the image is read.

glGenTextures(1,&texture);
/* make it the current texture */
glBindTexture(GL_TEXTURE_2D,texture);

// ----Set the parameter---- //

glTexImage2D(GL_TEXTURE_2D,0,GL_RGBA,TEX_WIDTH,TEX_HEIGHT,0,GL_RGB,GL_UNSIGNED_BYTE,texImage);

Suppose I have read the texture image and the name is texImage. After that, what should I do?

glPushMatrix();
    glTranslated(-0.25,-0.5,-5.4);
    glutSolidSphere(0.2,20,20);
glPopMatrix();

I have just added the line before the code above:
glEnable(GL_TEXTURE_2D);

It look like that I need to add the coordinate, right? But I don’t know how to add it.

Try this:

glEnable(GL_TEXTURE_2D);

glPushMatrix();
glTranslated(-0.25,-0.5,-5.4);
glBindTexture(GL_TEXTURE_2D, texture);
glutSolidSphere(0.2,20,20);
glPopMatrix();

Where texture is the the texture you have generated.

If it works, but looks iffy, I have a tutorial on my site which works on texturing a sphere without the glutSolidSphere command. My tutorial will allow for you to set the texture coordinates on the sphere.

http://www.cdadc.com/programming