LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: Daslee on March 12, 2013, 13:24:59

Title: Sphere with texture
Post by: Daslee on March 12, 2013, 13:24:59
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);
Title: Re: Sphere with texture
Post by: 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.
Title: Re: Sphere with texture
Post by: Daslee on March 12, 2013, 18:49:16
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);