Nrtesn Nyarlahotep
02-28-2008, 02:01 AM
Hi!
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);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glutSolidSphere(1,50,50);
glDisable(GL_TEXTURE_2D);
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! :)
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);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_OBJECT_LINEAR);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glutSolidSphere(1,50,50);
glDisable(GL_TEXTURE_2D);
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! :)