Sphere with texture

Started by Daslee, March 12, 2013, 13:24:59

Previous topic - Next topic

Daslee

Hello. How I can apply texture to sphere? For example this: http://www.shareaec.com/images/medium/16079.jpg
I know only how to draw it with color :D :

glColor3f(1f, 1f, 1f);
Sphere s = new Sphere();
s.draw(5, 25, 25);

quew8

The technique I think you want is called uv mapping. It would take a long time to explain, look it up.

Daslee

Quote from: quew8 on March 12, 2013, 16:55:54
The technique I think you want is called uv mapping. It would take a long time to explain, look it up.

Yes, that's what I wanted, but I found another technique.  :P

Sphere sphere = new Sphere();
sphere.setDrawStyle(GLU.GLU_FILL);
sphere.setTextureFlag(true);
sphere.setNormals(GLU.GLU_SMOOTH);
sphereId = glGenLists(1);
glNewList(sphereId, GL_COMPILE);
eightBall.bind();
sphere.draw(2.3f, 25, 25);
glEndList();


And now when I need to render it:
glCallList(sphereId);