Archived

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

Need explanation about textures and polygons...

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I have been experimenting a little with texturing quads in a display list (as explained in lesson 12) and showing it multiple times on the screen... to sort of make a tiled background picture for my program... I am really confused as to why I get such a heavy drop in fps (goes from around 1200 to 400 when I draw the quad 12 to times so it covers the entire visible area) the texture is a TGA image 256x256 pixels (257kb) and I run in 1024x768 on a Geforce FX 5600. U might think, what is he complaining about 400fps? but if I for example try to render it 192 times I drop to 130 fps. With that tendency I foresee my screen going really laggy when I really start drawing stuff... This is the code for the display list... maybe some of you can see if there´s something wrong with it... GLvoid BuildLists() { background=glGenLists(1); glNewList(background,GL_COMPILE); int tiled=1; int scale=256; glColor3f(1.0f,1.0f,1.0f); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, textures[1].texID); glBegin(GL_QUADS); glTexCoord2f(tiled*0.0f,tiled*1.0f); glVertex3f(scale*0.0f,scale*1.0f,-1.0f); glTexCoord2f(tiled*1.0f,tiled*1.0f); glVertex3f(scale*1.0f,scale*1.0f,-1.0f); glTexCoord2f(tiled*1.0f,tiled*0.0f); glVertex3f(scale*1.0f,scale*0.0f,-1.0f); glTexCoord2f(tiled*0.0f,tiled*0.0f); glVertex3f(scale*0.0f,scale*0.0f,-1.0f); glEnd(); glDisable(GL_TEXTURE_2D); glEndList(); } -------------------------------------------------------------- What''s the problem? I don''t got a problem, I got fuckin'' problems! plurum! -Tim Roth, Four Rooms

Share this post


Link to post
Share on other sites
Hello!

If you use this display list often you're calling some GL commands too often. For each display list call you enable 2D texturing, binding a texture and disable 2D texturing. You also call glBegin(), glColor() and glEnd() every time you execute your display list.

Try the compiling the display list without these command if you are using this list very often and before you call it, enable 2D texturing, bind your texture, call glBegin() and glColor(). After calling your list disable 2D texturing and call glEnd().


GLvoid BuildLists()
{
background=glGenLists(1);

glNewList(background,GL_COMPILE);

int tiled=1;
int scale=256;
glTexCoord2f(tiled*0.0f,tiled*1.0f); glVertex3f(scale*0.0f,scale*1.0f,-1.0f);
glTexCoord2f(tiled*1.0f,tiled*1.0f); glVertex3f(scale*1.0f,scale*1.0f,-1.0f);
glTexCoord2f(tiled*1.0f,tiled*0.0f); glVertex3f(scale*1.0f,scale*0.0f,-1.0f);
glTexCoord2f(tiled*0.0f,tiled*0.0f); glVertex3f(scale*0.0f,scale*0.0f,-1.0f);
glEndList();
}


// Call your list a couple of times

glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, textures[1].texID);
glBegin(GL_QUADS);
glColor3f(1.0f, 1.0f, 1.0f);

for (i = 0; i < nummer_of_calls; i++)
{
glPushMatrix();
glTranslatef(..,..,..);
glRotatef(..,..,..);
glCallList(background);
glPopMatrix();
}

glEnd();
glDisable(GL_TEXTURE_2D);


With this technique you enable 2D texturing, bind your texture and call glBegin only once. This will push your framerate. But maybe you are faster using vertex pointer rather than using display lists. But I'm not sure.

Hope this will help!

--------------------------------------------------------

"If it looks good, it is good computer graphics"
"If it looks like computer graphics, it is bad computer graphics"

Corrail
corrail@gmx.at
ICQ#59184081

[edited by - Corrail on October 11, 2003 8:00:12 AM]

[edited by - Corrail on October 11, 2003 8:01:14 AM]

Share this post


Link to post
Share on other sites