fortikur
04-22-2004, 08:52 AM
I tried to display a background image 20 times per sec under CBuilder (using timers), but drawing my 400 vertex polygon seems faster than displaying a simple image. I used the following code, which was borrowed from a tutorial:
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glDisable(GL_LIGHTING);
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glDisable(GL_DEPTH_TEST);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
// backgr is a 512x512x24 BMP file
glBindTexture(GL_TEXTURE_2D, backgr);
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2f(0, 0);
glVertex3f(-1, -1, 1);
glTexCoord2f(0, 1);
glVertex3f(-1, 1, 1);
glTexCoord2f(1, 1);
glVertex3f( 1, 1, 1);
glTexCoord2f(1, 0);
glVertex3f( 1, -1, 1);
glEnd();
glEnable(GL_DEPTH_TEST);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_LIGHTING);
I discovered, that the problem is somehow related to glLoadIdentity(). If I remove the two lines, I see no background - which is normal, but I get 20fps.
Does anyone have an idea, how to draw my background pic faster?
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glDisable(GL_LIGHTING);
glMatrixMode( GL_MODELVIEW );
glPushMatrix();
glDisable(GL_DEPTH_TEST);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glPushMatrix();
glLoadIdentity();
glEnable(GL_TEXTURE_2D);
// backgr is a 512x512x24 BMP file
glBindTexture(GL_TEXTURE_2D, backgr);
glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2f(0, 0);
glVertex3f(-1, -1, 1);
glTexCoord2f(0, 1);
glVertex3f(-1, 1, 1);
glTexCoord2f(1, 1);
glVertex3f( 1, 1, 1);
glTexCoord2f(1, 0);
glVertex3f( 1, -1, 1);
glEnd();
glEnable(GL_DEPTH_TEST);
glPopMatrix();
glMatrixMode(GL_MODELVIEW);
glPopMatrix();
glEnable(GL_LIGHTING);
I discovered, that the problem is somehow related to glLoadIdentity(). If I remove the two lines, I see no background - which is normal, but I get 20fps.
Does anyone have an idea, how to draw my background pic faster?