Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 9 of 9

Thread: Setting ZBuffer

  1. #1
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Pesaro,Italy,Italy
    Posts
    14

    Setting ZBuffer

    i have big problem to find pixelformat where depth buffer works correctly.

    my code is:

    memset(&m_pfd,0,sizeof(m_pfd));

    m_pfd.nSize = sizeof(m_pfd);
    m_pfd.nVersion = 1;
    m_pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER | PFD_GENERIC_ACCELERATED;
    m_pfd.iPixelType = PFD_TYPE_RGBA;
    m_pfd.cColorBits = 32;
    m_pfd.cDepthBits = 32;
    m_pfd.cStencilBits = 8;
    m_pfd.iLayerType = PFD_MAIN_PLANE;

    //
    // Get the pixelformat of this setup.
    //
    int pf;
    PIXELFORMATDESCRIPTOR pfdCheck;

    if (!(pf = ::ChoosePixelFormat(m_hDC,&m_pfd)))
    {
    GiottoPrintf(GIOTTO_MSG_INITIALIZATION,"ChoosePixe lFormat() failed!");
    return false;
    }

    //
    // Get a description of the pixelformat chosen
    ///
    if (!(DescribePixelFormat(m_hDC,pf,sizeof(PIXELFORMAT DESCRIPTOR),&pfdCheck)))
    {
    GiottoPrintf(GIOTTO_MSG_INITIALIZATION,"GLView: ChoosePixelFormat() The OpenGL Pixeldescription couldn't be retrieved!");
    return false;
    }

    //
    // Is hardware accelerated ?
    //
    if (((pfdCheck.dwFlags & PFD_GENERIC_ACCELERATED) == 0) && ((pfdCheck.dwFlags & PFD_GENERIC_FORMAT) > 0))
    GiottoPrintf(GIOTTO_MSG_INITIALIZATION,"The OpenGL driver that's currently active doesn't support hardware acceleration or there is no decent OpenGL driver installed.");

    if (SetPixelFormat(m_hDC,pf,&pfdCheck)!=TRUE)
    {
    GiottoPrintf(GIOTTO_MSG_INITIALIZATION,"SetPixelFo rmat() failed!");
    return false;
    }

    if ((m_hRC = wglCreateContext(m_hDC)) == NULL)
    {
    GiottoPrintf(GIOTTO_MSG_INITIALIZATION,"Cannot create rendering context");
    return false;
    }

    if (!wglMakeCurrent(m_hDC,m_hRC))
    {
    GiottoPrintf(GIOTTO_MSG_INITIALIZATION,"wglMakeCur rent() failed");;
    return false;
    }


    but in windowed mode with G400 depth buffers doesn't work......anyone knows why!?!!?

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2002
    Posts
    366

    Re: Setting ZBuffer

    Originally posted by Powerino:
    i have big problem to find pixelformat where depth buffer works correctly.

    m_pfd.cColorBits = 32;
    m_pfd.cDepthBits = 32;
    The pfd entry cColorBits for RGBA buffers is excluding alpha. You should specify 24.

    Are you sure that the G400 supports a 32bit depth buffer? Few consumer level cards do(if any). See other thread in here regarding just that.

  3. #3
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Pesaro,Italy,Italy
    Posts
    14

    Re: Setting ZBuffer

    Yes G400 works with 32 bit depth buffer!!!

    i have the same problem with gforce4mx!!!

    with Color depth 32, Depth 32 stencil 0

    WHY?!?!?!

  4. #4
    Member Regular Contributor
    Join Date
    Jun 2002
    Posts
    366

    Re: Setting ZBuffer

    Found this article which might interest you. According to it, 32bit z-buffer support isn't enabled in GL drivers. This was however, 4 YEARS ago. Maybe Matrox has fixed it and there is some another problem, or maybe not. Matrox isn't really famous for their awesome GL support. Maybe you can whip up a simple Direct3D app and see if it works under DX(they claim it does). And I'm assuming you're using the latest drivers.

  5. #5
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Pesaro,Italy,Italy
    Posts
    14

    Re: Setting ZBuffer

    Thanks very much...i have tried all pixelformat and i have found that all pixelformat with doublebuffer in windowed mode doesn't work with my engine.......
    disabling doublebuffer it works fine!!!
    WHY?!?!?
    WHY if the DescribePixelFormat tells me there a a valid pfmt with depth buffer after in opengl it doesn't work!!!!?!?!

  6. #6
    Junior Member Newbie
    Join Date
    Jun 2002
    Location
    Pesaro,Italy,Italy
    Posts
    14

    Re: Setting ZBuffer

    Any idea how to find a valid pixelformat for my application.....using old opengl driver i can't use new wglARB functions for pixelformat!!!!

  7. #7
    Member Regular Contributor
    Join Date
    Jun 2002
    Posts
    366

    Re: Setting ZBuffer

    Originally posted by Mazy:
    I dont really think you have 32bit zbuffer on g400.
    I highly doubted this too, so I checked the specs at Matrox. And in fact, they do say they support a 32bit depth buffer, including an 8bit stencil. http://www.matrox.com/mga/products/t...chip_specs.pdf

    I also looked for something like "32bit depth only supported if: ..." but couldn't find any.

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Oct 2001
    Posts
    596

    Re: Setting ZBuffer

    you have 2 choices
    either try to send different configs in pfd and try choosepixelformat until you get a good result ( in windows you often have the limitation that if the desktop is 16bit the opengl must be 16bit, and the zbuffer cannot exceed the color in bits. )

    or number 2, loop through all pixelformats and run describepixelformats on them and make your own search between the formats.

  9. #9
    Senior Member OpenGL Pro
    Join Date
    Feb 2002
    Location
    Bonn, Germany
    Posts
    1,633

    Re: Setting ZBuffer

    You're requesting a stencil buffer. You can't get more than a 24 bit z buffer then.
    I don't know whether 32bit z only is possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •