PDA

View Full Version : Build textures during runtime



aan02016
12-20-2010, 04:08 AM
Hi,

how do I build textures during runtime as fast as possible every frame?
The program receive a stream from an USB-camera, then I want to make some maths with this stream so I just can't put it onto the screen... Instead I build a texturemapped QUAD...

But how to do this as fast as possible... The only way I can make it work is thru gluBuild2DMipmaps(...), I know it's both slow and the wrong way...

The texture or stream is 640x480 or 800x600... A non power of two and not square :p

I should and will use shaders but I think the big performance gain is a complete different way of doing this glu-thing...

I want some portability so how to do it in openGL 1.4/2.0/3.0 etc, or just some version if you have any ideas!

Any help or ideas is very welcome, thanks in advance!

mhagain
12-20-2010, 04:59 AM
Create the texture once only at startup using glTexImage2D, then update it as required using glTexSubImage2D. Use internal format GL_RGBA, format GL_BGRA and type GL_UNSIGNED_INT_8_8_8_8_REV for the best performance on the widest possible hardware base. If it's still too slow for you after that, you can start looking at PBOs, but getting this much right should be the first thing you do.

For your usage scenario I don't think you're going to need mipmaps at all, so just don't bother with them.

You can use a texture size at the next power of 2 larger than your stream size, so 1024 x 512 or 1024 x 1024, then adjust your texcoords accordingly while drawing. But watch your GL_MAX_TEXTURE_SIZE, and be sure to check for GL_ARB_texture_rectangle and GL_ARB_texture_non_power_of_two.

aan02016
12-20-2010, 08:34 AM
Thanks alot!!! Worked directly! Now it runs sooo much faster!


How much speedup will it be using the extensions?