MCPcopy Create free account
hub / github.com/cinder/Cinder / drawScene

Method drawScene

samples/_opengl/StencilReflection/src/StencilReflectionApp.cpp:75–122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void StencilReflectionApp::drawScene()
76{
77 gl::clear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
78 gl::ScopedMatrices scopeMatrices;
79 {
80 gl::setMatrices( mCam );
81 gl::multModelMatrix( translate( vec3( 0, -2, -1.5 ) ) );
82 gl::multModelMatrix( rotate( -mRotation, vec3( 0, 0, 1 ) ) );
83 {
84 // enable stencil test to be able to give the stencil buffers values.
85 gl::ScopedState scopeStencil( GL_STENCIL_TEST, true );
86 gl::stencilFunc( GL_ALWAYS, 1, 0xFF );
87 gl::stencilOp( GL_KEEP, GL_KEEP, GL_REPLACE );
88 gl::stencilMask( 0xFF );
89 gl::depthMask( GL_FALSE );
90 gl::clear( GL_STENCIL_BUFFER_BIT );
91 // draw the seperation plane into the stencil buffer.
92 {
93 gl::ScopedModelMatrix scopeModel;
94 gl::multModelMatrix( translate( vec3( 0, 0, 1.5 ) ) );
95 gl::color( ColorA( 0, 0, 0, 1 ) );
96 gl::drawSolidRect( Rectf( -1.25, -1.25, 1.25, 1.25 ) );
97 }
98 // now tell the stencil what type of stenciling it has.
99 gl::stencilFunc( GL_EQUAL, 1, 0xFF );
100 gl::stencilMask( 0x00 );
101 gl::depthMask( GL_TRUE );
102 // draw into that stenciled area
103 {
104 gl::ScopedModelMatrix scopeModel;
105 gl::ScopedBlendAlpha scopeAlphaBlend;
106 gl::ScopedState scopeCull( GL_CULL_FACE, true );
107 gl::multModelMatrix( translate( vec3( 0, 0, 1 ) ) );
108 gl::color( ColorA( 1.0f, 1.0f, 1.0f, .09f ) );
109
110 glCullFace( GL_FRONT );
111 gl::drawCube( vec3( 0, 0, 1), vec3( 1, 1, 1 ) );
112
113 glCullFace( GL_BACK );
114 gl::drawCube( vec3( 0, 0, 1), vec3( 1, 1, 1 ) );
115 }
116 }
117 // This scope closes so Stencil test will no longer be performed
118 // The below colorCube's rendering will be unaffected.
119 gl::color( ColorA( 1, 1, 1, 1 ) );
120 gl::drawColorCube( vec3( 0, 0, 1), vec3( 1, 1, 1 ) );
121 }
122}
123
124// Enabling stencil on the system framebuffer
125auto options = RendererGl::Options().msaa( 16 ).stencil();

Callers

nothing calls this directly

Calls 13

setMatricesFunction · 0.85
multModelMatrixFunction · 0.85
stencilFuncFunction · 0.85
stencilOpFunction · 0.85
stencilMaskFunction · 0.85
depthMaskFunction · 0.85
drawSolidRectFunction · 0.85
drawCubeFunction · 0.85
drawColorCubeFunction · 0.85
clearFunction · 0.50
translateFunction · 0.50
rotateFunction · 0.50

Tested by

no test coverage detected