From 1f8ba128d4ce5a820e0703f312cc89a8edc19dfd Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Mon, 24 Sep 2012 06:42:47 +0000 Subject: [PATCH] core: fix sorting of 2D scenes. --- src/scene.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/scene.cpp b/src/scene.cpp index 59ac1762..1d588389 100644 --- a/src/scene.cpp +++ b/src/scene.cpp @@ -50,7 +50,11 @@ private: Tile const *t1 = (Tile const *)p1; Tile const *t2 = (Tile const *)p2; - return t2->prio - t1->prio; + if (t1->pos.z > t2->pos.z) + return 1; + if (t1->pos.z < t2->pos.z) + return -1; + return 0; } mat4 m_model_matrix; @@ -176,6 +180,11 @@ void Scene::Render() // XXX: rename to Blit() data->m_model_matrix *= mat4::rotate(17.0f * cosf(f), 0.0f, 0.0f, 1.0f); #endif data->m_model_matrix *= mat4::translate(-320.0f, -240.0f, 0.0f); +#if __ANDROID__ + data->m_model_matrix = mat4::scale(1280.0f / 640, + 736.0f / 480, + 1.0f) * data->m_model_matrix; +#endif // XXX: end of debug stuff ShaderUniform uni_mat, uni_tex;