Results 1 to 2 of 2

Thread: Writing directly to the Z-buffer?

  1. #1
    Member Contributor
    Join Date
    Sep 2000
    Copenhagen, Denmark

    Writing directly to the Z-buffer?

    Is it possible to write information directly into the Z-buffer and/or stencil buffer? I need to copy some color values from one imgaes into the Z-buffer as Z-buffer values. Then I need to draw another picture doing depth-tests with these values. It seems that functions like glCopyPixels and glReadPixels can read Z-buffer data and then convert them into colors but not the other way around. Can this be done?

    Any help is appreciated

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Feb 2000

    Re: Writing directly to the Z-buffer?

    Use glDrawPixels with GL_DEPTH_COMPONENT or GL_STENCIL_INDEX. Just remember that it does not draw directly into the depth/stencil buffer, but generates fragments. You might want to disable drawing to the color buffer, and set depth function to GL_ALWAYS. Not sure what you need to do with the stencil function, but I guess it's something similar.

Similar Threads

  1. Writing directly to the stencil buffer
    By imported_sleap in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 09-12-2013, 03:34 PM
  2. Writing and reading directly to/from buffers
    By muffinman104 in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 10-05-2009, 02:57 PM
  3. Writing directly to the depth buffer..!
    By Halloko in forum OpenGL: Advanced Coding
    Replies: 17
    Last Post: 10-16-2003, 01:38 PM
  4. writing directly to the screen.
    By Super13 in forum OpenGL: macOS
    Replies: 0
    Last Post: 02-25-2002, 12:41 AM
  5. Writing images directly to buffer
    By in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 06-25-2000, 05:05 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