I created a rect at 0,0,0 with width=1, height=1 and indeed the coordinates areGyroVorbis wrote:That is the equation for rotating something with respect to the origin. You aren't translating your entity before you rotate, are you?
That must be applied to your vertices before any translation.
Also, check to make sure that your local coordinates (since I'm guessing you've decided to store them) are (assuming a rect):
top left - (-0.5, -0.5)
top right - (0.5, -0.5)
bottom left - (-0.5, 0.5)
bottom right - (0.5, 0.5)
AND NOT
top left - (0, 0)
top right - (1, 0)
bottom left - (0, 1)
bottom right - (1, 1)
As for rotating, here's the basic setup of my draw loop:top left - (-0.5, -0.5)
top right - (0.5, -0.5)
bottom left - (-0.5, 0.5)
bottom right - (0.5, 0.5)
glPushMatrix()
glOrtho()
// call draw rectangle function (member function of rect class)
draw rectangles:
1) push matrix
2) glTranslatef(m_rectangle->getPosition().x, m_rectangle->getPosition().y, m_rectangle->getPosition().z);
glRotatef(m_rectangle->getOrientation(), 0,0,1);
glTranslatef(-m_rectangle->getPosition().x, -m_rectangle->getPosition().y, -m_rectangle->getPosition().z);
3) draw quad (rectangle)
4) pop matrix
// now back to main draw loop
// immediately draw this line
glBegin(GL_LINES);
glColor3f(0.0f, 1.0f, 0.0f);
glVertex3f(spriteArray[0].m_rectangle->getWorldVertices()[BOTTOM_LEFT].x,
spriteArray[0].m_rectangle->getWorldVertices()[BOTTOM_LEFT].y,
spriteArray[0].m_rectangle->getWorldVertices()[BOTTOM_LEFT].z);
glVertex3f(800,600,0);
glEnd();
glFlush();
glPopMatrix()
// end draw loop
So to answer your question, the only place I call rotate is inside the drawRect function, and i push/pop the matrix at the beginning/end of the function. So I thought I was handling the translations correctly inside the drawRect function within the push/pop calls, but I could be mistaken?
edit: the only place I call rotate (or translate) is inside the drawRect....