Hi there,
I've been trying out call lists in openGL, i created them fine and was able to display them fine at first, however, when i started to put them in Push/Pop matrixes I only seem to be able to display one call list (the stickList in the code shown below)? :S I'm assuming this is a rookie error but I cant seem to find what i'm doing wrong, posted the relevant code below:
Code ://My displaylist method i'm using to generate, called in the init() function void generateLists() { //START OF GATE LIST CREATE gateList = glGenLists(1); glNewList(gateList,GL_COMPILE); glPushMatrix(); GLUquadric *quad; quad = gluNewQuadric(); //Make gate straddle origin glTranslatef(-0.5,0,0); //Left Upright glPushMatrix(); glRotatef(-90,1,0,0); gluCylinder(quad, 0.1f, 0.1f, 1.0f, 18, 8); glPopMatrix(); //Crossbeam glPushMatrix(); glRotatef(90,0,1,0); glTranslatef(0,0.925,0); gluCylinder(quad, 0.1f, 0.1f, 1.0f, 18, 8); glPopMatrix(); //Right Upright glPushMatrix(); glRotatef(-90,1,0,0); glTranslatef(1,0,0); gluCylinder(quad, 0.1f, 0.1f, 1.0f, 18, 8); glPopMatrix(); gluDeleteQuadric(quad); glPopMatrix(); glEndList(); //END OF GATE LIST //START OF START/END STICK LIST CREATE stickList = glGenLists(1); glNewList(stickList,GL_COMPILE); glPushMatrix(); quad = gluNewQuadric(); //Make an upwards cylinder glPushMatrix(); glRotatef(-90,1,0,0); gluCylinder(quad, 0.1f, 0.1f, 1.0f, 18, 8); glPopMatrix(); //Make a cone at the top glPushMatrix(); glTranslatef(0,1,0); glRotatef(-90,1,0,0); gluCylinder(quad, 0.1f, 0, 0.2f, 18, 8); glPopMatrix(); gluDeleteQuadric(quad); glPopMatrix(); glEndList(); //END OF START/END STICK LIST //START OF CROQUET BALL LIST CREATE ballList = glGenLists(1); glNewList(ballList,GL_COMPILE); glPushMatrix(); //Translate ball up so the bottom is in contact with playing surface glTranslatef(0,0.25,0); //Generate sphere glutSolidSphere(0.25f, 20, 20); glPopMatrix(); glEndList(); //END OF CROQUET BALL LIST }Code ://Included all my display method as its reasonably short, assuming the call lists is all that may be applicable, but just in case..! void display(void) { //clear window glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPushMatrix(); //Movement glRotatef(angle,0,1,0); glTranslatef(xPos,-2,zPos); //START OF PLAYING FIELD glBegin(GL_QUADS); glColor3f(0.0f,0.5f,0.0f); // Set The Color To Green glVertex3f( 25.0f,0.0f, 50.0f); // Top Right Of The Quad (Bottom) glVertex3f(-25.0f,0.0f, 50.0f); // Top Left Of The Quad (Bottom) glVertex3f(-25.0f,0.0f,-50.0f); // Bottom Left Of The Quad (Bottom) glVertex3f( 25.0f,0.0f,-50.0f); // Bottom Right Of The Quad (Bottom) glEnd(); //END OF PLAYING FIELD //SET UP GATES AND POSTS //Start Post glPushMatrix(); glColor3f(1,1,1); glTranslatef(0,0,44); glCallList(stickList); glPopMatrix(); //GATE 1 glPushMatrix(); glColor3f(1,1,1); glTranslatef(0,0,38); glCallList(gateList); glPopMatrix(); glPopMatrix(); //flush buffers glFlush(); //Swap buffers glutSwapBuffers(); //Updating done here if (buildPower) { distToTravel = distToTravel + 0.001; } }
If theres anything else you need to know just ask, and thanks in advance!
Jack



and thanks again for your help Kelvin.