Saturday, December 27, 2008

Documentation, Microsoft! DOCUMENTATION!

IDirect3DDevice9::SetGammaRamp, cool or what?

Some parts of the documentation claim it doesn't work on Windowed displays, other parts claim that it does but affects the entire screen (it doesn't work at all windowed for me, but who knows for somebody else).

Nowhere in the documentation does it mention that you need to bit-shift left by 8 to get the correct values in, otherwise you get an all-black screen.

This is crazy. I just lost about 3 hours trying to figure out what I was doing wrong, including having to undo all sorts of nasty things I had done in the process. In the end I decided to look up the old GDI function (SetDeviceGammaRamps) that does much the same, and - lo and behold - there was the necessary info. An array of WORDS (i.e. unsigned shorts) with the ramps stored in the most significant bits. It seems obvious that the D3D function is just a wrapper around the GDI one, and also does the necessary GetDC/ReleaseDC stuff (as well as screwing up windowed mode gamma, as a bonus!)

Anyway, I'm dropping D3D gamma and using GDI. This experience has left me with a baaaaaad taste.

0 comments: