@@ -319,6 +319,31 @@ void Presenter::init_final_render_pass() {
319
319
});
320
320
}
321
321
322
+ void Presenter::init_stencil_test () {
323
+ glEnable (GL_STENCIL_TEST);
324
+ glStencilOp (GL_KEEP, GL_KEEP, GL_REPLACE);
325
+ glClear (GL_STENCIL_BUFFER_BIT);
326
+ }
327
+
328
+ void Presenter::enable_stencil_for_gui_mask () {
329
+ // Replace stencil value with 1 when depth test passes
330
+ glStencilFunc (GL_ALWAYS, 1 , 0xFF );
331
+ glStencilMask (0xFF );
332
+ glColorMask (GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
333
+ }
334
+
335
+ void Presenter::enable_stencil_for_world () {
336
+ // Only pass if stencil value is not 1
337
+ glStencilFunc (GL_NOTEQUAL, 1 , 0xFF );
338
+ glStencilMask (0x00 );
339
+ glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
340
+ }
341
+
342
+ void Presenter::disable_stencil () {
343
+ glDisable (GL_STENCIL_TEST);
344
+ glColorMask (GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
345
+ }
346
+
322
347
void Presenter::render () {
323
348
// TODO: Pass current time to update() instead of fetching it in renderer
324
349
this ->camera_manager ->update ();
0 commit comments