• ### Popular Now

• 11
• 9
• 10
• 9
• 10

#### Archived

This topic is now archived and is closed to further replies.

# Do models need lighting?

This topic is 5464 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Here''s why I ask: I am writing my first model loader (md2) and want to render the model without the skin (wireframe). I am just trying to view the first frame and have glPolygonMode set as such: glPolygonMode(GL_FRONT, GL_LINE). I have all of the vertices loaded into a display list (i''ve verified that I have valid vertices in my vertex array that I use to generate the display list) and use the same color for all when rendering but I am not seeing anything. Do I need lighting or is it something else? peace and (trance) out Mage

##### Share on other sites
Well, no, I know that I''ve loaded all of the vertex and command data correctly (as I have outputted the arrays to a text file after loading). The problem must be where I''m building the display lists for the frames or how I''ve set up the camera and/or perspective transforms... I''ll post again if I can''t get it figured out. Thanx.

peace and (trance) out

Mage

##### Share on other sites
Are you sure you are rendering the model inside the viewing frustum?

You may have something like this:

gluPerspective( 45, width/height/ 10.0, 100.0 );

but you have done

glTranslatef( 0.0, 0.0, -2.0 );

Look, it is before the near plane! Did you get what I mean?

Check those vertex coodinates, mate!

##### Share on other sites
Just another little something... turn off glCullFace... when loading model formats (such as md3), it''s very easy to end up with HUGE models, and it''s quite possible that your camera is inside it!

Just turn off culling to test... that way even if you are inside it, you''ll see something (the inside of it).

##### Share on other sites
You should read the Red Book 1.1 or a good book on OpenGL.

You CAN''T use vertex arrays in a display list, becouse of the client-server model of the OpenGL. (Yes, that''s why it''s called glEnableClientState()).

You have to decide between using a display list or an array. As far as I''ve seen, the vertex array is slightly faster than the display list, and if you use a boostin'' aproach (like using vertex pools instead of simple vertex arrays), you can get an 40-70% speed boost when rendering big amounts of data. But that''s up to you.

##### Share on other sites
I thought quake series models were backwards - cull out front facing.

##### Share on other sites
OK: I am working all this weekend so I really don''t have time to work on this (although I do have time to browse the gamedev forums...:->) but, I am already reading the redbook and I am not using vertex arrays for rendering, I am using arrays to store the vertexes and then using the indices from the glcommands in the md2 file to build the display list in a loop... anywayz, thanks for all of the suggestions guyz...

peace and (trance) out

Mage

##### Share on other sites
Just use this function

    void Wire()  {    glColor4f(0.5f, 0.5f, 0.5f, 1.0f);    glDisable(GL_BLEND);    glDisable(GL_LINE_SMOOTH);    glDisable(GL_TEXTURE_2D);    glPolygonMode(GL_FRONT, GL_LINE);    glPolygonMode(GL_BACK, GL_LINE);  }

##### Share on other sites
Ok, I'm stumped. The problem must be somewhere in how I'm building/using the display lists as I've checked out my camera and projection stuff by drawing some basic objects and I can see them just fine. So, here's the code where I build the display lists:

      //read in the glcommandsint *commands = new int[header.num_glcmds];file.seekg(header.ofs_glcmds, ios::beg);file.read((char*) commands, header.num_glcmds * sizeof(int));		//build the display listsnumFrames = header.num_frames;firstFrame = glGenLists(numFrames);int *temp2, count;for(i = 0; i < numFrames; ++i){        temp2 = commands;	count = 4; //need to set to 3 for first iteration of inner for loop	glNewList(firstFrame + i, GL_COMPILE);	while(count < header.num_glcmds){		int j = *(temp2++);		if(j < 0){			glBegin(GL_TRIANGLE_FAN);			j = -j; 		}		else			glBegin(GL_TRIANGLE_STRIP);		for(; j > 0; --j, temp2 += 3, count +=3){			glVertex3fv(&verts[temp2[2] + i*header.num_xyz]);		}		++count;		glEnd();	}	glEndList();}
verts is an array of 3*numFrames*header.num_xyz floats and as I noted earlier I have verified that I am loading them and the commands from the .md2 file correctly and successfully. However, when I call glCallList(firstFrame) I am not seeing anything... See any problems?

peace and (trance) out

Mage

[edited by - Mage2k on May 5, 2003 4:10:36 PM]

[edited by - Mage2k on May 5, 2003 4:11:18 PM]