drawRectangle, addTexturedStrip implementation.

This commit is contained in:
rachytski 2011-03-07 21:10:05 +02:00 committed by Alex Zolotarev
parent 758a3b3748
commit c6f83b6bd2
6 changed files with 72 additions and 8 deletions

View file

@ -312,7 +312,25 @@ namespace yg
m_pipelines[pageID].m_currentIndex += (size - 2) * 3;
}
void GeometryBatcher::addTexturedStrip(m2::PointF const * coords, m2::PointF const * texCoords, unsigned size, double depth, int pageID)
void GeometryBatcher::addTexturedStrip(
m2::PointF const * coords,
m2::PointF const * texCoords,
unsigned size,
double depth,
int pageID
)
{
addTexturedStripStrided(coords, sizeof(m2::PointF), texCoords, sizeof(m2::PointF), size, depth, pageID);
}
void GeometryBatcher::addTexturedStripStrided(
m2::PointF const * coords,
size_t coordsStride,
m2::PointF const * texCoords,
size_t texCoordsStride,
unsigned size,
double depth,
int pageID)
{
if (!hasRoom(size, (size - 2) * 3, pageID))
flush(pageID);
@ -324,9 +342,11 @@ namespace yg
for (unsigned i = 0; i < size; ++i)
{
m_pipelines[pageID].m_vertices[vOffset + i].pt = coords[i];
m_pipelines[pageID].m_vertices[vOffset + i].tex = texCoords[i];
m_pipelines[pageID].m_vertices[vOffset + i].pt = *coords;
m_pipelines[pageID].m_vertices[vOffset + i].tex = *texCoords;
m_pipelines[pageID].m_vertices[vOffset + i].depth = depth;
coords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(coords) + coordsStride);
texCoords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(texCoords) + texCoordsStride);
}
m_pipelines[pageID].m_currentVertex += size;

View file

@ -125,6 +125,14 @@ namespace yg
double depth,
int pageID);
void addTexturedStripStrided(m2::PointF const * coords,
size_t coordsStride,
m2::PointF const * texCoords,
size_t texCoordsStride,
unsigned size,
double depth,
int pageID);
void addTexturedStrip(m2::PointF const * coords,
m2::PointF const * texCoords,
unsigned size,

View file

@ -2,6 +2,8 @@
#include "shape_renderer.hpp"
#include "skin.hpp"
#include "../base/logging.hpp"
namespace yg
{
namespace gl
@ -65,5 +67,34 @@ namespace yg
drawTrianglesList(&sectorPts[0], sectorPts.size(), skin()->mapColor(c), depth);
}
void ShapeRenderer::drawRectangle(m2::RectD const & r, yg::Color const & c, double depth)
{
ResourceStyle const * style = skin()->fromID(skin()->mapColor(c));
if (style == 0)
{
LOG(LINFO, ("cannot map color"));
return;
}
m2::PointF rectPts[4] = {
m2::PointF(r.minX(), r.minY()),
m2::PointF(r.maxX(), r.minY()),
m2::PointF(r.minX(), r.maxY()),
m2::PointD(r.maxX(), r.maxY())
};
m2::PointF texPt = style->m_texRect.Center();
addTexturedStripStrided(
rectPts,
sizeof(m2::PointF),
&texPt,
0,
4,
depth,
style->m_pageID
);
}
}
}

View file

@ -18,6 +18,8 @@ namespace yg
void drawArc(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth);
void drawSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth);
void fillSector(m2::PointD const & center, double startA, double endA, double r, yg::Color const & c, double depth);
void drawRectangle(m2::RectD const & r, yg::Color const & c, double depth);
};
}
}

View file

@ -238,9 +238,12 @@ namespace yg
{
uint32_t glyphID = skin()->mapGlyph(GlyphKey(text[i], fontSize, false, yg::Color(0, 0, 0, 0)), fixedFont);
CharStyle const * p = static_cast<CharStyle const *>(skin()->fromID(glyphID));
rect.Add(pt);
rect.Add(pt + m2::PointD(p->m_xOffset + p->m_texRect.SizeX() - 4, -p->m_yOffset - (int)p->m_texRect.SizeY() + 4));
pt += m2::PointD(p->m_xAdvance, 0);
if (p != 0)
{
rect.Add(pt);
rect.Add(pt + m2::PointD(p->m_xOffset + p->m_texRect.SizeX() - 4, -p->m_yOffset - (int)p->m_texRect.SizeY() + 4));
pt += m2::PointD(p->m_xAdvance, 0);
}
}
else
{

View file

@ -96,7 +96,7 @@ namespace yg
Traits::gl_pixel_format_type,
Traits::gl_pixel_data_type,
&gil::view(image)(0, 0)));
// boost::gil::lodepng_write_view(fullPath.c_str(), gil::view(image));
boost::gil::lodepng_write_view(fullPath.c_str(), gil::view(image));
#endif
@ -274,7 +274,7 @@ namespace yg
readback();
std::string const fullPath = GetPlatform().WritablePathForFile(fileName);
#ifndef OMIM_GL_ES
// boost::gil::lodepng_write_view(fullPath.c_str(), view(width(), height()));
boost::gil::lodepng_write_view(fullPath.c_str(), view(width(), height()));
#endif
unlock();
}