From 0fd4f75cbc8067251bfc6b48dea339836ea82d99 Mon Sep 17 00:00:00 2001 From: Timur Gagiev Date: Sun, 26 Aug 2018 20:59:22 +0300 Subject: [PATCH] iOS copy framebuffer --- src/cache.h | 19 ++++++++++++------- src/level.h | 2 +- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/cache.h b/src/cache.h index 62ac910..02cd94b 100644 --- a/src/cache.h +++ b/src/cache.h @@ -791,8 +791,13 @@ struct WaterCache { y = Core::viewportDef.y; } else x = y = 0; - + #ifdef _OS_IOS + Core::setTarget(refract, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); + blitTexture(screen); + Core::setTarget(screen, RT_LOAD_COLOR | RT_STORE_COLOR); + #else Core::copyTarget(refract, 0, 0, x, y, Core::viewportDef.width, Core::viewportDef.height); // copy framebuffer into refraction texture + #endif } void simulate() { @@ -926,8 +931,8 @@ struct WaterCache { dropCount = 0; } - void blitScreen() { - ASSERT(screen); + void blitTexture(Texture *tex) { + ASSERT(tex); Core::setDepthTest(false); Core::setBlendMode(bmNone); @@ -935,14 +940,14 @@ struct WaterCache { game->setShader(Core::passGUI, Shader::DEFAULT); Core::mView.identity(); - Core::mProj = GAPI::ortho(0.0f, float(screen->origWidth), 0.0f, float(screen->origHeight), 0.0f, 1.0f); + 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); Core::active.shader->setParam(uMaterial, vec4(1.0f)); - screen->bind(0); - int w = screen->width; - int h = screen->height; + tex->bind(0); + int w = tex->width; + int h = tex->height; Index indices[6] = { 0, 1, 2, 0, 2, 3 }; Vertex vertices[4]; diff --git a/src/level.h b/src/level.h index 62bdcb0..4aabbd0 100644 --- a/src/level.h +++ b/src/level.h @@ -2052,7 +2052,7 @@ struct Level : IGame { if (water && waterCache && waterCache->visible && screen) { Core::setTarget(NULL, RT_CLEAR_COLOR | RT_CLEAR_DEPTH | RT_STORE_COLOR); - waterCache->blitScreen(); + waterCache->blitTexture(screen); } if (showUI)