View Full Version : Sphere and texture rotation
furetto3
05-30-2011, 10:12 AM
Hi!
I'm drawing a sphere and cover it with a texture.
That's the problem: I want the texture to rotate with the sphere.
How can I do this?
Iblues76
05-30-2011, 10:32 AM
Well, if you add the texture to the sphere, it would be attach to it.
Bind the texture before drawing the sphere
McLeary
05-30-2011, 11:45 AM
Hi!
I'm drawing a sphere and cover it with a texture.
That's the problem: I want the texture to rotate with the sphere.
How can I do this?
If you're drawing a texture, you must have texture coordinates for your sphere vertices. So, when rotating the sphere, the texture will rotate too, unless you are not setting the texture coordinates correctly.
furetto3
05-31-2011, 05:46 AM
Sorry, but I don't understand...I'm doing something like this:
glPushMatrix();
glEnable(GL_TEXTURE_2D);
glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
glBindTexture(GL_TEXTURE_2D, texture_id[1]);
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_SPHERE_MAP);
glTranslatef(posX, 1.0, posZ);
glutSolidSphere(palla.r, 12, 12);
glDisable(GL_TEXTURE_2D);
glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glPopMatrix();
what kind of sphere vertex I'm suppose to consider?
McLeary
05-31-2011, 05:55 PM
I'm not sure, but I read somewhere that glutSolidSphere didn't generate texture coordinates. Try glutSolidTeapot(), I'm sure that the teapot have texture coordinates.
furetto3
06-01-2011, 12:34 AM
Probably you are right.
But I need to draw a sphere not a teapot.
Anybody can help me, please?
V-man
06-01-2011, 05:37 AM
You can use glu (gluSphere)
or you can use my library (glhCreateSpheref2 and example code is provided in the header).
Or as a fun exercise, create a sphere yourself.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.