take a screenshot

Started by
10 comments, last by kburkhart84 18 years, 4 months ago
I would like to be able to capture screenshots of my game. So where is the final image stored for display, and how do i access this data? thanks
Advertisement
the "print screen" button takes a snapshot of your monitor and stores it in the clipboard. Paste that into any image-editing program for use. Also, ALT+Prnt Scrn takes a snapshot of just the active window.

EDIT: this is, of course, assuming you're running on windows
-Chris
You can just press the Print Screen button on your key board, and then paste it into Paint. Thats the simplest way I can think of.

EDIT: Damn Beaten again[grin]
My Current Project Angels 22 (4E5)
I took your question to mean a programmatic way of taking the screenshot and being able to access that data in-game. In OpenGL, all it takes is a simple function call.

glReadPixels(0,0,640,480,GL_RGB, GL_UNSIGNED_BYTE, imagedata)

This assumed a 640x480 resolution at 24-bit resolution. Change that to GL_RGBA for 32-bit, I believe. The unsigned byte is for the data type (0-255 values for r,g,b). image data is a pointer to the place you want to put this. I believe the container for this would be a char array of length (640x480x3) 921600. Excuse me if my math or explanation is off.. I haven't touched gl in a while.
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
If the simple print screen isn't what you're looking for, I think ultimategameprogramming.com has a tutorial for just this subject.
Quote:Original post by falkone
I took your question to mean a programmatic way of taking the screenshot and being able to access that data in-game. In OpenGL, all it takes is a simple function call.

glReadPixels(0,0,640,480,GL_RGB, GL_UNSIGNED_BYTE, imagedata)

This assumed a 640x480 resolution at 24-bit resolution. Change that to GL_RGBA for 32-bit, I believe. The unsigned byte is for the data type (0-255 values for r,g,b). image data is a pointer to the place you want to put this. I believe the container for this would be a char array of length (640x480x3) 921600. Excuse me if my math or explanation is off.. I haven't touched gl in a while.


You are pretty close. The fifth argument/parameter determines in what format you have your "imagedata" pointer in. As in, if you are using RGB format for example to save to a BMP file. It doesn't have anything to do with how high bit you have your display, rather how high bit/what format you want OpenGL to put in your imagedata pointer. If you want the alpha value, use GL_RGBA, though I don't think you would want to use that to save a screenshot. For imagedata pointer, I use the unsigned char type for it.


Or you could just have fraps http://www.fraps.com/ running and press f9 or whichever key it is and it will take a screen shot of your program.. it also gives you your fps.
Quote:Original post by kburkhart84
Quote:Original post by falkone
I took your question to mean a programmatic way of taking the screenshot and being able to access that data in-game. In OpenGL, all it takes is a simple function call.

glReadPixels(0,0,640,480,GL_RGB, GL_UNSIGNED_BYTE, imagedata)

This assumed a 640x480 resolution at 24-bit resolution. Change that to GL_RGBA for 32-bit, I believe. The unsigned byte is for the data type (0-255 values for r,g,b). image data is a pointer to the place you want to put this. I believe the container for this would be a char array of length (640x480x3) 921600. Excuse me if my math or explanation is off.. I haven't touched gl in a while.


You are pretty close. The fifth argument/parameter determines in what format you have your "imagedata" pointer in. As in, if you are using RGB format for example to save to a BMP file. It doesn't have anything to do with how high bit you have your display, rather how high bit/what format you want OpenGL to put in your imagedata pointer. If you want the alpha value, use GL_RGBA, though I don't think you would want to use that to save a screenshot. For imagedata pointer, I use the unsigned char type for it.


Ah, so no manual conversion is required then?
Disclaimer: "I am in no way qualified to present advice on any topic concerning anything and can not be held responsible for any damages that my advice may incurr (due to neither my negligence nor yours)"
ScreenCap </selfplug> [wink]
Rob Loach [Website] [Projects] [Contact]
thanks for all the replies

I was looking for an in program way to do this, so I will go with the glReadPixels(0,0,640,480,GL_RGB, GL_UNSIGNED_BYTE, imagedata)
then i can save as bmp or whatever, thanks

This topic is closed to new replies.

Advertisement