This is what I’m trying to do: Put textures on a sphere so it looks nice. I’ve drawn some nice eyes I want to try out
The closest I’ve come to a solution is this implementation of shpere-mapping (textureId is loaded with a texture):
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, textureId);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
It looks nice but since it’s sphere-mapped the textures doesn’t rotate along with the sphere. I admit I’m new to OpenGl but I realise it’s not sphere-mapping I want.
However sphere-mapping was the most related concept I could google for and I hoped I could work from there.
I’ve looked up those functions but it doesn’t look like they can be used to do what I want, or am I missing something?
I’m just wondering if there is a nice way to put textures onto a sphere? The only other way I can think of is doing something cool with GLSL, but I enjoy simple solutions when they exist.
Any help would be very aprichiated. Thanks!
Actually, you don’t need to generate texture coords since you’re using glutSolidSphere. The glutSolidSphere function already provides correct texture coordinates for the sphere.
Thank you for your reply, but you don’t mean gluSphere? I searched a little more and the gluSphere have an additional argument to turn on textures.
Or does GlutSolidSphere have texture-coordniates as well? How are they positioned? I couldn’t find anything about it here on this site.
If anyone’s interested it worked with the textures on gluSphere, but I had to draw the eye like a world map where the poles cover almost the entire top and bottom. The pupil had to be a thine line at the bottom and so on.
The code to implement it looks like this:
GLUquadric *qobj = gluNewQuadric();
March 1, 2008, 10:23am
You asked about glutSolidSphere, not gluSphere. This are different functions from different libraries. AFAIK, glutSolidSphere automatically supplies texture coordinates; just as PsosperLOADED said.
If you need a special kind of mapping, try generating the sphere yourself. Or model it with a 3d modeller.