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.
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
glTexImage2D(...
EDIT: and the basic trap, be sure to upload the texture only once, and not for each frame
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: