Texture frequently updated from array

Started by
7 comments, last by A_SN 14 years, 11 months ago
Here's what I'm trying to do : I have a fairly large bitmap of arbitrary dimensions in an array (under the form uint32_t *array) that is frequently updated (up to 60 times a second) and that I'm trying to display flat on the screen (like an in-game minimap if you will). Since unlike a regular texture it's updated very often and its dimensions aren't a power of two the proper efficient way to do it should be quite unlike creating a regular texture, am I right? So what would be the appropriate way to do it? Thanks in advance.
Advertisement
How about DrawPixels? You also can use PixelZoom (not sure if that name is correct) to change the output size of the bitmap when displaying it.
Quote:Original post by A_SN
Here's what I'm trying to do : I have a fairly large bitmap of arbitrary dimensions in an array (under the form uint32_t *array) that is frequently updated (up to 60 times a second) and that I'm trying to display flat on the screen (like an in-game minimap if you will).

Since unlike a regular texture it's updated very often and its dimensions aren't a power of two the proper efficient way to do it should be quite unlike creating a regular texture, am I right? So what would be the appropriate way to do it?
All modern cards support the ARB_texture_non_power_of_two extension, which allows you to create arbitrary shaped textures. Previous generation cards support ARB_texture_rectangle, which is a more limited extension along the same lines.

If you have one of these extensions available, it should be as simple as creating the texture once, and then updating the texture data whenever necessary with glTexSubImage2D().

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Quote:Original post by surfi
How about DrawPixels? You also can use PixelZoom (not sure if that name is correct) to change the output size of the bitmap when displaying it.


Thanks a lot! Just tried that and it works great.
Quote:Original post by A_SN
Quote:Original post by surfi
How about DrawPixels? You also can use PixelZoom (not sure if that name is correct) to change the output size of the bitmap when displaying it.
Thanks a lot! Just tried that and it works great.
Be aware that glDrawPixels will often be slower than the texture upload method, and support under recent drivers can be a little iffy.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

Ack, there's a problem with glDrawPixels, it displays my bitmap upside down.. Any way to make OpenGL flip it? glPixelZoom is useless since it rotates around the 0 coordinates.

EDIT: Nevermind, worked it out.

Quote:Original post by swiftcoder
Quote:Original post by A_SN
Quote:Original post by surfi
How about DrawPixels? You also can use PixelZoom (not sure if that name is correct) to change the output size of the bitmap when displaying it.
Thanks a lot! Just tried that and it works great.
Be aware that glDrawPixels will often be slower than the texture upload method, and support under recent drivers can be a little iffy.


I can see that glDrawPixels isn't so fast in full screen. So far I haven't had any luck with glTexSubImage2D though, all I could get was a blue square...
Quote:Original post by A_SN
I can see that glDrawPixels isn't so fast in full screen. So far I haven't had any luck with glTexSubImage2D though, all I could get was a blue square...
Make sure you created the texture (using glTexImage2D) first - glTexSubImage2D only updates an existing texture.

Tristam MacDonald. Ex-BigTech Software Engineer. Future farmer. [https://trist.am]

If you need even more speed you can transfer texture using a PBO, that way you might get DMA transfer from CPU to GPU.
Quote:Original post by swiftcoder
Quote:Original post by A_SN
I can see that glDrawPixels isn't so fast in full screen. So far I haven't had any luck with glTexSubImage2D though, all I could get was a blue square...
Make sure you created the texture (using glTexImage2D) first - glTexSubImage2D only updates an existing texture.


Quote:Original post by mrr
If you need even more speed you can transfer texture using a PBO, that way you might get DMA transfer from CPU to GPU.


Using glDrawPixels is unpractically slow on my 10 year old Power Mac G4 450 MHz with an ATI Rage 128 AGP, I get like 5 FPS on a 1000x700 window, would any of those alternatives make it any faster for such old machines with slow GPUs?

This topic is closed to new replies.

Advertisement