I have a system in which I cache the back buffer of each windows in an allocated memories whenever redraw() finished its execution. The back buffer is being stored as an array of unsigned long where the content was read into as followings, and the content was being recalled using glDrawPixels();
{
unsigned long *buffer;
buffer = ( unsigned long * )malloc( imgW * imgH );
redraw();
glFinish();
glReadPixels( 0, 0, imgW, imgH, GL_RGBA, GL_UNSIGNED_BYTE, buffer );
}
I had wished to optimize this process. It is to my understanding that by replacing glDrawPixels() with textured quad, on most system the process should be faster. My window is not always in POT however. After a brief research, there appeared to be these three approaches people use.
- GL_TEXTURE_RECTANGLE_ARB/(GL_TEXTURE_RECTANGLE?)
- Make the canvas size of your image into a POT image whereas the extended sections are to be padded by other colors.
- Break your image into smaller tiles of POT attributes, then re-construct them later accordingly.
My questions are these.
- Which is the approach most would implement? For the moment, I am incline toward the first. Though, I gathered that it is not too friendly toward old graphic cards?
- What are the differences between GL_TEXTURE_RECTANGLE and GL_TEXTURE_RECTANGLE_ARB?
- Would this effected the multisampling capabilities I do have in the buffer I read from? I gather that multisamplings are calculated during all the drawing functions so this should be like simply copying the resulting pixels?
- If I want to output what was being cached as an image for a debugging purpose, how should the method be approached?
- Are there more ways, I can also optimize glDrawPixels() barring the use of FBO, or PBO?