Well I am trying to learn openGL and want to make a triangle move one unit (0.1) everytime I press one of the keyboard arrows. However i want the triangle to turn first pointing the direction where i will move one unit. So if my triangle is pointing up and I press right the it should point right first and then move one unit in the x axis. I have implemented the code to move the object one unit in any direction, however I can not get it to turn pointing to the direction it is going. The initial position of the Triangle is pointing up.
#define LENGTH 0.05
float posX = -0.5, posY = -0.5, posZ = 0;
float inX = 0.0 ,inY = 0.0 ,inZ = 0.0; // what values????
void rect(){
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glPushMatrix();
glTranslatef(posX,posY,posZ);
glRotatef(rotate, inX, inY, inZ);
glBegin(GL_TRIANGLES);
glColor3f(0.0, 0.0, 1.0);
glVertex2f(-LENGTH,-LENGTH);
glVertex2f(LENGTH-LENGTH, LENGTH);
glVertex2f(LENGTH, -LENGTH);
glEnd();
glPopMatrix();
}