View Full Version : glReadPixels are killing my project!!!
12-23-2010, 01:09 PM
I receive a stream from a camera, make a texture from that stream, rotate it and record it to a movie...
But, because I rotate it I can't just add my buffer/texture to movieframe I have to get what's on the screen!
So I try the glReadPixels(...) but my FPS drop from 25 to 11 :p
Is't a better solution for openGL 1.4/2.0/3.0?
I have notice a significant FPS-drop in my glClear(GL_COLOR_BUFFER_BIT), from 25 to 15? Is that normal?
12-23-2010, 02:05 PM
glReadPixels is slow. The same tips I gave in your other topic (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Main=55666&Number=2880 82#Post288082) (format GL_BGRA, type GL_UNSIGNED_INT_8_8_8_8_REV) will help a lot here,
12-23-2010, 02:42 PM
GL_UNSIGNED_INT_8_8_8_8_REV doesn't seem to work... Not supported, even if my OpenGL-version is 1.4.... But nevermind, new hardware on its way :)
GL_BGRA works but thru GL_BGR_EXT...
But is't the only solution? glReadPixels?
Thanks for your replys, helps alot and point me in the right direction...
12-23-2010, 02:47 PM
But is't the only solution?
You don't have to use OpenGL. If all you're doing is rotating an image, there are plenty of image libraries that can do that for you.
12-23-2010, 03:03 PM
GL_BGR_EXT isn't good enough as OpenGL will have to take a 32-bit framebuffer, go through it 4 bytes at a time, and drop one of those 4 bytes in order to get your data out. Depending on your driver this may be done entirely in software, meaning that it also needs to allocate (and subsequently free) another buffer of it's own in order to read back the data in it's original native format. This is one reason why so many people experience bad performance with glReadPixels - they're not coding close enough to the hardware. You need to be using the same format and layout as your framebuffer, and that means that you need a 4-component format in BGRA (or BGRX, same thing for the purposes of this discussion) layout.
If you don't have a define for GL_BGRA you can just add one to your program; this will work with OpenGL 1.2 or above so you don't need to worry about support unless you're targetting really really old (over 10 years old) hardware. Likewise with GL_UNSIGNED_INT_8_8_8_8_REV.
#define GL_BGRA 0x80E1
#define GL_UNSIGNED_INT_8_8_8_8_REV 0x8367
12-25-2010, 05:06 PM
Not have bench a lot this feature...
You can try without texture binding: just read from fbo:
glReadBuffer(GL_COLOR_ATTACHMENT0_EXT);//your texture attachment
Dont know if it'll work...
or read compressed image data using
As well it's said that not native pixel format can lead to performance losses....
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.