Morning. I’m trying to use glTranslatef still I can’t move my object. I read something about the projection matrix, put some lines but it didnt work. What do I have to do?
#include "GL/freeglut.h"
#include "GL/gl.h"
void Draw(void){
glClear(GL_COLOR_BUFFER_BIT);
glBegin(GL_LINES);
glColor3f(1.0, 1.0, 1.0);
glVertex2f(-1.0f, 0.0f);
glVertex2f(1.0f, 0.0f);
glVertex2f(0.0f, 1.0f);
glVertex2f(0.0f, -1.0f);
glEnd();
glBegin(GL_QUADS);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glVertex2f(-0.25, 0.25);
glVertex2f(-0.75, 0.25);
glVertex2f(-0.75, 0.75);
glVertex2f(-0.25, 0.75);
glTranslatef(-1.0, 0.0, 0.0);
glEnd();
glFlush();
}
void Init(void)
{
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
}
int main(int argc, char** argv)
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutCreateWindow("Translation");
glutDisplayFunc(Draw);
glutIdleFunc(Draw);
Init();
glutMainLoop();
}