Save OpenGL Buffer as image?

Whether you're a newbie or an experienced programmer, any questions, help, or just talk of any language will be welcomed here.

Moderator: Coders of Rage

Post Reply
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Save OpenGL Buffer as image?

Post by dandymcgee »

Anyone know the easiest way to save the OpenGL screen buffer as an image file? The ultimate goal is to send it to the default printer. I know print screen would work perfectly fine for this, but unfortunately it is not an option. Any help is appreciated.

Thanks. ;)
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
User avatar
dandymcgee
ES Beta Backer
ES Beta Backer
Posts: 4709
Joined: Tue Apr 29, 2008 3:24 pm
Current Project: https://github.com/dbechrd/RicoTech
Favorite Gaming Platforms: NES, Sega Genesis, PS2, PC
Programming Language of Choice: C
Location: San Francisco
Contact:

Re: Save OpenGL Buffer as image?

Post by dandymcgee »

No one has any ideas?
Falco Girgis wrote:It is imperative that I can broadcast my narcissistic commit strings to the Twitter! Tweet Tweet, bitches! :twisted:
qpHalcy0n
Respected Programmer
Respected Programmer
Posts: 387
Joined: Fri Dec 19, 2008 3:33 pm
Location: Dallas
Contact:

Re: Save OpenGL Buffer as image?

Post by qpHalcy0n »

Create an auxiliary buffer object of an RGBA8 integer format with dimensions matching the window dimensions. When some key is pressed, you need to route the final render target instead of to the back buffer to the new render target. FBO would be best for this. Then you can use a PBO (pixel buffer object) to do an async readback of the buffer into client memory. From there you can take this client buffer, tag a BMP header, and write it out as a BMP.
Post Reply