GetPixel() returning wrong value (Windows API)
Posted on 2004-09-22
I'm using GetDC() to get a device context for the entire screen followed by GetPixel() to check the color of a pixel within a DirectX application. Most frequently the color returned is the correct, expected value. However, occasionally when no colors have changed GetPixel() performed on the same x and y will return an incorrect, completely unrelated value and I'm having a hard time pinpointing why. The only thing I can come up with is that GetPixel() is returning values from the back buffer occasionally while it's still being rendered in memory, but I'm not sure on that at all.
So, any idea what's causing this behavior, and if so, how would I go about preventing it?