PDA

View Full Version : Bitmap Performance



cont103
06-25-2002, 08:18 AM
Hi,
I have a big bitmap image and I have to load it every time I redisplay the scene (I have made a display list and I call it). But the performance is very bad. How could I get rid of calling it every time? I mean, is there a way of calling it one time and then do other operations while the picture is still there?
thanks

mikael_aronsson
06-25-2002, 09:46 AM
Hi !

First of all, when you say bitmap, are you talking about a bitmap in windows terms (a matrix of pixels in different colors) or in the OpenGL terms a matrix of bits (0/1) ?

If you are talking about the first case, then it depends on how you display it, glDrawPixels is very slow, if you create a texture and put it on a quad you should get ok performance.

If youi are talking about the second case there isn't much you can do about it, I think most hardware today does not put a high priority on bitmaps so the performance could be suffering a bit there.

Mikael

cont103
06-25-2002, 10:26 AM
It's the same as the first case. But the problem is that: the display function should be called several times in one second, so the performance is still bad.
What I want to know is there a way to prevent calling the display list (of the quad) each time I call the display func?
I know that seems a bit strange but...
thanks anyway

ioquan
06-27-2002, 08:11 PM
You load the bytes of the bitmap into an unsigned char * or (GLUByte *). Then you dont need to read the file anymore. Once you have it loaded, you do something like this, once:

glGenTextures(1,&identifier);
glBindTexture(GL_TEXTURE_2D,identifier);

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE,GL_MODULATE);

glTexImage2D(GL_TEXTURE_2D,0,components,width,heig ht,
0,mformat,GL_UNSIGNED_BYTE,bytes);

Then you only need to do this to activate it on each frame update:


glBindTexture(GL_TEXTURE_2D, identifier);

zed
06-27-2002, 09:14 PM
yes display lists (with textures) were really only needed in opengl1.0, since opengl1.1 (which has been around for years) the above (ioquan) method is better (texture objects).
are u learning from an ancient code sample?