From 9842cb7f1c7e198d9a65fa4c7e91feefdf9fd627 Mon Sep 17 00:00:00 2001 From: rachytski Date: Sat, 8 Jan 2011 23:05:52 +0200 Subject: [PATCH] decreasing the size of drawPathText font size, to reduce the "text garbage" effect. --- map/drawer_yg.cpp | 17 +++++++------- map/framework.hpp | 9 ++++---- yg/defines.hpp | 7 ++++++ yg/gpu_state.hpp | 55 +++++++++++++++++++++++++++++++++++++++++++++ yg/renderbuffer.cpp | 2 +- yg/utils.cpp | 11 +++++---- yg/yg.pro | 4 +++- 7 files changed, 84 insertions(+), 21 deletions(-) create mode 100644 yg/defines.hpp create mode 100644 yg/gpu_state.hpp diff --git a/map/drawer_yg.cpp b/map/drawer_yg.cpp index d49cfb9584..9ab23633f4 100644 --- a/map/drawer_yg.cpp +++ b/map/drawer_yg.cpp @@ -1,9 +1,9 @@ #include "drawer_yg.hpp" - #include "../indexer/drawing_rules.hpp" #include "../indexer/scales.hpp" +#include "../yg/defines.hpp" #include "../yg/screen.hpp" #include "../yg/skin.hpp" #include "../yg/resource_manager.hpp" @@ -148,16 +148,15 @@ uint8_t DrawerYG::get_font_size(rule_ptr_t pRule) void DrawerYG::drawText(m2::PointD const & pt, string const & name, rule_ptr_t pRule, int /*depth*/) { - uint8_t fontSize = get_font_size(pRule); - if (fontSize > 3 * m_visualScale) - m_pScreen->drawText(pt, 0.0, fontSize, name, 10000); + uint8_t fontSize = max(get_font_size(pRule), (uint8_t)(yg::minTextSize * m_visualScale)); + m_pScreen->drawText(pt, 0.0, fontSize, name, yg::maxDepth); } void DrawerYG::drawPathText(vector const & pts, double pathLength, string const & name, rule_ptr_t pRule, int /*depth*/) { - uint8_t fontSize = get_font_size(pRule); - if (fontSize > 3 * m_visualScale) - m_pScreen->drawPathText(&pts[0], pts.size(), fontSize, name, pathLength, yg::gl::Screen::middle_line, true, 10000); + uint8_t fontSize = get_font_size(pRule) - 2; + if (fontSize >= yg::minTextSize * m_visualScale) + m_pScreen->drawPathText(&pts[0], pts.size(), fontSize, name, pathLength, yg::gl::Screen::middle_line, true, yg::maxDepth); } shared_ptr DrawerYG::screen() const @@ -251,9 +250,9 @@ void DrawerYG::drawStats(double duration, int scale, double lat, double lng) out << " FPS: inf"; else out << " FPS: " << 1.0 / duration; - m_pScreen->drawText(m2::PointD(10, 20), 0, 14, out.str().c_str(), 10000); + m_pScreen->drawText(m2::PointD(10, 20), 0, 14, out.str().c_str(), yg::maxDepth); out.str(""); out << "(" << lat << ", " << lng << ") Scale: " << scale; - m_pScreen->drawText(m2::PointD(10, 40), 0, 14, out.str().c_str(), 10000);*/ + m_pScreen->drawText(m2::PointD(10, 40), 0, 14, out.str().c_str(), yg::maxDepth);*/ } diff --git a/map/framework.hpp b/map/framework.hpp index 437219b2b0..913879c184 100644 --- a/map/framework.hpp +++ b/map/framework.hpp @@ -13,6 +13,7 @@ #include "../platform/platform.hpp" +#include "../yg/defines.hpp" #include "../yg/screen.hpp" #include "../yg/color.hpp" #include "../yg/render_state.hpp" @@ -343,7 +344,7 @@ public: m2::PointD ptShift = m_renderQueue.renderState().coordSystemShift(false); /// Drawing position and heading m2::PointD pxPosition = m_navigator.Screen().GtoP(m_position); - pDrawer->drawSymbol(pxPosition - ptShift, "current-position", 12000); + pDrawer->drawSymbol(pxPosition - ptShift, "current-position", yg::maxDepth); double pxConfidenceRadius = pxPosition.Length(m_navigator.Screen().GtoP(m_position + m2::PointD(m_confidenceRadius, 0))); @@ -374,14 +375,14 @@ public: &borderPts[0], borderPts.size(), pDrawer->screen()->skin()->mapPenInfo(yg::PenInfo(yg::Color(0, 0, 255, 64), 4, 0, 0, 0)), - 11999 + yg::maxDepth - 1 ); pDrawer->screen()->drawTriangles( &areaPts[0], areaPts.size(), pDrawer->screen()->skin()->mapColor(yg::Color(0, 0, 255, 32)), - 11998); + yg::maxDepth - 2); /* if (m_isHeadingEnabled) { @@ -397,7 +398,7 @@ public: pts, 2, pDrawer->screen()->skin()->mapPenInfo(yg::PenInfo(yg::Color(255, 0, 0, 255), 4, 0, 0, 0)), - 12000 + yg::maxDepth ); } */ diff --git a/yg/defines.hpp b/yg/defines.hpp new file mode 100644 index 0000000000..fa0badbd19 --- /dev/null +++ b/yg/defines.hpp @@ -0,0 +1,7 @@ +#pragma once + +namespace yg +{ + static const int maxDepth = 12000; + static const int minTextSize = 10; +} diff --git a/yg/gpu_state.hpp b/yg/gpu_state.hpp new file mode 100644 index 0000000000..5f4518c46f --- /dev/null +++ b/yg/gpu_state.hpp @@ -0,0 +1,55 @@ +#pragma once + +#include + +namespace yg +{ + namespace gl + { + struct ArrayParams + { + /// vertexArray params + bool m_enabled; + GLint m_size; + GLenum m_type; + GLsizei m_stride; + GLvoid * m_ptr; + }; + + class GPUState + { + private: + + int m_readFBO; + int m_drawFBO; + int m_fboColor0; + int m_fboDepth; + int m_fboStencil; + + int m_tex0; + int m_vb; + int m_ib; + + ArrayParams m_vertexAP; + ArrayParams m_colorAP; + ArrayParams m_texCoordAP; + + bool m_depthTest; + GLenum m_depthFunc; + + bool m_alphaTest; + GLenum m_alphaFunc; + GLclampf m_ref; + + bool m_alphaBlend; + GLenum m_srcFactor; + GLenum m_dstFactor; + + yg::Color m_color; + + public: + + + }; + } +} diff --git a/yg/renderbuffer.cpp b/yg/renderbuffer.cpp index e106fc0846..8818aa2180 100644 --- a/yg/renderbuffer.cpp +++ b/yg/renderbuffer.cpp @@ -53,7 +53,7 @@ namespace yg if (m_isMultiSampled) OGLCHECK(glRenderbufferStorageMultisampleAPPLE(target, - 4, + 2, internalFormat, width, height)); diff --git a/yg/utils.cpp b/yg/utils.cpp index 6969f0a085..e9bea083c8 100644 --- a/yg/utils.cpp +++ b/yg/utils.cpp @@ -1,5 +1,6 @@ #include "../base/SRC_FIRST.hpp" +#include "defines.hpp" #include "utils.hpp" #include "memento.hpp" #include "vertexbuffer.hpp" @@ -27,18 +28,16 @@ namespace yg OGLCHECK(glMatrixMode(GL_PROJECTION)); OGLCHECK(glLoadIdentity()); - int const bound = 12000; - #ifdef OMIM_GL_ES if (!doSwap) - OGLCHECK(glOrthof(0, width, 0, height, -bound, bound)); + OGLCHECK(glOrthof(0, width, 0, height, -yg::maxDepth, yg::maxDepth)); else - OGLCHECK(glOrthof(0, width, height, 0, -bound, bound)); + OGLCHECK(glOrthof(0, width, height, 0, -yg::maxDepth, yg::maxDepth)); #else if (!doSwap) - OGLCHECK(glOrtho(0, width, 0, height, -bound, bound)); + OGLCHECK(glOrtho(0, width, 0, height, -yg::maxDepth, yg::maxDepth)); else - OGLCHECK(glOrtho(0, width, height, 0, -bound, bound)); + OGLCHECK(glOrtho(0, width, height, 0, -yg::maxDepth, yg::maxDepth)); #endif } } diff --git a/yg/yg.pro b/yg/yg.pro index 9a2778d059..d1b80ca762 100644 --- a/yg/yg.pro +++ b/yg/yg.pro @@ -100,7 +100,9 @@ HEADERS += \ text_renderer.hpp \ geometry_batcher.hpp \ screen.hpp \ - layer_manager.hpp + layer_manager.hpp \ + gpu_state.hpp \ + defines.hpp !iphonesimulator-g++42 { !iphonedevice-g++42 {