OpenGL context dimention to OF dimention

This is from the OF wiki :
" Typically, the coordinates of OpenGL contexts go from -1 to 1 on the x, y, and z axis. But openFrameworks is setup for 2-dimensional drawing - its coordinates are changed to a range of 0 to the screen width in the x-axis and 0 to the screen height on the y-axis."

I found a OpenGL tutorial which is based on the -1 to 1 scale with many complected math. I tried to scale the geometry up in OF using glScalef and glTranslatef. but some maths for shadow effect become invalid. Is there a safe way to convert between the two context dimension?

I’m not sure if this is what you are after, but if you wan’t to jump “out of” OF coordinates
into normal gl you can simply push a projection matrix and setup perspective with either
the glu helper function or load your own matrix onto the stack.

glMatrixMode( GL_PROJECTION );
glPushMatrix( );
glMatrixMode( GL_MODELVIEW );

… do your thing here…

glMatrixMode( GL_PROJECTION );
glPopMatrix( );
glMatrixMode( GL_MODELVIEW );

… you are back in OF mode.

gluPerspective is a helper function to setup the projection, google it for correct params.
Hope this helps.

  • Edvin