A couple of functions to switch between 2D and 3D projections.
from OpenGL.GL import * def set_projection_2d( ): viewport = glGetIntegerv( GL_VIEWPORT ) glMatrixMode( GL_PROJECTION ) glLoadIdentity( ) gluOrtho2D( 0, viewport[ 2 ], viewport[ 3 ], 0 ) glMatrixMode( GL_MODELVIEW ) glLoadIdentity( ) def set_projection_3d( ): viewport = glGetIntegerv( GL_VIEWPORT ) glMatrixMode( GL_PROJECTION ) glLoadIdentity( ) gluPerspective( 60.0, float( viewport[ 2 ] ) / float( viewport[ 3 ] ), 0.1, 1000.0 ) glMatrixMode( GL_MODELVIEW ) glLoadIdentity( )