This is how a normal block should rotate, right?
Code:
xx
xx
becomes
x
xx
x
but mine becomes
instead.
This is the code
Code:
void display()
{float xmov = 3.0f;
float ymov = 3.0f;
float anrot = 0.0f;
float yrot = 0.0f;
float xrot = 0.0f;
glClear(GL_COLOR_BUFFER_BIT);
glPushMatrix();
glScalef(0.2f, 0.2f, 0.0f);
glTranslatef(xmov, ymov, 0.0f);
glRotatef(anrot, xrot, yrot, 1.0f);
glColor3f(0.5f, 0.5f, 1.0f);
glBegin(GL_QUADS);
glVertex2f(-0.1f, -0.1f);
glVertex2f(-0.1f, 0.0f);
glVertex2f(0.0f, 0.0f);
glVertex2f(0.0f, -0.1f);
glEnd();
glBegin(GL_QUADS);
glVertex2f(-0.1f, 0.0f);
glVertex2f(-0.1f, 0.1f);
glVertex2f(0.0f, 0.1f);
glVertex2f(0.0f, 0.0f);
glEnd();
glBegin(GL_QUADS);
glVertex2f(0.0f, 0.0f);
glVertex2f(0.0f, 0.2f);
glVertex2f(0.1f, 0.2f);
glVertex2f(0.1f, 0.0f);
glEnd();
glPopMatrix();
glFlush();
}
void idle()
{ if (xmov < 0.0f)
{xmov = 5.0f;}
if (ymov < 0.0f)
{ymov = 5.0f;}
}
LRESULT OpenGL::WndProc(HWND hwnd, UINT msg,
WPARAM wParam, LPARAM lParam)
{
switch(msg)
{
case WM_ACTIVATE :
{
active = HIWORD(wParam) ? false : true;
return 0;
}
case WM_CLOSE :
{
PostQuitMessage(0);
return 0;
}
case WM_SIZE :
{
width = LOWORD(lParam);
height = HIWORD(lParam);
if (resize)
resize(LOWORD(lParam), HIWORD(lParam));
return 0;
}
case WM_KEYDOWN :
if (wParam == VK_RIGHT)
{xmov += 0.1f;}
if (wParam == VK_LEFT)
{xmov -= 0.1f;}
if (wParam == VK_UP)
{ymov += 0.1f;}
if (wParam == VK_DOWN)
{ymov -= 0.1f;}
if (wParam == VK_SPACE)
{anrot += 180.0f;
xrot += 45.0f;
yrot += 45.0f;}
}
return DefWindowProc(hwnd, msg, wParam, lParam);
}
I don't think you need anymore of the code. If you need anymore, please tell me.
I know this seems stupid to belong in Game Programming... >.<
Thanks in advance!