I have a program to draw 3D graphs of Lat, Long and Altitude. Each trail of points is broken up into segments and each segment has two display lists. One list renders the line as a GL_LINE_STRIP and the other uses gluCylinder to make ‘pipes’. The displaylist that’s used switches from line strip to pipe as the user gets closer. The weird thing is that when the first segment on a trail switches to a pipe the remaining segments change colour! Reverse away and it switches back. Here’s the code for one segment:
m_listIndex0 = glGenLists(2);
m_listIndex1 = m_listIndex0 + 1;
if( m_listIndex0 != 0 ) {
glNewList( m_listIndex0, GL_COMPILE );
glEnable( GL_COLOR_MATERIAL );
glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE);
glColor3fv( m_colour );
GLUquadricObj* quadricObj;
if ( NULL != ( quadricObj = gluNewQuadric() ) )
{
gluQuadricDrawStyle(quadricObj, GLU_FILL);
// set coords
.....
gluCylinder( quadricObj, cylRadius, cylRadius, dist, 6, 2 );
}
glCullFace(GL_BACK);
gluDeleteQuadric( quadricObj );
glDisable( GL_COLOR_MATERIAL );
glEndList();
}
// create a display list for low-res
if( m_listIndex1 != 0 ) {
glNewList( m_listIndex1, GL_COMPILE );
glEnable( GL_COLOR_MATERIAL );
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
glColor3fv( m_colour );
glBegin(GL_LINE_STRIP);
for(int i=0, k=0; i<numpts; ++i, k+=3)
{
glVertex3f( vertArray[k], vertArray[k+1], vertArray[k+2] );
}
glEnd();
glDisable( GL_COLOR_MATERIAL );
glEndList();
}