Skip to main content
GameDev.net gamedev.net
🔒 Locked

Display List problem

Started by JDev Aug 14, 2006 at 6:54 PM 2 replies 2.9k views
Original Post
JDev
JDev
Hi, I'm having trouble getting display lists to work in my game. I am loading .obj models from diffrent files and "trying" to put them in display lists to make them render faster. They render just fine without using display list, but I see nothing that is defined in a display list. Here is the meat of my code, any suggestions would be greatly appreciated. JModelObj(char* objFileName, char* mtlFileName) { loadMTLFile(mtlFileName); loadOBJfile(objFileName); displayListID = glGenLists(1); cout << "\nDisplay list: " << displayListID; glNewList( displayListID, GL_COMPILE ); draw(); glEndList(); } void JModelObj::drawDL() { glPushMatrix(); glColor3f(1.0, 0.0, 0.0); glCallList(displayListID); glPopMatrix(); } void JModelObj::draw() { JVertex *vertIt, *normIt; JTexCoor *texIt; int curMatIndex=-99; int tempIndex=0; faceVec::iterator faceIt; glColor3d( 0.0, 1.0, 0.0); glPushMatrix(); glBegin(GL_TRIANGLES); for( faceIt=faces.begin(); faceIt!=faces.end(); faceIt++) { vertIt = vertexVec.at(*faceIt); //cout << (*faceIt) << " "; faceIt++; texIt = textureVec.at(*faceIt); //cout << (*faceIt) << " "; faceIt++; normIt = normalVec.at(*faceIt); //cout << (*faceIt) << "\n"; faceIt++; tempIndex = (*faceIt); if( curMatIndex != tempIndex ) { curMatIndex = tempIndex; glEnd(); //matVec.at(curMatIndex)->setCurrentMaterial(); glBegin(GL_TRIANGLES); } //glTexCoord2f(texIt->getTexX(), texIt->getTexY()); glNormal3f(normIt->getPointX(), normIt->getPointY(), normIt->getPointZ()); glVertex3f(vertIt->getPointX(), vertIt->getPointY(), vertIt->getPointZ()); //cout << "P:" <getPointX()<<"/"<getPointY()<<"/"<getPointZ()<<"\n"; } glEnd(); glPopMatrix(); }
Digitalfragment
Digitalfragment
Not sure, but i can see a few problems:


void JModelObj::drawDL()
{
glPushMatrix();
glColor3f(1.0, 0.0, 0.0);
glCallList(displayListID);
glPopMatrix();
}

glColor3f isnt going to do anything, because you have a call to glColor inside your display list which will override it. Also, in your display list you are calling glPushMatrix and glPopMatrix despite not actually doing any matrix transformations.

Run through a debugger and make sure displayListID is actually being created. use glError() during your code to ensure that GL isnt reporting any errors.
JDev
JDev
I get two unique id's everytime, but still no models. I do notice that the game runs faster, but I don't see anything. I've even turned lighting on and off an neigther reveals anything....*shrug*....?
Rasmadrak
Rasmadrak
When are you creating the display list?

Try putting it after graphics inits and texture loading etc... does that help?
"Game Maker For Life, probably never professional thou." =)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.