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 );
glMatrixMode( GL_MODELVIEW );
// backgr is a 512x512x24 BMP file
glNormal3f(0.0f, 0.0f, 1.0f);
glVertex3f(-1, -1, 1);
glVertex3f(-1, 1, 1);
glVertex3f( 1, 1, 1);
glVertex3f( 1, -1, 1);
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?
No, it’s faster because you don’t draw anything. The load identity is very inexpensive. My only criticism is that you keep pushing the matrix before you load the identity matrix, this is probably not required, you only need to push the matrix stack if you want to restore what’s on it back later. The last thing you would want to do is push before an identity load unless you were trying to return the stack to it’s previous state after drawing your background. This will not be slowing you down either.
Displaying your background image takes a lot of work to texture all the pixels with your image. You could make this faster by disablind depth tests & writes and by changing your texture filter, perhaps to GL_NEAREST and by changing the internal format of the texture and using a GL_REPLACE texture environment instead of GL_MODULATE, but quality will be affected by some of these.
If you’re slower than 20fps you may not have a hardware accelerated OpenGL context. Upgrade your drivers and make sure your pixel format descriptor is accelerated, and perhaps upgrade your graphics card if you still have problems.
Damn! I found the problem. You were right about the drivers. I’ve never thought WinXP would detect my Asus Geforce 6800 as a Nvidia Geforce DDR.
I downloaded the drivers and voilá! It runs fine.
I just switched to XP from 98 and as XP recognized my graphics card, I didn’t care about looking after its type stored in the driver settings.