OpenGL - przycinanie kwadryką
Ostatnio zmodyfikowano 2014-02-17 13:47
albert_oo Temat założony przez niniejszego użytkownika |
OpenGL - przycinanie kwadryką » 2014-02-09 21:49:04 Witam.
Potrzebuję przyciąć prostokąt kołem, tj. aby uzyskać efekt:
|---------------| | / | / | / | / | | | | | \ | \ | \ | \ |---------------|
tak, aby prawa granica nowo-powstałego prostokąta była "wycięta" kołem. Funkcja glClipPlane przycina tylko płaszczyzną. Wielkie dzięki za pomoc.
Pozdro. albert_oo |
|
DejaVu |
» 2014-02-17 13:47:43 http://www.opengl.org/archives/resources/faq/technical/clipping.htm
10.030 How do I render to a nonrectangular viewport?
OpenGL's stencil buffer can be used to mask the area outside of a non-rectangular viewport. With stencil enabled and stencil test appropriately set, rendering can then occur in the unmasked area. Typically an application will write the stencil mask once, and then render repeated frames into the unmasked area.
As with the depth buffer, an application must ask for a stencil buffer when the window and context are created.
An application will perform such a rendering as follows:
glEnable( GL_STENCIL_TEST );
glStencilFunc( GL_ALWAYS, 0x1, 0x1 );
glStencilFunc( GL_EQUAL, 0x0, 0x1 );
After a single bit is painted in the area outside the viewport, an application may render geometry to either the area inside or outside the viewport. To render to the inside area, use glStencilFunc(GL_EQUAL,0x0,0x1), as the code above shows. To render to the area outside the viewport, use glStencilFunc(GL_EQUAL,0x1,0x1).
You can obtain similar results using only the depth test. After rendering a 3D scene to a rectangular viewport, an app can clear the depth buffer and render the nonrectangular frame.
|
/edit:
Więcej informacji na ten temat:
np. http://en.wikibooks.org/wiki/OpenGL_Programming/Stencil_buffer |
|
« 1 » |