Is it possible to use some openGL functions to take a screenshot and maybe save it to a pre-defined dir?
Code would help!
Thanks in advance,
Sérgio "KeSh" Rui
Orzech
11-24-2004, 01:18 PM
Originally posted by KeSh:
Is it possible to use some openGL functions to take a screenshot and maybe save it to a pre-defined dir?Unfortunately, there is no such feature in OpenGL. Though, it doesn't mean you can't solve the problem. :)
You may consider using glReadPixels() to get the data from your color buffer and then - having a pixel data of what you see on a screen - you can save it to a file. The process of creating an image file might be a little confusing. You can go for some graphics library where you will find functions that create an image file basing on a data you have.
Cheers :)
RigidBody
11-25-2004, 05:25 AM
here it comes, quick and dirty:
void Screendump(char *destFile, short W, short H) {
FILE *out = fopen(destFile, "w");
char pixel_data[3*W*H];
short TGAhead[] = {0, 2, 0, 0, 0, 0, W, H, 24};
glReadBuffer(GL_FRONT);
glReadPixels(0, 0, W, H, GL_BGR, GL_UNSIGNED_BYTE, pixel_data);
fwrite(&TGAhead, sizeof(TGAhead), 1, out);
fwrite(pixel_data, 3*W*H, 1, out);
fclose(out); }creates a 24-bit uncompressed true color tga-file, width W and height H. for a complete description of tga go to www.wotsit.org. (http://www.wotsit.org.) if you use a doublebuffered configuration, be sure to swap buffers before you call the screendump function.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.