12.07.2015 Views

Lecture notes - FreeDesktop.Org

Lecture notes - FreeDesktop.Org

Lecture notes - FreeDesktop.Org

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Stencil Buffer – ExampleglClearStencil(0);glClear(GL_STENCIL_BUFFER_BIT);glEnable(GL_STENCIL_TEST);// Write 1 to stencil where polygon is drawn.glStencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS, 1, ~0);glStencilOpSeparate(GL_FRONT_AND_BACK,GL_KEEP, GL_KEEP, GL_REPLACE);draw_some_polygon();// Draw scene only where stencil buffer is 1.glStencilFuncSeparate(GL_FRONT_AND_BACK, GL_EQUAL, 1, ~0);glStencilOpSeparate(GL_FRONT_AND_BACK,GL_KEEP, GL_KEEP, GL_KEEP);draw_scene();© Copyright Ian D. Romanick 2009, 2011 9-February-2011

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!