Original Post
I get 205 for red, green and blue after I call glReadPixels although the screen is not gray... I tried to call the function before and after SwapBuffers... What do I do wrong?
Here is the function:
bool __declspec(dllexport) PrintScreen(CGraphController controller)
{
FILE *f;
GLubyte *buf = new GLubyte[controller.screenWidth * controller.screenHeight * 3];
char *dimensions = new char[20];
glReadPixels(0, controller.screenHeight, controller.screenWidth, controller.screenHeight,
GL_RGB, GL_UNSIGNED_BYTE, (void *)buf);
if(!(f = fopen("screenie.idg", "w")))
{
Log("Can not open file for writing!", __FUNCSIG__);
return false;
}
sprintf(dimensions, "%d %d ", controller.screenWidth, controller.screenHeight);
fputs(dimensions, f);
fwrite(buf, controller.screenWidth * controller.screenHeight * 3, 1, f);
fclose(f);
}