Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9156251
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:44:03+00:00 2026-06-17T12:44:03+00:00

An example code looks like this: glEnable(GL_STENCIL_TEST); glClearStencil(2); glClear(GL_STENCIL_BUFFER_BIT); glStencilFuncSeparate(GL_FRONT, GL_NOTEQUAL, 0, 1); object.draw();

  • 0

An example code looks like this:

glEnable(GL_STENCIL_TEST);
glClearStencil(2);
glClear(GL_STENCIL_BUFFER_BIT);
glStencilFuncSeparate(GL_FRONT, GL_NOTEQUAL, 0, 1);
object.draw();
glDisable(GL_STENCIL_TEST);

Stencil buffer for each pixel has this binary value: 00000010 (8 bits precision) Next, glStencilFuncSeparate make following logic operation: (00000000 & 00000001 = 00000000), (00000010 & 00000001 = 00000000) -> 00000000 != 00000000 so the stencil test is failed and front faces of the object won’t be drawn. We can set a mask for example as 2 or 255 and then the test will be passed.

If the Ref argument in glStencilFuncSeparate is 257 then will be clamped to 1. 1.What about the mask argument and clamping ?
2.Presented informations are correct, right ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T12:44:04+00:00Added an answer on June 17, 2026 at 12:44 pm

    You say:

    Stencil buffer for each pixel has this binary value: 00000010 (8 bits precision) Next, glStencilFuncSeparate make following logic operation: (00000000 & 00000001 = 00000000), (00000010 & 00000001 = 00000000) -> 00000000 != 00000000 so the stencil test is failed and front faces of the object won’t be drawn.

    which is all correct.

    We can set a mask for example as 2 or 255 and then the test will be passed.

    Yes; any value where the combination of the mask parameter (the fourth parameter to glStencilFunc*) with the pixel’s stencil value yields a non-zero answer (provided you don’t change the ref parameter (the third parameter to glStencilFunc*) will pass the stencil comparison test.

    If the Ref argument in glStencilFuncSeparate is 257 then will be clamped to 1.

    Actually, no. According to the OpenGL spec and glStencilFunc* reference page, the ref value is clamped to the range [0,  2s – 1], where s is the number of stencil bits, so in your example, the ref value would be clamped to 255.

    1. What about the mask argument and clamping?

    only the s least significant bits of mask are used. The stencil comparison function is really:

    result = (pixel & (mask & (1<<s - 1))) <stencil func> (ref & (mask & (1<<s - 1)))
    

    2. Presented informations are correct, right?

    Almost. Not a bad job at all 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

example: http://jsfiddle.net/kuTLf/ code looks like this: <div id=main> <div id=slideshow class=pics> <div id=nav></div> <img
For example, I have a code looks like this: a = [1, 2] b
I have seen example code that looks like this, which seems perfectly reasonable: [Authorize(Roles
I'm trying to reimplement this example in CoffeeScript. My code looks like this: class
My base code looks like this: class C1(object): def f(self): return 2*self.g() def g(self):
Currently my code looks like this. It allows me to parse multiple parameters my
The example code is like this, it does the statistic of number of times
my HTML code looks like this <TR Row=1 CLASS=ThemeAlignCenter> <TD id=wrdActive_Row1 style=width: 50px CLASS=rdThemeDataTableCell><SPAN
my HTML code looks like this <TABLE style= border=0 CLASS=rdThemeDataTable id=dtWardData cellspacing=0> <COL id=wrdActive></COL>
My code looks like this: myObject.myMethod('imageCheck', function () { var image = new Image();

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.