saving canvas into bitmap problem

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!

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

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

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

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

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

any chance you could point me to that code?

cheers

Originally posted by chowiela:
[b]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.

[/b]

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