PDA

View Full Version : How can i find out the color depth of the desktop?



01-01-2003, 12:04 PM
The code below attempts to create a full screen openGL window at a resolution of 1024*768 with a 32 bit color depth:

CreateGLWindow("Taking Fire",1024,768,32,fullscreen))

However I want to replace those constants with variables defined by the current desktop resolution. I can use:

int xres = GetSystemMetrics(SM_CXFULLSCREEN);
int yres = GetSystemMetrics(SM_CYFULLSCREEN);

to find out the desktop resolution but I'd like to know how to determine the desktop color depth or alternatively get OpenGL to automatically use the highest color depth the card supports.

DFrey
01-01-2003, 04:43 PM
Use EnumDisplaySettings, and have it tell you the current settings only.

DFrey
01-01-2003, 04:46 PM
Or pass the DC of the desktop to GetDeviceCaps to get the BITSPIXEL value.

01-02-2003, 01:27 AM
Thanks for the reply. I had tried Getdevice caps but used GetDC instead of GetDC(NULL) and it kept returning 0. The code below now does the job.

char bpp[10] = {0};// 0-9 !!
int x = GetDeviceCaps(GetDC(NULL),BITSPIXEL);
_itoa( x, bpp, 10 );
alert[9]=0;//ensure null termination
MessageBox (NULL, TEXT (alert), TEXT ("Color Depth"), 0) ;

marcus256
01-03-2003, 03:18 AM
GLFW (http://hem.passagen.se/opengl/glfw) :

GLFWvidmode mode;
glfwGetDektopMode( &mode );
printf( "%d x %d x %d:%d:%d\n", mode.Width, mode.Height, mode.RedBits, mode.GreenBits, mode.BlueBits );

...which of course also works under Linux, SGI/IRIX, Solaris, etc, and soon Mac OS X too http://www.opengl.org/discussion_boards/ubb/wink.gif