• 12
• 12
• 9
• 10
• 13

# Constant scale orthographic projection

This topic is 4263 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm doing a little GUI test, and I want my GUI to stay a constant size in pixels, regardless of the size of the window it's in. The GUI is defined relative to the top-left corner of the window, and I use gluOrtho2d to define the projection like so:
glMatrixMode( GL_PROJECTION );
gluOrtho2D( 0, 600, 0, 600 );

glTranslatef( 0, 600 0 );
glScalef( 1, -1, 1 );

glViewport( 0, 0, 600, 600 );

glMatrixMode( GL_MODELVIEW );


600 is the width and height of the initial window. I'm keeping them constant here as I DONT want the gui elements to scale when the window resizes. i.e. I want the coordinate system to stay the same andbe exactly the same as the integer coordinates I get through from glut's x, y parameters to glutMouseMoveFunc etc. Has anyone done this before, or know what I should be doing?

##### Share on other sites
glViewport(0, 0, window_width, window_height);glMatrixMode(GL_PROJECTION)glLoadIdentity();glOrtho(0, window_width, window_height, 0);

There, origin in the upper left corner, with positive Y-axis downwards.