PDA

View Full Version : saving canvas into bitmap problem



03-11-2004, 09:41 PM
hi. i've search through the forums and found some code for saving the screen canvas into bitmap using glReadPixels, and i've tried it.

one weird problem is that the code can save a clean blank canvas, i.e. all black (my starting canvas is black), but once i draw something on it, the file cannot be saved. is it some double buffer problem, or am i just using the wrong dc? does Invalidate(FALSE) do anything to it other than flushing the old one out? i'm not too good in this, hope you all can help. thanks!

mikael_aronsson
03-11-2004, 11:03 PM
Hi !

What do you mean by "it doesn't work" whet happens when you save it ? is the contents still black or junk or what ?

Maybe you could post the code that does the actueal reading (glReadPixels) in case you do something wrong there.

Make sure you have an active rendering context when you call glReadPixels.

You could also try to call glGetError in some places in the code to make sure that you don't have any errors in there.

Mikael

03-12-2004, 06:25 AM
it doesn't work in the sense that the bitmap file is not created at all. in the previous case (when nothing is drawn) a blank black bitmap file can be created.

regarding the active rendering context.. do you mean the dc? i'm rather confused by the DCs and such.. bleah

thanks for the tip abt glGetError anyway! will go try it

03-12-2004, 06:32 AM
it doesn't work in the sense that the bitmap file is not created at all. in the previous case (when nothing is drawn) a blank black bitmap file can be created.

regarding the active rendering context.. do you mean the dc? i'm rather confused by the DCs and such.. bleah

thanks for the tip abt glGetError anyway! will go try it

03-12-2004, 06:33 AM
it doesn't work in the sense that the bitmap file is not created at all. in the previous case (when nothing is drawn) a blank black bitmap file can be created.

regarding the active rendering context.. do you mean the dc? i'm rather confused by the DCs and such.. bleah

thanks for the tip abt glGetError anyway! will go try it

mikael_aronsson
03-13-2004, 11:28 PM
Hi !

A rendering context must be active for any OpenGL functions to work, in win32 you use wglMakeCurrent(...) to do this, in glut it is done for you in the display callback and so on.

Mikael

39smooth
03-14-2004, 02:15 PM
any chance you could point me to that code?

cheers



Originally posted by chowiela:
hi. i've search through the forums and found some code for saving the screen canvas into bitmap using glReadPixels, and i've tried it.





[This message has been edited by 39smooth (edited 03-14-2004).]