Jump to content
  • Advertisement
Sign in to follow this  
SelethD

take a screenshot

This topic is 4871 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!