Drawing context




Before your redraw function is called,  some OpenGL setup is done in a method called draw_mode_setup().  That code is as follows.
 

void Scene::draw_mode_setup(int drawMode)
{
if ( drawMode & MODE_RAYTRACE ) {
setDrawMode( drawMode, g_rayfilename );
}
else {
setDrawMode( drawMode, NULL );
}

GLfloat light_position[] = { 10.0f, 10.0f, 10.0f, 0.0f };

GLfloat mat_ambient[4];
GLfloat mat_diffuse[4];
GLfloat mat_specular[4];
GLfloat mat_shininess;

mat_ambient[0] = mat_ambient[1] = mat_ambient[2] = 0.5;
mat_ambient[3] = 1.0;
mat_diffuse[0] = mat_diffuse[1] = mat_diffuse[2] = 0.5;
mat_diffuse[3] = 1.0;
mat_specular[0] = mat_specular[1] = mat_specular[2] = mat_specular[3] = 1.0;
mat_shininess = 100.0;

glMatrixMode( GL_MODELVIEW );
glLoadIdentity();

glEnable( GL_DEPTH_TEST );

if ( drawMode & MODE_NORMAL )
{
/* initialization for "normal" mode. */

glShadeModel( GL_SMOOTH );
glMaterialfv( GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, mat_ambient );
glMaterialfv( GL_FRONT_AND_BACK, GL_SPECULAR, mat_specular );
glMaterialfv( GL_FRONT_AND_BACK, GL_SHININESS, &mat_shininess );
glLightfv( GL_LIGHT0, GL_POSITION, light_position );

glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
glEnable( GL_NORMALIZE );

glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE );
glPolygonMode( GL_FRONT, GL_FILL );
glCullFace( GL_BACK );
glEnable( GL_CULL_FACE );
}

if ( drawMode & MODE_WIREFRAME )
{
/* initialization for "wireframe" mode. */

glDisable( GL_LIGHTING );
glDisable( GL_NORMALIZE );

glPolygonMode( GL_FRONT_AND_BACK, GL_LINE );

glColor3f( 0.5, 0.5, 0.5 );
}

if ( drawMode & MODE_FLATSHADE )
{
/* initialization for "flat shaded" mode. */

glDisable( GL_LIGHTING );
glDisable( GL_NORMALIZE );

glPolygonMode( GL_FRONT_AND_BACK, GL_FILL );

glColor3f( 0.5, 0.5, 0.5 );
}
}



The redraw function in your model is called from the modeler framework.  The caller is CGLView::draw.  CGLView is a class derived from the FLTK class Fl_Gl_Window.  The draw function is:
void CGLView::draw()
{
if(!valid())
{

m_nWindowWidth=w();
m_nWindowHeight=h();

m_bSizeChange=true;

glMatrixMode( GL_PROJECTION );
glLoadIdentity();

gluPerspective( 30.0, (double)m_nWindowWidth/m_nWindowHeight, 1.0, 100.0 );
glViewport( 0, 0, m_nWindowWidth, m_nWindowHeight );
glEnable(GL_DEPTH_TEST);

glClearColor(0.0f, 0.0f, 0.0f, 0.0);

int drawMode=m_pUI->getDrawMode();
m_pScene->draw_mode_setup(drawMode);
glTranslated(0,0,-20);

glGetDoublev(GL_MODELVIEW_MATRIX, (double*)m_pScene->model);

}

glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );

// get drawMode and drawQuality from UI
int drawMode=m_pUI->getDrawMode();
if (m_pScene)
m_pScene->redraw(drawMode);

}