Im having a problem using the lwjgl library (opengl).
Whem im trying to texture a sphere i get some strange behaviour.
The texture seems to move backwards around the sphere sometimes.
This happens when the rotation angle < 90 or > 270, but i cant find any reason why.
The texture is 1024 x 512 pixels.
The left part of the sphere is rotating to the right like it should, but the right part seems to wrap around it, moving to the left.
Drawing:
GL11.glClear( GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT );
if(text != null){ text.Bind(); }
GL11.glPushMatrix();
GL11.glTranslatef(231,223,-300);
GL11.glRotatef(90,1,0,0);
GL11.glRotatef(rotate, 0,0,1);
GL11.glColor4f(1,1,1,1);
Sphere s = new Sphere();
s.setDrawStyle(GLU.GLU_FILL);
s.setNormals(GLU.GLU_SMOOTH);
s.setOrientation(GLU.GLU_OUTSIDE);
if(text != null){ s.setTextureFlag(true); }
s.draw(200, 50, 50);
GL11.glPopMatrix();
Init:
protected void initGL()
{
GL11.glViewport(0, 0, 463, 446); // Reset The Current Viewport And Perspective Transformation
GL11.glMatrixMode(GL11.GL_PROJECTION); // Select The Projection Matrix
GL11.glLoadIdentity(); // Reset The Projection Matrix
GLU.gluPerspective(45, 463 / 446, -1000, 1000); // Calculate The Aspect Ratio Of The Window
GL11.glClearColor( 0.0f, 0.0f, 0.0f, 1.0f );
GL11.glClearDepth( 1.0f );
GL11.glDepthFunc( GL11.GL_ALWAYS );
GL11.glHint( GL11.GL_PERSPECTIVE_CORRECTION_HINT,GL11.GL_NICEST );
GL11.glHint( GL11.GL_LINE_SMOOTH_HINT, GL11.GL_DONT_CARE );
GL11.glEnable( GL11.GL_TEXTURE_2D );
GL11.glLoadIdentity();
GL11.glOrtho(0, 463, 446, 0, -1000, 0);
GL11.glDisable(GL11.GL_DEPTH_TEST);
GL11.glMatrixMode(GL11.GL_MODELVIEW);
GL11.glLoadIdentity();
}