Paul McCarthy
Paul McCarthy

Reputation: 890

SetDisplayMode(XRes, YRes, 16 vs 32, 0, 0)

I have an old DirectDraw based program I wrote years ago and I've started looking at it again.

I change one line from this: SetDisplayMode(XRes, YRes, 16, 0, 0)

to this: SetDisplayMode(XRes, YRes, 32, 0, 0)

and the program operates dramatically faster. (maybe 4 times faster)

The parameter I changed is bits per pixel. I would expect using more bits per pixel would need more memory and so be slower.

Does anyone have any experience of this behaviour? If yes, do you have any explanation as to why the performance improves?

Thanks.

Upvotes: 0

Views: 131

Answers (1)

MuertoExcobito
MuertoExcobito

Reputation: 10039

While it does seem intuitive that less precision would operate faster, it is likely that your current display hardware does not natively support a 16-bit mode. In fact, unless you are running programs in compatibility mode, Windows 8.0+ do not support 16-bit color at all. You can check your driver, to see if in fact, there is a 16-bit mode listed. If you were running such a program on much older hardware, it's likely that a 16-bit mode was supported.

If no support is natively available, there must be a conversion done at runtime, explaining why 16-bit mode is slower. If conversion is the reason, it will also consume no less memory than the 32-bit version.

Upvotes: 1

Related Questions