View Full Version : reading color buffer to save as bitmap
08-19-2005, 04:14 PM
I need to read the information in the color buffer, which I have just rendered to, so that I can save this information to file in bitmap form.
I have successfully done so with small sections of the color buffer ( 120x120 pixels ) - but the information I retrieve is distorted spacially and in color content when I attempt to perform the same thing with larger sections of the color buffer such as 200x200 pixels. I have chosen dimensions that are multiples of eight to avoid problems due to padded length of the rows.
Any suggestions? Thanks in advance.
- mark young
Have you looked at glPixelStore, specifically the GL_PACK_* stuff? Not sure what you mean by "distorted spacially".
08-21-2005, 03:35 PM
Actually I did try what you suggested. I wish there was a word to describe the horrific things that openGL is doing with the data it gives me - but you can imagine in some cases it is perfect, in some cases the scan lines appear slightly shifted horizontally in relation to the neighboring scan line, in some cases it displays total garbage, and in some cases the colors are incorrect.
Search for the OpenGL Game Programming book. Go to the errata page and try chapter 6 or 7 (might want to look at the table of contents to be sure). There's a good code example of how you can save a screenshot from your opengl window.
08-22-2005, 04:40 PM
Thanks DVM !! My professor just told me if I got this working the project was complete enough for the summer - and I can take a vacation without guilt.
Twenty minutes later I had it fixed thanks to your suggestion.
I never did find an errata list, but I did find the "teaser" examples for some folks trying to sell the OpenGL Game Programming book. You were right - chapter 7, example 3, had exactly what I needed. I just pasted in their function ( with the same param list as my own function ) and everything worked magically!!!
Here's the URL to the zip file:
- mark young / ucsc student
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.