Hello Guest

LWJGL 2 rotating with rotatef rotates all sprites in direction.

  • 0 Replies
  • 3610 Views
Hello,

Recently, I've been getting into LWJGL, so I am very beginner level at LWJGL and OpenGL, so please pardon me. I am trying to make stars the rotate (or a rotation system, of course), and I am having trouble with the rotation. On the first sprite, it rotates in the counter-clockwise direction, but in the second sprite, it does the same when it needs to rotate in the clockwise direction. This happens for all sprites I am drawing on screen.

Here is my code:

Code: [Select]
GL11.glPushMatrix();
GL11.glTranslatef(0.0f, 0.0f, -300f); // Sprite 1
GL11.glRotatef(i+=0.5f, 0.0f, 0.0f, 1.0f );
drawStar2(0, 0, 0);
GL11.glLoadIdentity();
GL11.glPopMatrix();

GL11.glLoadIdentity();

GL11.glPushMatrix(); // Sprite 2
GL11.glTranslatef(0.0f, 50.0f, -300f);
GL11.glRotatef(i-=0.5f, 0.0f, 0.0f, 1.0f);
drawStar0(0, 0, 0);
GL11.glLoadIdentity();
GL11.glPopMatrix();

GL11.glPushMatrix();
GL11.glTranslatef(0.0f, 50.0f, -300f);
GL11.glRotatef(i+=0.5f, 0.0f, 0.0f, 1.0f);
drawTitle(0, 0, 0);
GL11.glLoadIdentity();
GL11.glPopMatrix();

Thank you for anyone's help,

Pale-Gray