How reshape function should look like for 2D game?
void SystemClass::Reshape( int w, int h ) // ignore system class
{
glViewport ( 0, 0, w, h );
glMatrixMode ( GL_PROJECTION );
glLoadIdentity ( );
PrepareScene();
if ( h==0 ) // Calculate The Aspect Ratio Of The Window
gluOrtho2D ( 0 , float(w) , 0 , float(h) );
else
gluOrtho2D ( 0 , float(w) , 0 , float(h) );
glMatrixMode ( GL_MODELVIEW ); // Select The Model View Matrix
glLoadIdentity ( ); // Reset The Model View Matrix
PrepareScene();
}
PrepareScene
void PrepareScene()
{
glClear ( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ) ;
glLoadIdentity ();
gluOrtho2D ( 0 , 800 , 0 , 600 ) ;
glColor3f ( 1.0 , 1.0 , 1.0 ) ;
}