glReadPixels
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);
}
Oh my god!! Cross posting this in the Lounge !!! Haha!! u aer teh funie!!!
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
And you better delete [] ''dimensions'' and ''buf'' or your app will consume 1440020 bytes, 1.3 Mbytes every frame, in case you are calling this per frame... Think about it: 82.4 Mbytes/s (60 fps), isn''t it great...
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Any body knows what is the problem with my code?
2Shlomi:
How do you know how much bytes my app will consume per frame?
[edited by - idinkin on October 16, 2003 10:36:16 AM]
2Shlomi:
How do you know how much bytes my app will consume per frame?
[edited by - idinkin on October 16, 2003 10:36:16 AM]
quote:Original post by idinkin
Any body knows what is the problem with my code?
2Shlomi:
How do you know how much bytes my app will consume per frame?
[edited by - idinkin on October 16, 2003 10:36:16 AM]
In case that your resolution is 800*600 than this code will consume xxx(-> look above <-) MBytes per call...
Your code has many problems like not being written between the [ source ]...[ /source ] tags...
edit: stupid tags...
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
[edited by - shlomisteinberg on October 16, 2003 11:37:58 AM]
quote:Original post by idinkin
Can you answer the question??
Put your code between the [ source ]...[ /source ] tags so I would be able to read it, then I will answer your question....
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
Oh.. I''m sorry.. Now I remember. You have sight problems!
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);}
quote:Original post by idinkin
blablablabla
*worthless code goes here*
You idiot!! Where the spaces/tabs?! This more readable?! YOU BIG DONKEY!!!
edit:
*looks at code without understanding anything*
Of course it doesn't work!! You run it on a GeForce 3 Ti200!! Buy that new FX 5200 64MB (!) and then check that code!!
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
[edited by - shlomisteinberg on October 16, 2003 2:41:19 PM]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement