-
May 9th, 2001, 06:44 PM
#1
glReadPixels() Help!
Hello, I am not familiar with OpenGL and its API, but I was wondering how I would go about using the function glReadPixels()? Yes, yes, I have looked at all of the declarations for it as MSDN, etc., but I still am I not sure how to utilize it. In order to use the function, must I intialize a bunch of OpenGL things as I would for DirectDraw? How would I incorporate this function in a Win32 program that reads the color values of pixels in a game running in OpenGL? Also, once pixel data is retrieved, say with the GL_RGB flag (or any other one for that matter. I'm not too familiar in which mode to use), how do I access the color information of the pixels? Is it stored in hexademical, etc? If possible, it would to great to have example code showing how to use glReadPixels(). Thank you very much in advance.
-
May 13th, 2001, 04:41 AM
#2
Re: glReadPixels() Help!
This is a screencapture function I`m using.
It captures RGB information of the screen and stores it in UNSIGNED_BYTE format, that is three bytes RGB.
/*
DB = uchar
DW = ushort
DD = ulong
*/
typedef struct{ DB Head[12];
DW DX, DY, Head2;
DB Pic[768*1024][3];
} TypeTGA;
TypeTGA TGA;
char CaptureName[256];
DD CaptureNo;
DB TGAHead[12] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
void
ScreenCapture (void)
{
// Prepare targa header
memcpy(TGA.Head,TGAHead,12);
TGA.DX = Screen.Width;
TGA.DY = Screen.Height;
TGA.Head2 = 0x2018;
glReadPixels (0,0,Screen.Width,Screen.Height,GL_RGB,GL_UNSIGNED_BYTE,TGA.Pic[0]);
sprintf(CaptureName,"Snapshots\\Pic_%04x.TGA",CaptureNo); CaptureNo++;
cc = fopen(CaptureName,"wb");
fwrite(&TGA,1,(18 + 3*Screen.Width*Screen.Height),cc); fclose(cc);
}
Miran
-
March 25th, 2013, 06:40 AM
#3
Re: glReadPixels() Help!
Hello,
I used you code but I have my output saved picture is reversed.
Have you please an Idea about this problem?
Thank you in advance
oussama
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|