// Draw
void display ( void )
{
	int j=0;
	glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
	glLineWidth( GLfloat(lineWidth) );

	if (!useErrors)
	{
		// Bind and setup the shader
		draw->Enable();
		draw["xRange"] = vec2( 330.0f, 843.0f );
		draw["yRange"] = vec2( -0.13f, 2.05f );
		draw["useXYZ"]    = vec3( displayX ? 1.0f : 0.0f, 
								  displayY ? 1.0f : 0.0f, 
								  displayZ ? 1.0f : 0.0f );
			// For each curve, check if it's selected to be display, if so, draw it
			for (uint i=0; i<drawableCurves.Size(); i++)
			{
				// Check if this curve was selected to be drawn
				if ( curveSelection[i]->GetValue() )
				{
					draw["xColor"] = colorArr[j++];
					draw["yColor"] = colorArr[j++];
					draw["zColor"] = colorArr[j++];
					drawableCurves[i]->DrawArrays( GL_LINE_STRIP, 0, 471 );
				}
			}
		draw->Disable();

		// After drawing the curve, draw the axes
		drawAxes->Enable();
			axes->DrawArrays( GL_LINES, 0, 38 );
		drawAxes->Disable();
	}
	else
	{
		// Bind and setup the shader
		draw->Enable();
		draw["xRange"] = vec2( 330.0f, 843.0f );
		draw["yRange"] = vec2( -0.25f, 0.25f );
		draw["useXYZ"]    = vec3( displayX ? 1.0f : 0.0f, 
								  displayY ? 1.0f : 0.0f, 
								  displayZ ? 1.0f : 0.0f );
			// For each curve, check if it's selected to be display, if so, draw it
			for (uint i=0; i<errorCurves.Size(); i++)
			{
				// Check if this curve was selected to be drawn
				if ( curveSelection[i]->GetValue() )
				{
					draw["xColor"] = colorArr[j++];
					draw["yColor"] = colorArr[j++];
					draw["zColor"] = colorArr[j++];
					errorCurves[i]->DrawArrays( GL_LINE_STRIP, 0, 471 );
				}
			}
		draw->Disable();
	}

	// Draw the labels
	for (int i=0; i<10; i++)
		IGLUDraw::DrawColorText( IGLU_FONT_VARIABLE, 
		                         int(textOffsetFactor.X()*labels[i].x), 
								 int(textOffsetFactor.Y()*labels[i].y), 
								 color::Gray80, labels[i].name, textOffsetFactor.X() );
}