[vtkusers] Re: again Stencil Buffer

Ingmar Wegner i.wegner at dkfz-heidelberg.de
Mon Jan 3 10:21:42 EST 2005

Hi to all,
to answer my question:

My problem was, that I disregarded, that we also use QT as a GUI besides 
VTK and ITK.
The default initialization of QGLWidget is without stencil buffer.
So with setting the right flag in QGLWidget and the overwritten 
'SetupPixelFormat'- method from vtkRenderWindow the stencil buffer 
should be available.

In SetupPixelFormat I  check the amount of stencil bits available through::

//check how much bits the stencil buffer supports
  GLint stencilBits = -1;
  glGetIntegerv(GL_STENCIL_BITS, &stencilBits);

    sizeof(PIXELFORMATDESCRIPTOR),  //gc size
    1,                              //gc version
    dwFlags         ,               //gc support double-buffering
    PFD_TYPE_RGBA,                  //gc color type
    bpp,                            //gc prefered color depth
    0, 0, 0, 0, 0, 0,               //gc color bits (ignored)
    0,                              //gc no alpha buffer
    0,                              //gc alpha bits (ignored)
    0,                              //gc no accumulation buffer
    0, 0, 0, 0,                     //gc accum bits (ignored)
    zbpp,                           //gc depth buffer
    stencilBits,                    //gc stencil buffer enabled!!!
    0,                              //gc no auxiliary buffers
    PFD_MAIN_PLANE,                 //gc main layer
    0,                              //gc reserved
    0, 0, 0,                        //gc no layer, visible, damage masks

Then the stencil buffer is also configured the right way in VTK.


>Message: 1
>Date: Wed, 29 Dec 2004 20:16:19 +0100
>From: Ingmar Wegner <i.wegner at dkfz-heidelberg.de>
>Subject: [vtkusers] again Stencil Buffer
>To: vtkusers at vtk.org
>Message-ID: <41D30283.9040107 at dkfz-heidelberg.de>
>Content-Type: text/plain; charset=ISO-8859-1; format=flowed
>Merry Christmas and a happy new year to you all,
>I wanted to ask once more, how stencil some objects in a vtk scene.
>I tried to enable stencil buffer, thought I solved the problem through 
>overwriting SetupPixelFormat in vtkWin32OpenGLRenderWindow, but now I 
>noticed, that I didn't solve the problem.
>I still haven't got access to the stencil buffer.
>I an OpenGL test environment I got the things I want to do to work 
>easily but VTK gives me a headache.
>How can I enable Stencil Buffer?
>Is there an other way to stencil rendered objects?
>Is that what vtkImageStencil or vtkImageToImageStencil are used for?
>What I need is a progress to be able to cut off objects through other 
>invisible objects like done in depth testing with disabled ColorMask. 
>Then I want to enable stencil -testing to be able to switch off depth 
>testing and to draw the next object only stenciled with the visible 
>objects (as if only in background).
>This is to be done in a 3D environment and the last object is a 2D 
>Image, so vtk always wants to draw it in the front...
>Any answer is welcome!
>    (I wrote three questions now, that weren't answered. I also tried to 
>reach David Grobbi but didn't succeed... )
>Happy new Year,

Dipl.-Inform. Med. Ingmar Wegner    Tel.: (+49) 6221/42-3543  
German Cancer Research Center       Fax.: (+49) 6221/42-2345  
Div. Medical and Biological Informatics                       
Im Neuenheimer Feld 280             mailto:I.Wegner at dkfz.de   
D-69120 Heidelberg, Germany      http://mbi.dkfz-heidelberg.de
Homepage: http://mbi.dkfz-heidelberg.de/mbi/people/ingmar.html

More information about the vtkusers mailing list