From 73f20b9b9deb8b651f531b0272a21f35ea169858 Mon Sep 17 00:00:00 2001 From: XProger Date: Sun, 26 Aug 2018 21:27:26 +0300 Subject: [PATCH] fix RT flags for iOS --- src/cache.h | 17 ++++++++--------- src/level.h | 4 ++-- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/src/cache.h b/src/cache.h index 02cd94b..c7d24ae 100644 --- a/src/cache.h +++ b/src/cache.h @@ -792,9 +792,9 @@ struct WaterCache { } else x = y = 0; #ifdef _OS_IOS - Core::setTarget(refract, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); + Core::setTarget(refract, RT_LOAD_DEPTH | RT_STORE_COLOR | RT_STORE_DEPTH); blitTexture(screen); - Core::setTarget(screen, RT_LOAD_COLOR | RT_STORE_COLOR); + Core::setTarget(screen, RT_LOAD_COLOR | RT_LOAD_DEPTH | RT_STORE_COLOR); #else Core::copyTarget(refract, 0, 0, x, y, Core::viewportDef.width, Core::viewportDef.height); // copy framebuffer into refraction texture #endif @@ -934,15 +934,11 @@ struct WaterCache { void blitTexture(Texture *tex) { ASSERT(tex); - Core::setDepthTest(false); - Core::setBlendMode(bmNone); - game->setShader(Core::passGUI, Shader::DEFAULT); - Core::mView.identity(); - Core::mProj = GAPI::ortho(0.0f, float(tex->origWidth), 0.0f, float(tex->origHeight), 0.0f, 1.0f); - Core::setViewProj(Core::mView, Core::mProj); - Core::active.shader->setParam(uViewProj, Core::mViewProj); + mat4 mProj = GAPI::ortho(0.0f, float(tex->origWidth), 0.0f, float(tex->origHeight), 0.0f, 1.0f); + + Core::active.shader->setParam(uViewProj, mProj); Core::active.shader->setParam(uMaterial, vec4(1.0f)); tex->bind(0); @@ -964,6 +960,9 @@ struct WaterCache { vertices[2].texCoord = short4(32767, 0, 0, 0); vertices[3].texCoord = short4( 0, 0, 0, 0); + Core::setDepthTest(false); + Core::setBlendMode(bmNone); + game->getMesh()->renderBuffer(indices, COUNT(indices), vertices, COUNT(vertices)); Core::setDepthTest(true); diff --git a/src/level.h b/src/level.h index 4aabbd0..0e35327 100644 --- a/src/level.h +++ b/src/level.h @@ -2011,7 +2011,7 @@ struct Level : IGame { Texture *screen = NULL; if (water) { screen = (waterCache && waterCache->visible) ? waterCache->getScreenTex() : NULL; - Core::setTarget(screen, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); // render to screen texture (FUCK YOU iOS!) or back buffer + Core::setTarget(screen, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR | (screen ? RT_STORE_DEPTH : 0)); // render to screen texture (FUCK YOU iOS!) or back buffer setupBinding(); } @@ -2051,7 +2051,7 @@ struct Level : IGame { Core::Pass pass = Core::pass; if (water && waterCache && waterCache->visible && screen) { - Core::setTarget(NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); + Core::setTarget(NULL, RT_STORE_COLOR); waterCache->blitTexture(screen); }