Skip to content

Commit

Permalink
Add Depth Test to GL State Backup - GL3 Renderer (#629)
Browse files Browse the repository at this point in the history
Add enable_depth_test field to GLStateBackup - saved and restored in BeginFrame() and EndFrame()
  • Loading branch information
ben-metzger-z authored Jul 5, 2024
1 parent d2ce132 commit 09ddcf8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Backends/RmlUi_Renderer_GL3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,7 @@ void RenderInterface_GL3::BeginFrame()
glstate_backup.enable_blend = glIsEnabled(GL_BLEND);
glstate_backup.enable_stencil_test = glIsEnabled(GL_STENCIL_TEST);
glstate_backup.enable_scissor_test = glIsEnabled(GL_SCISSOR_TEST);
glstate_backup.enable_depth_test = glIsEnabled(GL_DEPTH_TEST);

glGetIntegerv(GL_VIEWPORT, glstate_backup.viewport);
glGetIntegerv(GL_SCISSOR_BOX, glstate_backup.scissor);
Expand Down Expand Up @@ -879,6 +880,8 @@ void RenderInterface_GL3::BeginFrame()
glStencilMask(GLuint(-1));
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);

glDisable(GL_DEPTH_TEST);

SetTransform(nullptr);

render_layers.BeginFrame(viewport_width, viewport_height);
Expand Down Expand Up @@ -936,6 +939,11 @@ void RenderInterface_GL3::EndFrame()
else
glDisable(GL_SCISSOR_TEST);

if(glstate_backup.enable_depth_test)
glEnable(GL_DEPTH_TEST);
else
glDisable(GL_DEPTH_TEST);

glViewport(glstate_backup.viewport[0], glstate_backup.viewport[1], glstate_backup.viewport[2], glstate_backup.viewport[3]);
glScissor(glstate_backup.scissor[0], glstate_backup.scissor[1], glstate_backup.scissor[2], glstate_backup.scissor[3]);

Expand Down
1 change: 1 addition & 0 deletions Backends/RmlUi_Renderer_GL3.h
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ class RenderInterface_GL3 : public Rml::RenderInterface {
bool enable_blend;
bool enable_stencil_test;
bool enable_scissor_test;
bool enable_depth_test;

int viewport[4];
int scissor[4];
Expand Down

0 comments on commit 09ddcf8

Please sign in to comment.