Results 1 to 4 of 4

Thread: Stencil buffer problem ?

  1. #1
    Guest

    Stencil buffer problem ?

    Hello .
    I have a big problem .
    I can not work with stencil buffer .
    When I draw a object , OpenGL display it in frame buffer either I call before it "glStencilFun(GL_NEVER,..." or "glStencilFun(GL_ALWAYS,..." .
    What is my mistake ?
    Thankyou before your favour.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: Stencil buffer problem ?

    I assume you have enabled stencil test
    Code :
    glEnable( GL_STENCIL);
    ?

    Mikael

  3. #3
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Stencil buffer problem ?

    First take a step back and check if you have requested and selected a pixelformat with stencil bits.
    glGetIntegerv(GL_STENCIL_BITS, &stencilBits) will tell you if you actually got some.
    You should have cleared the stencil buffer with glClear(GL_STENCIL_BUFFER_BIT) before rendering into it.
    You need to enable glEnable(GL_STENCIL_TEST) to get any data rendered into the stencil buffer.
    Then set the glStencilFunc() and glStencilOp() and glStencilMask() they way you need it.
    Render your stuff into the stencil buffer.
    If you don't want this to occur in the color or depth buffer, use glColorMask() and/or glDepthMask() to disable writes to the respective buffer.
    Enable the write masks again, change your stencil funcs and render stuff which should be tested somehow against the previous stencil data.

  4. #4
    Senior Member Regular Contributor
    Join Date
    Aug 2004
    Location
    Angers, France
    Posts
    245

    Re: Stencil buffer problem ?

    Hi Heydari,

    You wrote "glStencilFun(GL_NEVER,..."
    Don't forget the c from function such as
    "glStencilFunc" as said Relic
    The .Product will make you .Believe

Similar Threads

  1. Stencil buffer problem
    By Loicus in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 08-13-2012, 03:09 AM
  2. Stencil buffer problem
    By Stuart McDonald in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 07-13-2012, 07:36 AM
  3. Stencil buffer problem ?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 06-30-2005, 12:46 PM
  4. Stencil Buffer Problem
    By mulat in forum OpenGL: Advanced Coding
    Replies: 9
    Last Post: 02-20-2003, 05:50 AM
  5. HELP: Stencil buffer problem
    By C++ in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 11-24-2002, 05:56 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