I’ve got a large (4096*4096), 48-bits-per-pixel, bitmap which I need to display in my window as a 2D image, and I’m trying to determine which is the best way to display it. The picture needs to zip around a lot (transformed in x and y directions), so obviously speed is of the essence.
So far I’ve tried two methods:
i) Non-OpenGL method. Simply using the SetPixel command to write the pixels directly to my window. This is way too slow. It takes half a second just to paint the full window. :eek:
ii) OpenGL method. Apply the bitmap as a texture to a QUAD using glTexImage2D. While this is much faster and does work very well, it’s still slightly sluggish when viewing the screen at full size.
So is there any other way of doing this? My app doesn’t need to do any 3D stuff at all, though it does need to zoom the bitmap in every now and then.
Any help or suggestions much appreciated!!
Be sure to use (automatic or manual) mipmapping.
It will improve a lot the speed when there are more texels than pixels.
Use something like this for your texture params :
// or GL_LINEAR_MIPMAP_LINEAR, if it is not too slow for you, it smoothes transitions when zooming in
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST);
// auto mipmap, so you don't have to generate each mipmap level yourself
glTexParameteri( GL_TEXTURE_2D, GL_GENERATE_MIPMAP_SGIS, GL_TRUE ); // auto mipmap, so you don't have to generate each mipmap level yourself
EDIT: and the basic trap, be sure to upload the texture only once, and not for each frame
I’ve just tried that but my compiler’s not recognising the GL_GENERATE_MIPMAP_SGIS command. I’ve also tried GL_GENERATE_MIPMAP but to no avail.
Do you think I’ve got an old verion of OpenGL? If so, what do I need to update?
do you mean that your compiler is reporting an undefined symbol?
did you include glext.h?
do you check the extension string?
what version of opengl is reported by glGetString?
(this is all in the faq/wiki.)
OK thanks, I’ve got that compiling now. It really hasn’t made any difference to the speed though.
Any other thoughts on which way might be fastest?
Maybe if I use glDrawPixel instead? Or glBitmap?
To my knowledge texturing with mipmaping is the fastest way.
(4096*4096), 48-bits-per-pixel is a lot of data. : 96 MB !
Define “sluggish”, and what you expect.
It will depend also from your dsiplay resolution, and your video card.
Can you provide more details ?
The mipmaping only helps when the texture is significantly minified which might be not the case here.
It is also possible that the texture dimensions are too big for your card, you might try to split it into sveral smaller textures to see if that change something.
I’d crop the color format. 48 bits per pixel is enormous!
4096x4096x6 = 6x16777216 = 96 MB!!
If you can’t reduce the size, crop the colors. Even dropping it to 24 bit color, you won’t notice a visual difference, and it reduces it to 48 MB, small enough for most video cards, old or new. If not, compress the texture with S3TC or DXT. You can find out more here:
Thanks for your comments guys.
It seems that texture mapped Quads is the best way to do it, though the mipmapping doesn’t really help with the speed in this instance.
I now have another question on this topic, but I’ll post it in a separate thread instead of here.