I have some code to take a screenshot. I use glReadPixels to get the data.
However, i use that piece of code for over 2 years now and used several drivers, etc. and since the first day there is one weird thing about it:
The data is randomly flipped about the horizontal or vertical axis!
Sometimes i need to flip the screenshot around the x-axis, sometimes around the y-axis, sometimes i need to rotate the image 180°. It seems to be completely non-deterministic. I don’t change ANYTHING of the code, it seems to be decided at program-startup, how the driver flips the data around.
I use an ATI Radeon 9700.
So, i assume it is some setting, which i don’t set, which affects how the data is transfered. Any ideas?
Hm, i put a glFinish right before and after glReadPixels and now it seems to always work as expected. Although i can’t say for sure now, because this “bug” has a will of his own.
I will test it further and if it comes up again, i’ll tell you. However, it seems as if this solved it.
the beginning looks a bit strange: first, you use glGetInteger to get the viewport size. then you modify the viewport variable with GetResolution*, although it already contains the viewport size.
btw, it’s not necessary to create the file byte by byte if you use GL_BGR in glReadPixels, like in the following example
Uh, got me there!
Seems i first did it this way and then, after i had some new and shiny code, changed it to another way, but forgot to remove the redundancy.
Well, i admit, your code is shorter. And nicer. But mine got more love in it!
But maybe i use yours from now on.
I wish i had the time to do all the programming i like, right now
If you are so good, would you also like to write my medicine test for me?