Results 1 to 7 of 7

Thread: What is z-buffering?

  1. #1
    Guest

    What is z-buffering?

    I'm new to OpenGl, 3 days exactly. I know C++ though, but what i'm asking is what in the world is z-buffering?

  2. #2
    Senior Member Regular Contributor
    Join Date
    May 2000
    Location
    Oxford, England
    Posts
    472

    Re: What is z-buffering?

    its a depth test. It ensures that objects in your world are drawn in the right order.

    ie, stuff at the back, isn't drawn over whats in the front.

  3. #3
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: What is z-buffering?

    This means you do not have to sort for depth.
    You can draw your objects in whatever order you like and the foremost should be visible anyway.
    The z-buffer simply stores the depth value of each pixel and compares with this upon rendering.

  4. #4
    Guest

    Re: What is z-buffering?

    so how do i code for this?

  5. #5
    Senior Member OpenGL Guru Humus's Avatar
    Join Date
    Mar 2000
    Location
    Stockholm, Sweden
    Posts
    2,342

    Re: What is z-buffering?

    Well... are you using glut or win32 api?
    You must first of all request a depthbuffer (z-buffer). In win32 api you set the cDepthBits members in the PIXELFORMATDESCRIPTOR structure to something like 16,24 or 32. I dont know exactly with glut but you should pass a GL_DEPTH_BUFFER or similar parameter when you initialize your window.
    You must also enable depth testing with glEnable(GL_DEPTH_TEST) and you should set up an appropriate depthtest function with either glDepthFunc(GL_LESS) or glDepthFunc(GL_GREATER) depending on what fits your app.

  6. #6
    Senior Member OpenGL Guru
    Join Date
    Feb 2000
    Location
    Sweden
    Posts
    2,978

    Re: What is z-buffering?

    Just a minor note to Humus post. In GLUT you pass GLUT_DEPTH to glutInitDisplayMode() to get a depthbuffer.

  7. #7
    Guest

    Re: What is z-buffering?

    Thanks for the help, I was looking at NeHe's tutorial and i believe he uses z-buffering so i get how to do it now.

Similar Threads

  1. VBO Buffering
    By Critical_Impact in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 05-04-2010, 04:49 PM
  2. Z-buffering
    By nt in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 10-17-2007, 07:03 PM
  3. Stereo buffering?
    By PM in forum OpenGL: Advanced Coding
    Replies: 7
    Last Post: 03-03-2003, 01:36 PM
  4. Buffering
    By Gavin in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 05-15-2001, 11:43 AM
  5. how do i use tripple-buffering
    By imported_T2k in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-11-2001, 03:50 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