CODE SNIPPETS - full code at: https://github.com/Jevi/Asteroids/tree/master/src/org/cstutorials
This is how i render the ship object ( which is compromised of 4 lines loaded into a FloatBuffer ( im using LWJGL btw ) that FloatBuffer is loaded in to memory and I draw from that allocated memory. The random GL_POINT is to see where (x,y) currently is.
@Override
public void render(Graphics g)
{
glLoadIdentity();
glPushMatrix();
glBegin(GL_POINTS);
glVertex2f(x, y);
glEnd();
g.rotate(x, y, angle);
g.drawLines();
glPopMatrix();
}
This is my drawLines() implementation, the variables seen inside are handled by a gameObjectManager which is not in these snippets ( no need )
public void drawLines()
{
glEnableClientState(GL_VERTEX_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, currentVertexHandle);
glVertexPointer(numCoordinates, GL_FLOAT, 0, 0L);
glDrawArrays(GL_LINES, 0, numPairVertices);
glBindBuffer(GL_ARRAY_BUFFER, 0);
glDisableClientState(GL_VERTEX_ARRAY);
}
Finally here is my rotatation implementation, it use to work fine when I used immediate mode rendering but now that I have VBOs it does not work the same
public void rotate(float x, float y, float angle)
{
glTranslatef(x, y, 0);
glRotatef(angle, 0, 0, 1);
glTranslatef(-x, -y, 0);
}






