From 483212f382ac86e6396358f4015fe72f1b5d2b42 Mon Sep 17 00:00:00 2001 From: Sergey Lipskiy Date: Sat, 25 Feb 2017 20:36:41 +0700 Subject: [PATCH] Correct special drawers. --- .../GLSL/glsl_SpecialShadersFactory.cpp | 2 ++ src/TexrectDrawer.cpp | 25 ++++++++++--------- src/TextDrawer.cpp | 12 ++++----- 3 files changed, 21 insertions(+), 18 deletions(-) diff --git a/src/Graphics/OpenGLContext/GLSL/glsl_SpecialShadersFactory.cpp b/src/Graphics/OpenGLContext/GLSL/glsl_SpecialShadersFactory.cpp index bb8d68ce..cb304d48 100644 --- a/src/Graphics/OpenGLContext/GLSL/glsl_SpecialShadersFactory.cpp +++ b/src/Graphics/OpenGLContext/GLSL/glsl_SpecialShadersFactory.cpp @@ -25,6 +25,7 @@ namespace glsl { "void main() \n" "{ \n" " gl_Position = aRectPosition; \n" + " gl_Position.y = -gl_Position.y; \n" "} \n" ; } @@ -42,6 +43,7 @@ namespace glsl { "void main() \n" "{ \n" " gl_Position = aRectPosition; \n" + " gl_Position.y = -gl_Position.y;\n" " vTexCoord0 = aTexCoord0; \n" "} \n" ; diff --git a/src/TexrectDrawer.cpp b/src/TexrectDrawer.cpp index 2eff64bb..107d8b83 100644 --- a/src/TexrectDrawer.cpp +++ b/src/TexrectDrawer.cpp @@ -171,13 +171,6 @@ void TexrectDrawer::add() m_max_lry = std::max(m_max_lry, m_lry); } - Context::DrawRectParameters rectParams; - rectParams.mode = drawmode::TRIANGLE_STRIP; - rectParams.verticesCount = 4; - rectParams.vertices = pRect; - rectParams.combiner = currentCombiner(); - gfxContext.drawRects(rectParams); - RectCoords coords; coords.x = pRect[1].x; coords.y = pRect[1].y; @@ -185,8 +178,16 @@ void TexrectDrawer::add() coords.x = pRect[3].x; coords.y = pRect[3].y; m_vecRectCoords.push_back(coords); - ++m_numRects; + + for (u32 i = 0; i < 4; ++i) + pRect[i].y = -pRect[i].y; + Context::DrawRectParameters rectParams; + rectParams.mode = drawmode::TRIANGLE_STRIP; + rectParams.verticesCount = 4; + rectParams.vertices = pRect; + rectParams.combiner = currentCombiner(); + gfxContext.drawRects(rectParams); } bool TexrectDrawer::draw() @@ -293,10 +294,10 @@ bool TexrectDrawer::draw() gfxContext.bindFramebuffer(bufferTarget::DRAW_FRAMEBUFFER, m_FBO); m_programClear->activate(); - rect[0].y = m_uly; - rect[1].y = m_uly; - rect[2].y = m_lry; - rect[3].y = m_lry; + rect[0].y = -m_uly; + rect[1].y = -m_uly; + rect[2].y = -m_lry; + rect[3].y = -m_lry; if (m_pBuffer == nullptr) gfxContext.setViewport(0, 0, VI.width, VI.height); diff --git a/src/TextDrawer.cpp b/src/TextDrawer.cpp index 1d26893c..976a0f2b 100644 --- a/src/TextDrawer.cpp +++ b/src/TextDrawer.cpp @@ -288,37 +288,37 @@ void TextDrawer::drawText(const char *_pText, float _x, float _y) const continue; rect.x = x2; - rect.y = -y2; + rect.y = y2; rect.s0 = m_atlas->c[*p].tx; rect.t0 = m_atlas->c[*p].ty; coords.push_back(rect); rect.x = x2 + w; - rect.y = -y2; + rect.y = y2; rect.s0 = m_atlas->c[*p].tx + m_atlas->c[*p].bw / m_atlas->w; rect.t0 = m_atlas->c[*p].ty; coords.push_back(rect); rect.x = x2; - rect.y = -y2 - h; + rect.y = y2 + h; rect.s0 = m_atlas->c[*p].tx; rect.t0 = m_atlas->c[*p].ty + m_atlas->c[*p].bh / m_atlas->h; coords.push_back(rect); rect.x = x2 + w; - rect.y = -y2; + rect.y = y2; rect.s0 = m_atlas->c[*p].tx + m_atlas->c[*p].bw / m_atlas->w; rect.t0 = m_atlas->c[*p].ty; coords.push_back(rect); rect.x = x2; - rect.y = -y2 - h; + rect.y = y2 + h; rect.s0 = m_atlas->c[*p].tx; rect.t0 = m_atlas->c[*p].ty + m_atlas->c[*p].bh / m_atlas->h; coords.push_back(rect); rect.x = x2 + w; - rect.y = -y2 - h; + rect.y = y2 + h; rect.s0 = m_atlas->c[*p].tx + m_atlas->c[*p].bw / m_atlas->w; rect.t0 = m_atlas->c[*p].ty + m_atlas->c[*p].bh / m_atlas->h; coords.push_back(rect);