Re: [AD] [WIN] desktop_color_depth() problem

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


At 15:52 06/10/00 +0200, you wrote:
Hi,
I've just come across a weird problem with the desktop_color_depth()
function on Windows (95 OSR2 French, DirectX 6.0)
Here the code:

#include <allegro.h>
#include <winalleg.h>

int WINAPI WinMain(HINSTANCE hInst, HINSTANCE hPrevInst, LPSTR lpCmdLine,
int nCmdShow)
{
    allegro_init();
    allegro_message("color depth = %d", desktop_color_depth());
    return 0;
}

Sometimes I get 32232 (!!), sometimes 29940 or 28840, whatever the actual
color depth Windows is using.
Can someone figure out what does it mean ?
Anyway, after looking into the Platform SDK docs, I've found a somewhat
different way of doing the things:

/* sys_directx_desktop_color_depth:
 *  Returns the current desktop color depth.
 */
static int sys_directx_desktop_color_depth(void)
{
   HDC dc;
   int depth;

   dc = GetWindowDC(allegro_wnd);
   depth = GetDeviceCaps(dc, BITSPIXEL);
   ReleaseDC(allegro_wnd, dc);

   return depth;
}

The return value is correct in every color depth (15bpp is reported as
16bpp, according to the docs) with my code.

--
Eric Botcazou (ebotcazou@xxxxxxxxxx)
Web Site: http://www.multimania.com/ebotcazou


OK, I have changed it. See if it works now for everybody




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