Skip to content

Commit 9cb066d

Browse files
committed
refactor by add init_stencil()
1 parent de392cf commit 9cb066d

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

libopenage/presenter/presenter.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2024 the openage authors. See copying.md for legal info.
1+
// Copyright 2019-2025 the openage authors. See copying.md for legal info.
22

33
#include "presenter.h"
44

@@ -309,12 +309,15 @@ void Presenter::init_final_render_pass() {
309309
});
310310
}
311311

312-
void Presenter::enable_stencil_for_gui_mask() {
312+
void Presenter::init_stencil_test() {
313313
glEnable(GL_STENCIL_TEST);
314+
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
314315
glClear(GL_STENCIL_BUFFER_BIT);
316+
}
317+
318+
void Presenter::enable_stencil_for_gui_mask() {
315319
// Replace stencil value with 1 when depth test passes
316320
glStencilFunc(GL_ALWAYS, 1, 0xFF);
317-
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
318321
glStencilMask(0xFF);
319322
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
320323
}
@@ -338,6 +341,8 @@ void Presenter::render() {
338341
this->world_renderer->update();
339342
this->hud_renderer->update();
340343

344+
this->init_stencil_test();
345+
341346
// First Pass: Render GUI to stencil buffer
342347
this->enable_stencil_for_gui_mask();
343348
this->gui->render();

libopenage/presenter/presenter.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright 2019-2024 the openage authors. See copying.md for legal info.
1+
// Copyright 2019-2025 the openage authors. See copying.md for legal info.
22

33
#pragma once
44

@@ -142,6 +142,7 @@ class Presenter {
142142

143143
// void init_audio();
144144

145+
void init_stencil_test();
145146
void enable_stencil_for_gui_mask();
146147
void enable_stencil_for_world();
147148
void disable_stencil();

0 commit comments

Comments
 (0)