diff --git a/engine/joint/v4k.h b/engine/joint/v4k.h index 4104621..96f731c 100644 --- a/engine/joint/v4k.h +++ b/engine/joint/v4k.h @@ -372685,6 +372685,8 @@ bool postfx_begin(postfx *fx, int width, int height) { return true; } +static renderstate_t postfx_rs; + bool postfx_end(postfx *fx) { uint64_t num_active_passes = postfx_active_passes(fx); bool active = fx->enabled && num_active_passes; @@ -372692,12 +372694,16 @@ bool postfx_end(postfx *fx) { return false; } + do_once { + postfx_rs = renderstate(); + // disable depth test in 2d rendering + postfx_rs.depth_test_enabled = 0; + } + // unbind postfx fbo fbo_unbind(); - // disable depth test in 2d rendering - bool is_depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); - glDisable(GL_DEPTH_TEST); + renderstate_apply(&postfx_rs); int frame = 0; float t = time_ms() / 1000.f; @@ -372751,9 +372757,6 @@ bool postfx_end(postfx *fx) { } glUseProgram(0); - if(is_depth_test_enabled); - glEnable(GL_DEPTH_TEST); - // restore clear color: needed in case transparent window is being used (alpha != 0) glClearColor(0,0,0,1); // @transparent diff --git a/engine/split/v4k_render.c b/engine/split/v4k_render.c index 4a9df47..0c501c0 100644 --- a/engine/split/v4k_render.c +++ b/engine/split/v4k_render.c @@ -2610,6 +2610,8 @@ bool postfx_begin(postfx *fx, int width, int height) { return true; } +static renderstate_t postfx_rs; + bool postfx_end(postfx *fx) { uint64_t num_active_passes = postfx_active_passes(fx); bool active = fx->enabled && num_active_passes; @@ -2617,12 +2619,16 @@ bool postfx_end(postfx *fx) { return false; } + do_once { + postfx_rs = renderstate(); + // disable depth test in 2d rendering + postfx_rs.depth_test_enabled = 0; + } + // unbind postfx fbo fbo_unbind(); - // disable depth test in 2d rendering - bool is_depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); - glDisable(GL_DEPTH_TEST); + renderstate_apply(&postfx_rs); int frame = 0; float t = time_ms() / 1000.f; @@ -2676,9 +2682,6 @@ bool postfx_end(postfx *fx) { } glUseProgram(0); - if(is_depth_test_enabled); - glEnable(GL_DEPTH_TEST); - // restore clear color: needed in case transparent window is being used (alpha != 0) glClearColor(0,0,0,1); // @transparent diff --git a/engine/v4k.c b/engine/v4k.c index d225cd1..2898710 100644 --- a/engine/v4k.c +++ b/engine/v4k.c @@ -19777,6 +19777,8 @@ bool postfx_begin(postfx *fx, int width, int height) { return true; } +static renderstate_t postfx_rs; + bool postfx_end(postfx *fx) { uint64_t num_active_passes = postfx_active_passes(fx); bool active = fx->enabled && num_active_passes; @@ -19784,12 +19786,16 @@ bool postfx_end(postfx *fx) { return false; } + do_once { + postfx_rs = renderstate(); + // disable depth test in 2d rendering + postfx_rs.depth_test_enabled = 0; + } + // unbind postfx fbo fbo_unbind(); - // disable depth test in 2d rendering - bool is_depth_test_enabled = glIsEnabled(GL_DEPTH_TEST); - glDisable(GL_DEPTH_TEST); + renderstate_apply(&postfx_rs); int frame = 0; float t = time_ms() / 1000.f; @@ -19843,9 +19849,6 @@ bool postfx_end(postfx *fx) { } glUseProgram(0); - if(is_depth_test_enabled); - glEnable(GL_DEPTH_TEST); - // restore clear color: needed in case transparent window is being used (alpha != 0) glClearColor(0,0,0,1); // @transparent