RE: [AD] desktop_color_depth() in windows

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


> i noticed that this function needed to be implemented in the 3.9.12
> todo.txt, so i checked the mail-list archives and did not find anything
> saying it's been done yet, bit a few with people saying that it's broken
> under Windows!)

Thanks for it, but it was already done in the CVS version

> so here's one way to do it:
> // returns number of bits per pixel of the Windows desktop
> int deskop_color_depth(void)
> {
> // this function only requires <windows.h>
> // actually winuser.h for the function called & wingdi.h for the structure
> to store the data to be specific
>     DEVMODE devmode ;    // structure to store settings retreived by
> EnumDisplaySettings()
> 
>     // retreives settings and change corresponding members of DEVMODE
> structure
>     EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &devmode) ;
> 
>     return devmode.dmBitsPerPel ;    // return data from relevant member of
> DEVMODE
> }

Before calling enumdisplaysettings you should init the structure:
devmode.dmSize = sizeof (DEVMODE);
devmode.dmDriverExtra = 0;



Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/