Skip to content

Commit d63438c

Browse files
committed
merge branch
2 parents 18622d4 + 9cb066d commit d63438c

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

libopenage/presenter/presenter.cpp

+25
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,31 @@ void Presenter::init_final_render_pass() {
319319
});
320320
}
321321

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+
322347
void Presenter::render() {
323348
// TODO: Pass current time to update() instead of fetching it in renderer
324349
this->camera_manager->update();

0 commit comments

Comments
 (0)