Screenshots
Hi, here is a little Yule gift for all you GL junkies out there, it’s a short quick and easy tool for taking a screen shot into the tga format, sure it’s uncompressed and doesn’t increment the file name, but it’s pretty slick.
void screenshot (char filename[160],int x, int y) { // get the image data // split x and y sizes into bytes int ya= y % 256; //assemble the header // write header and data to file delete[] data; |
Usage: screenshot (“test.tga”,800,600);
Just call the function with the correct window size just before SwapBuffers and it will take a screen shot of everything in the frame buffer, easy.
3 Comments
Other Links to this Post
RSS feed for comments on this post. TrackBack URI


By yifan, December 10, 2011 @ 06:52
very nice function. I use it to save my ray tracing picture.
By Peter Wallström, December 10, 2011 @ 12:47
Tanks, and pretty soon i will release an even better version in my toolkit that can deal with compression
By NaliPL, February 7, 2012 @ 01:15
reinterpret_cast
change to reinterpret_cast
require include :
#include
#include
if not using “using namespace std;
Then place std before; std::fstream std::ios