Results 1 to 5 of 5

Thread: How can i find out the color depth of the desktop?

  1. #1
    Guest

    How can i find out the color depth of the desktop?

    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.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: How can i find out the color depth of the desktop?

    Use EnumDisplaySettings, and have it tell you the current settings only.

  3. #3
    Senior Member OpenGL Pro
    Join Date
    Jun 2000
    Location
    Shreveport, LA, USA
    Posts
    1,502

    Re: How can i find out the color depth of the desktop?

    Or pass the DC of the desktop to GetDeviceCaps to get the BITSPIXEL value.

  4. #4
    Guest

    Re: How can i find out the color depth of the desktop?

    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) ;

  5. #5
    Senior Member Frequent Contributor marcus256's Avatar
    Join Date
    Aug 2001
    Location
    Sweden
    Posts
    764

    Re: How can i find out the color depth of the desktop?

    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

Similar Threads

  1. Find the minimun depth value
    By nachovall in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 03-19-2009, 05:44 AM
  2. Find color of point?
    By Bobalandi in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-04-2008, 04:40 PM
  3. Getting the bit depth of the 'desktop' on all platforms
    By RussJ in forum OpenGL: User Software
    Replies: 0
    Last Post: 05-04-2006, 12:11 AM
  4. Replies: 1
    Last Post: 07-19-2004, 08:19 PM
  5. desktop color depth
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-08-2001, 02:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean