Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

idinkin

glReadPixels

This topic is 5456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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); }

Share this post


Link to post
Share on other sites
Advertisement
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!"

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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!"

Share this post


Link to post
Share on other sites
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);
}

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!