PDA

View Full Version : Best way to render a frame?



stefand
07-13-2009, 12:33 PM
Can someone tell me the best way to draw a frame with OpenGL? At the moment I am using glDrawPixels with most of the features for 3D disabled to speed things up. However there must be a better way?

I have investigated pixel buffer objects, but my graphics chip doesn't support this extension.

ZbuffeR
07-13-2009, 01:18 PM
What do you mean, a frame ?
glDrawPixels is not always very fast.
A textured quad or two textured triangles assembled in a quad is very fast.

stefand
07-13-2009, 09:00 PM
By frame, I mean that I have an array of unsigned bytes in memory that I want to draw to the window. One thread writes to this memory as it knows what color each pixel is, and another thread will render the memory to the output window when it receives a WM_PAINT message using glDrawPixels.

If I use a textured quad, do I need a special extension if my texture is not a power of two?

scratt
07-14-2009, 12:39 AM
I would use glTexSubImage2D to upload to a texture, and then a textured QUAD / TRIANGLE_STRIP (QUAD) to draw it on the screen.

Without knowing what HW you are on I can't say whether you need a POT texture or not. Most HW these days will support NPOT textures, but in any case you can upload any shape you like to the texture using glTexSubImage2D (as long as it's a rectangular or square obviously!!) .

ZbuffeR
07-14-2009, 01:48 AM
Then to draw it, adapt the texture coords to only show the relevant part, with something like : ((float)width)/texwidth instead of 1.0