With following code I am getting my triangle in top right corner of the graph, which tells me that the 0,0 is in the center of the window. What should I do to bring it in the corner of the window, i.e. bottom left?
#include <GL/glut.h>
void displayCube()
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0,1.0,1.0);
glBegin(GL_TRIANGLES);
glVertex3f(0, 0, 0);
glVertex3f(0.5, 0, 0);
glVertex3f(0.25, 0.25, 0);
glEnd();
glFlush();
}
int main(int argc, char *argv[]){
glutInit(&argc,argv);
glutInitDisplayMode(GLUT_SINGLE);
glutInitWindowSize(500,500);
glutInitWindowPosition(0,0);
glutCreateWindow("Cube");
glutDisplayFunc(displayCube);
glutMainLoop();
return 0;
}
OpenGL uses a set of matrix transformation to move from original model space to screen/window space.
In you example, there is default identity projection so you are 'moving' in box -1 to 1 in each direction.
point (0.0, 0.0, 0.0)
is in the centre. (-1, 0, 0)
is on the left side, (1, 0, 0)
is on the right, (0, 1, 0)
is top.
try to figure out the rest :)