forked from organicmaps/organicmaps
prototype support for shader-performed text rotation.
This commit is contained in:
parent
de0d2d236a
commit
736defcc69
19 changed files with 283 additions and 37 deletions
|
@ -12,7 +12,7 @@
|
|||
|
||||
TilingRenderPolicyST::TilingRenderPolicyST(Params const & p)
|
||||
: BasicTilingRenderPolicy(p,
|
||||
false,
|
||||
true,
|
||||
true)
|
||||
{
|
||||
int cpuCores = GetPlatform().CpuCores();
|
||||
|
|
|
@ -93,7 +93,14 @@ namespace yg
|
|||
bool needToFlush = (batchSize < pointsLeft);
|
||||
|
||||
m2::PointF texCoord(texX, texY);
|
||||
addTexturedListStrided(&points[batchOffset], sizeof(m2::PointD), &texCoord, 0, batchSize, depth, style->m_pipelineID);
|
||||
m2::PointF normal(0, 0);
|
||||
|
||||
addTexturedListStrided(&points[batchOffset], sizeof(m2::PointD),
|
||||
&normal, 0,
|
||||
&texCoord, 0,
|
||||
batchSize,
|
||||
depth,
|
||||
style->m_pipelineID);
|
||||
|
||||
batchOffset += batchSize;
|
||||
pointsLeft -= batchSize;
|
||||
|
|
|
@ -134,6 +134,8 @@ namespace yg
|
|||
pointsData[i].depth = yg::maxDepth;
|
||||
pointsData[i].tex.x = texPts[i].x;
|
||||
pointsData[i].tex.y = texPts[i].y;
|
||||
pointsData[i].normal.x = 0;
|
||||
pointsData[i].normal.y = 0;
|
||||
// pointsData[i].color = yg::Color(255, 255, 255, 255);
|
||||
}
|
||||
|
||||
|
@ -317,6 +319,8 @@ namespace yg
|
|||
pointsData[i].depth = yg::maxDepth;
|
||||
pointsData[i].tex.x = m_texPts[i].x;
|
||||
pointsData[i].tex.y = m_texPts[i].y;
|
||||
pointsData[i].normal.x = 0;
|
||||
pointsData[i].normal.y = 0;
|
||||
}
|
||||
|
||||
blitStorage.m_vertices->unlock();
|
||||
|
|
|
@ -472,20 +472,94 @@ namespace yg
|
|||
m2::PointF(texMaxX, texMinY)
|
||||
};
|
||||
|
||||
addTexturedFan(coords, texCoords, 4, depth, pipelineID);
|
||||
m2::PointF normal(0, 0);
|
||||
|
||||
addTexturedFanStrided(coords, sizeof(m2::PointF),
|
||||
&normal, 0,
|
||||
texCoords, sizeof(m2::PointF),
|
||||
4,
|
||||
depth,
|
||||
pipelineID);
|
||||
}
|
||||
|
||||
void GeometryBatcher::drawStraightTexturedPolygon(
|
||||
m2::PointD const & ptPivot,
|
||||
float tx0, float ty0, float tx1, float ty1,
|
||||
float x0, float y0, float x1, float y1,
|
||||
double depth,
|
||||
int pipelineID)
|
||||
{
|
||||
if (!hasRoom(4, 6, pipelineID))
|
||||
flush(pipelineID);
|
||||
|
||||
m_pipelines[pipelineID].checkStorage(resourceManager());
|
||||
if (!m_pipelines[pipelineID].m_hasStorage)
|
||||
return;
|
||||
|
||||
float texMinX = tx0;
|
||||
float texMaxX = tx1;
|
||||
float texMinY = ty0;
|
||||
float texMaxY = ty1;
|
||||
|
||||
shared_ptr<BaseTexture> const & texture = m_skin->getPage(pipelineID)->texture();
|
||||
|
||||
if (!texture)
|
||||
{
|
||||
LOG(LDEBUG, ("returning as no texture is reserved"));
|
||||
return;
|
||||
}
|
||||
|
||||
texture->mapPixel(texMinX, texMinY);
|
||||
texture->mapPixel(texMaxX, texMaxY);
|
||||
|
||||
/// rotated and translated four points (x0, y0), (x0, y1), (x1, y1), (x1, y0)
|
||||
|
||||
m2::PointF offsets[4] =
|
||||
{
|
||||
m2::PointF(x0, y0),
|
||||
m2::PointF(x0, y1),
|
||||
m2::PointF(x1, y1),
|
||||
m2::PointF(x1, y0)
|
||||
};
|
||||
|
||||
m2::PointF texCoords[4] =
|
||||
{
|
||||
m2::PointF(texMinX, texMinY),
|
||||
m2::PointF(texMinX, texMaxY),
|
||||
m2::PointF(texMaxX, texMaxY),
|
||||
m2::PointF(texMaxX, texMinY)
|
||||
};
|
||||
|
||||
m2::PointF pv(ptPivot.x, ptPivot.y);
|
||||
|
||||
addTexturedFanStrided(&pv, 0,
|
||||
offsets, sizeof(m2::PointF),
|
||||
texCoords, sizeof(m2::PointF),
|
||||
4,
|
||||
depth,
|
||||
pipelineID);
|
||||
}
|
||||
|
||||
|
||||
void GeometryBatcher::addTexturedFan(m2::PointF const * coords,
|
||||
m2::PointF const * normals,
|
||||
m2::PointF const * texCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID)
|
||||
{
|
||||
addTexturedFanStrided(coords, sizeof(m2::PointF), texCoords, sizeof(m2::PointF), size, depth, pipelineID);
|
||||
addTexturedFanStrided(coords, sizeof(m2::PointF),
|
||||
normals, sizeof(m2::PointF),
|
||||
texCoords, sizeof(m2::PointF),
|
||||
size,
|
||||
depth,
|
||||
pipelineID);
|
||||
}
|
||||
|
||||
void GeometryBatcher::addTexturedFanStrided(m2::PointF const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
|
@ -509,9 +583,11 @@ namespace yg
|
|||
for (unsigned i = 0; i < size; ++i)
|
||||
{
|
||||
pipeline.m_vertices[vOffset + i].pt = *coords;
|
||||
pipeline.m_vertices[vOffset + i].normal = *normals;
|
||||
pipeline.m_vertices[vOffset + i].tex = *texCoords;
|
||||
pipeline.m_vertices[vOffset + i].depth = depth;
|
||||
coords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(coords) + coordsStride);
|
||||
normals = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(normals) + normalsStride);
|
||||
texCoords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(texCoords) + texCoordsStride);
|
||||
}
|
||||
|
||||
|
@ -529,18 +605,26 @@ namespace yg
|
|||
|
||||
void GeometryBatcher::addTexturedStrip(
|
||||
m2::PointF const * coords,
|
||||
m2::PointF const * normals,
|
||||
m2::PointF const * texCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID
|
||||
)
|
||||
{
|
||||
addTexturedStripStrided(coords, sizeof(m2::PointF), texCoords, sizeof(m2::PointF), size, depth, pipelineID);
|
||||
addTexturedStripStrided(coords, sizeof(m2::PointF),
|
||||
normals, sizeof(m2::PointF),
|
||||
texCoords, sizeof(m2::PointF),
|
||||
size,
|
||||
depth,
|
||||
pipelineID);
|
||||
}
|
||||
|
||||
void GeometryBatcher::addTexturedStripStrided(
|
||||
m2::PointF const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
|
@ -564,9 +648,11 @@ namespace yg
|
|||
for (unsigned i = 0; i < size; ++i)
|
||||
{
|
||||
pipeline.m_vertices[vOffset + i].pt = *coords;
|
||||
pipeline.m_vertices[vOffset + i].normal = *normals;
|
||||
pipeline.m_vertices[vOffset + i].tex = *texCoords;
|
||||
pipeline.m_vertices[vOffset + i].depth = depth;
|
||||
coords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(coords) + coordsStride);
|
||||
normals = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(normals) + normalsStride);
|
||||
texCoords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(texCoords) + texCoordsStride);
|
||||
}
|
||||
|
||||
|
@ -591,6 +677,8 @@ namespace yg
|
|||
void GeometryBatcher::addTexturedListStrided(
|
||||
m2::PointD const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
|
@ -614,9 +702,11 @@ namespace yg
|
|||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
pipeline.m_vertices[vOffset + i].pt = m2::PointF(coords->x, coords->y);
|
||||
pipeline.m_vertices[vOffset + i].normal = *normals;
|
||||
pipeline.m_vertices[vOffset + i].tex = *texCoords;
|
||||
pipeline.m_vertices[vOffset + i].depth = depth;
|
||||
coords = reinterpret_cast<m2::PointD const*>(reinterpret_cast<unsigned char const*>(coords) + coordsStride);
|
||||
normals = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(normals) + normalsStride);
|
||||
texCoords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(texCoords) + texCoordsStride);
|
||||
}
|
||||
|
||||
|
@ -632,6 +722,8 @@ namespace yg
|
|||
void GeometryBatcher::addTexturedListStrided(
|
||||
m2::PointF const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
|
@ -655,9 +747,11 @@ namespace yg
|
|||
for (size_t i = 0; i < size; ++i)
|
||||
{
|
||||
pipeline.m_vertices[vOffset + i].pt = *coords;
|
||||
pipeline.m_vertices[vOffset + i].normal = *normals;
|
||||
pipeline.m_vertices[vOffset + i].tex = *texCoords;
|
||||
pipeline.m_vertices[vOffset + i].depth = depth;
|
||||
coords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(coords) + coordsStride);
|
||||
normals = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(normals) + normalsStride);
|
||||
texCoords = reinterpret_cast<m2::PointF const*>(reinterpret_cast<unsigned char const*>(texCoords) + texCoordsStride);
|
||||
}
|
||||
|
||||
|
@ -669,9 +763,17 @@ namespace yg
|
|||
pipeline.m_currentIndex += size;
|
||||
}
|
||||
|
||||
void GeometryBatcher::addTexturedList(m2::PointF const * coords, m2::PointF const * texCoords, unsigned size, double depth, int pipelineID)
|
||||
void GeometryBatcher::addTexturedList(m2::PointF const * coords,
|
||||
m2::PointF const * normals,
|
||||
m2::PointF const * texCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID)
|
||||
{
|
||||
addTexturedListStrided(coords, sizeof(m2::PointF), texCoords, sizeof(m2::PointF), size, depth, pipelineID);
|
||||
addTexturedListStrided(coords, sizeof(m2::PointF),
|
||||
normals, sizeof(m2::PointF),
|
||||
texCoords, sizeof(m2::PointF),
|
||||
size, depth, pipelineID);
|
||||
}
|
||||
|
||||
void GeometryBatcher::enableClipRect(bool flag)
|
||||
|
|
|
@ -127,6 +127,7 @@ namespace yg
|
|||
void setRenderTarget(shared_ptr<RenderTarget> const & rt);
|
||||
|
||||
void addTexturedFan(m2::PointF const * coords,
|
||||
m2::PointF const * normals,
|
||||
m2::PointF const * texCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
|
@ -134,28 +135,42 @@ namespace yg
|
|||
|
||||
void addTexturedFanStrided(m2::PointF const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
|
||||
void addTexturedStrip(m2::PointF const * coords,
|
||||
m2::PointF const * normals,
|
||||
m2::PointF const * texCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
|
||||
void addTexturedStripStrided(m2::PointF const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
|
||||
void addTexturedStrip(m2::PointF const * coords,
|
||||
m2::PointF const * texCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
void addTexturedList(m2::PointF const * coords,
|
||||
m2::PointF const * texCoords,
|
||||
m2::PointF const * normalCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
|
||||
void addTexturedListStrided(m2::PointD const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
|
@ -164,20 +179,23 @@ namespace yg
|
|||
|
||||
void addTexturedListStrided(m2::PointF const * coords,
|
||||
size_t coordsStride,
|
||||
m2::PointF const * normals,
|
||||
size_t normalsStride,
|
||||
m2::PointF const * texCoords,
|
||||
size_t texCoordsStride,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
|
||||
void addTexturedList(m2::PointF const * coords,
|
||||
m2::PointF const * texCoords,
|
||||
unsigned size,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
|
||||
int aaShift() const;
|
||||
|
||||
void drawStraightTexturedPolygon(
|
||||
m2::PointD const & ptPivot,
|
||||
float tx0, float ty0, float tx1, float ty1,
|
||||
float x0, float y0, float x1, float y1,
|
||||
double depth,
|
||||
int pipelineID);
|
||||
|
||||
/// drawing textured polygon with antialiasing
|
||||
/// we assume that the (tx0, ty0, tx1, ty1) area on texture is surrounded by (0, 0, 0, 0) pixels,
|
||||
/// and the 1px interior area is also (0, 0, 0, 0).
|
||||
|
|
|
@ -63,6 +63,7 @@ namespace yg
|
|||
|
||||
void (OPENGL_CALLING_CONVENTION * glEnableClientStateFn) (GLenum array);
|
||||
void (OPENGL_CALLING_CONVENTION * glVertexPointerFn) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
void (OPENGL_CALLING_CONVENTION * glNormalPointerFn) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
void (OPENGL_CALLING_CONVENTION * glTexCoordPointerFn) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
|
||||
void (OPENGL_CALLING_CONVENTION * glMatrixModeFn) (GLenum mode);
|
||||
|
|
|
@ -74,10 +74,12 @@ namespace yg
|
|||
extern void (OPENGL_CALLING_CONVENTION * glAlphaFuncFn)(GLenum func, GLclampf ref);
|
||||
extern void (OPENGL_CALLING_CONVENTION * glEnableClientStateFn) (GLenum array);
|
||||
extern void (OPENGL_CALLING_CONVENTION * glVertexPointerFn) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
extern void (OPENGL_CALLING_CONVENTION * glNormalPointerFn) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
extern void (OPENGL_CALLING_CONVENTION * glTexCoordPointerFn) (GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
|
||||
extern const GLenum GL_VERTEX_ARRAY_MWM;
|
||||
extern const GLenum GL_TEXTURE_COORD_ARRAY_MWM;
|
||||
extern const GLenum GL_NORMAL_ARRAY_MWM;
|
||||
|
||||
extern void (OPENGL_CALLING_CONVENTION * glMatrixModeFn) (GLenum mode);
|
||||
extern void (OPENGL_CALLING_CONVENTION * glLoadIdentityFn)();
|
||||
|
|
|
@ -43,6 +43,7 @@ namespace yg
|
|||
|
||||
glVertexPointerFn = &glsl::glVertexPointer;
|
||||
glTexCoordPointerFn = &glsl::glTexCoordPointer;
|
||||
glNormalPointerFn = &glsl::glNormalPointer;
|
||||
glEnableClientStateFn = &glsl::glEnableClientState;
|
||||
|
||||
glMatrixModeFn = &glsl::glMatrixMode;
|
||||
|
|
|
@ -36,6 +36,7 @@ namespace yg
|
|||
glAlphaFuncFn = &glsl::glAlphaFunc;
|
||||
|
||||
glVertexPointerFn = &glsl::glVertexPointer;
|
||||
glNormalPointerFn = &glsl::glNormalPointer;
|
||||
glTexCoordPointerFn = &glsl::glTexCoordPointer;
|
||||
glEnableClientStateFn = &glsl::glEnableClientState;
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ namespace yg
|
|||
|
||||
const GLenum GL_VERTEX_ARRAY_MWM = 0;
|
||||
const GLenum GL_TEXTURE_COORD_ARRAY_MWM = 1;
|
||||
const GLenum GL_NORMAL_ARRAY_MWM = 2;
|
||||
|
||||
const GLenum GL_ALPHA_TEST_MWM = 0x0BC0;
|
||||
|
||||
|
@ -31,12 +32,13 @@ namespace yg
|
|||
|
||||
static const char g_vxSrc[] =
|
||||
"attribute vec4 Position;\n"
|
||||
"attribute vec2 Normal;\n"
|
||||
"attribute vec2 TexCoordIn;\n"
|
||||
"uniform mat4 ProjM;\n"
|
||||
"uniform mat4 ModelViewM;\n"
|
||||
"varying vec2 TexCoordOut;\n"
|
||||
"void main(void) {\n"
|
||||
" gl_Position = Position * ModelViewM * ProjM;\n"
|
||||
" gl_Position = floor(vec4(Normal, 0.0, 0.0) + Position * ModelViewM) * ProjM;\n"
|
||||
" TexCoordOut = TexCoordIn;\n"
|
||||
"}\n";
|
||||
|
||||
|
@ -67,6 +69,7 @@ namespace yg
|
|||
GLuint m_program;
|
||||
GLuint m_positionHandle;
|
||||
GLuint m_texCoordHandle;
|
||||
GLuint m_normalHandle;
|
||||
GLuint m_projectionUniform;
|
||||
GLuint m_modelViewUniform;
|
||||
GLuint m_textureUniform;
|
||||
|
@ -123,6 +126,12 @@ namespace yg
|
|||
OGLCHECKAFTER;
|
||||
}
|
||||
|
||||
void attachNormal(char const * name)
|
||||
{
|
||||
m_normalHandle = ::glGetAttribLocation(m_program, name);
|
||||
OGLCHECKAFTER;
|
||||
}
|
||||
|
||||
void attachPosition(char const * name)
|
||||
{
|
||||
m_positionHandle = ::glGetAttribLocation(m_program, name);
|
||||
|
@ -131,7 +140,7 @@ namespace yg
|
|||
|
||||
void attachTexCoord(char const * name)
|
||||
{
|
||||
m_texCoordHandle = ::glGetAttribLocation(m_program, "TexCoordIn");
|
||||
m_texCoordHandle = ::glGetAttribLocation(m_program, name);
|
||||
OGLCHECKAFTER;
|
||||
}
|
||||
|
||||
|
@ -213,12 +222,14 @@ namespace yg
|
|||
m_alphaTestProgram.attachTexture("Texture");
|
||||
m_alphaTestProgram.attachPosition("Position");
|
||||
m_alphaTestProgram.attachTexCoord("TexCoordIn");
|
||||
m_alphaTestProgram.attachNormal("Normal");
|
||||
|
||||
m_noAlphaTestProgram.attachProjection("ProjM");
|
||||
m_noAlphaTestProgram.attachModelView("ModelViewM");
|
||||
m_noAlphaTestProgram.attachTexture("Texture");
|
||||
m_noAlphaTestProgram.attachPosition("Position");
|
||||
m_noAlphaTestProgram.attachTexCoord("TexCoordIn");
|
||||
m_noAlphaTestProgram.attachNormal("Normal");
|
||||
|
||||
m_currentProgram = &m_noAlphaTestProgram;
|
||||
m_currentProgram->apply();
|
||||
|
@ -283,6 +294,13 @@ namespace yg
|
|||
::glVertexAttribPointer(threadData.m_noAlphaTestProgram.m_texCoordHandle, size, type, GL_FALSE, stride, pointer);
|
||||
}
|
||||
|
||||
void glNormalPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer)
|
||||
{
|
||||
ThreadData & threadData = g_threadData[threads::GetCurrentThreadID()];
|
||||
::glVertexAttribPointer(threadData.m_alphaTestProgram.m_normalHandle, size, type, GL_FALSE, stride, pointer);
|
||||
::glVertexAttribPointer(threadData.m_noAlphaTestProgram.m_normalHandle, size, type, GL_FALSE, stride, pointer);
|
||||
}
|
||||
|
||||
void glEnableClientState(GLenum array)
|
||||
{
|
||||
ThreadData & threadData = g_threadData[threads::GetCurrentThreadID()];
|
||||
|
@ -296,6 +314,10 @@ namespace yg
|
|||
::glEnableVertexAttribArray(threadData.m_alphaTestProgram.m_texCoordHandle);
|
||||
::glEnableVertexAttribArray(threadData.m_noAlphaTestProgram.m_texCoordHandle);
|
||||
break;
|
||||
case GL_NORMAL_ARRAY_MWM:
|
||||
::glEnableVertexAttribArray(threadData.m_alphaTestProgram.m_normalHandle);
|
||||
::glEnableVertexAttribArray(threadData.m_noAlphaTestProgram.m_normalHandle);
|
||||
break;
|
||||
default:
|
||||
LOG(LERROR, ("Unknown option is passed to glEnableClientState"));
|
||||
};
|
||||
|
|
|
@ -14,6 +14,7 @@ namespace yg
|
|||
|
||||
void glVertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
void glTexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
void glNormalPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *pointer);
|
||||
void glEnableClientState(GLenum array);
|
||||
|
||||
void glDrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices);
|
||||
|
|
|
@ -138,7 +138,15 @@ namespace yg
|
|||
texture->mapPixel(m2::PointF(texMaxX, texMinY))
|
||||
};
|
||||
|
||||
addTexturedFan(coords, texCoords, 4, depth, lineStyle->m_pipelineID);
|
||||
m2::PointF normals[4] =
|
||||
{
|
||||
m2::PointF(0, 0),
|
||||
m2::PointF(0, 0),
|
||||
m2::PointF(0, 0),
|
||||
m2::PointF(0, 0)
|
||||
};
|
||||
|
||||
addTexturedFan(coords, normals, texCoords, 4, depth, lineStyle->m_pipelineID);
|
||||
|
||||
segLenRemain -= rawTileLen;
|
||||
|
||||
|
@ -203,7 +211,14 @@ namespace yg
|
|||
m2::PointF(points[i + 1] + prevStartVec * geomHalfWidth)
|
||||
};
|
||||
|
||||
addTexturedFan(joinSeg, joinSegTex, 3, depth, lineStyle->m_pipelineID);
|
||||
m2::PointF joinSegNormals[3] =
|
||||
{
|
||||
m2::PointF(0, 0),
|
||||
m2::PointF(0, 0),
|
||||
m2::PointF(0, 0)
|
||||
};
|
||||
|
||||
addTexturedFan(joinSeg, joinSegNormals, joinSegTex, 3, depth, lineStyle->m_pipelineID);
|
||||
|
||||
prevStartVec = startVec;
|
||||
}
|
||||
|
@ -277,7 +292,14 @@ namespace yg
|
|||
texture->mapPixel(m2::PointF(texMaxX, texMaxY))
|
||||
};
|
||||
|
||||
addTexturedStrip(coords, texCoords, 8, depth, lineStyle->m_pipelineID);
|
||||
m2::PointF normal(0, 0);
|
||||
|
||||
addTexturedStripStrided(coords, sizeof(m2::PointF),
|
||||
&normal, 0,
|
||||
texCoords, sizeof(m2::PointF),
|
||||
8,
|
||||
depth,
|
||||
lineStyle->m_pipelineID);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -107,9 +107,13 @@ namespace yg
|
|||
|
||||
m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
|
||||
|
||||
m2::PointF normal(0, 0);
|
||||
|
||||
addTexturedStripStrided(
|
||||
rectPtsF,
|
||||
sizeof(m2::PointF),
|
||||
&normal,
|
||||
0,
|
||||
&texPt,
|
||||
0,
|
||||
4,
|
||||
|
@ -144,9 +148,13 @@ namespace yg
|
|||
|
||||
m2::PointF texPt = texture->mapPixel(m2::RectF(style->m_texRect).Center());
|
||||
|
||||
m2::PointF normal(0, 0);
|
||||
|
||||
addTexturedStripStrided(
|
||||
rectPts,
|
||||
sizeof(m2::PointF),
|
||||
&normal,
|
||||
0,
|
||||
&texPt,
|
||||
0,
|
||||
4,
|
||||
|
@ -218,9 +226,13 @@ namespace yg
|
|||
for (unsigned i = 0; i < seg10.size(); ++i)
|
||||
pts.push_back(m2::PointF(seg10[i]));
|
||||
|
||||
m2::PointF normal(0, 0);
|
||||
|
||||
addTexturedFanStrided(
|
||||
&pts[0],
|
||||
sizeof(m2::PointF),
|
||||
&normal,
|
||||
0,
|
||||
&texPt,
|
||||
0,
|
||||
pts.size(),
|
||||
|
|
|
@ -78,11 +78,13 @@ namespace yg
|
|||
|
||||
m2::PointD posPt = tieRect(m2::RectD(texRect), m);
|
||||
|
||||
r->drawTexturedPolygon(m2::PointD(0.0, 0.0), 0.0,
|
||||
texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(),
|
||||
posPt.x, posPt.y, posPt.x + texRect.SizeX(), posPt.y + texRect.SizeY(),
|
||||
yg::maxDepth,
|
||||
style->m_pipelineID);
|
||||
posPt -= pivot();
|
||||
|
||||
r->drawStraightTexturedPolygon(pivot(),
|
||||
texRect.minX(), texRect.minY(), texRect.maxX(), texRect.maxY(),
|
||||
posPt.x, posPt.y, posPt.x + texRect.SizeX(), posPt.y + texRect.SizeY(),
|
||||
yg::maxDepth,
|
||||
style->m_pipelineID);
|
||||
}
|
||||
|
||||
int SymbolElement::visualRank() const
|
||||
|
|
|
@ -115,14 +115,16 @@ namespace yg
|
|||
{
|
||||
glyphPt = pv + offs + elem.m_pt;
|
||||
glyphAngle = elem.m_angle;
|
||||
|
||||
screen->drawStraightGlyph(pv, offs + elem.m_pt, glyphStyle, depth);
|
||||
}
|
||||
else
|
||||
{
|
||||
glyphPt = (pv + offs + elem.m_pt) * m;
|
||||
glyphAngle = ang::AngleD(elem.m_angle.val() + deltaA);
|
||||
}
|
||||
|
||||
screen->drawGlyph(glyphPt, m2::PointD(0.0, 0.0), glyphAngle, 0, glyphStyle, depth);
|
||||
screen->drawGlyph(glyphPt, m2::PointD(0.0, 0.0), glyphAngle, 0, glyphStyle, depth);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -27,8 +27,34 @@ namespace yg
|
|||
m_glyphCacheID(params.m_glyphCacheID)
|
||||
{}
|
||||
|
||||
void TextRenderer::drawStraightGlyph(m2::PointD const & ptPivot,
|
||||
m2::PointD const & ptOffs,
|
||||
GlyphStyle const * p,
|
||||
float depth)
|
||||
{
|
||||
float x0 = ptOffs.x + (p->m_gi->m_metrics.m_xOffset - 1);
|
||||
float y1 = ptOffs.y - (p->m_gi->m_metrics.m_yOffset - 1);
|
||||
float y0 = y1 - (p->m_texRect.SizeY() - 2);
|
||||
float x1 = x0 + (p->m_texRect.SizeX() - 2);
|
||||
|
||||
void TextRenderer::drawGlyph(m2::PointD const & ptOrg, m2::PointD const & ptGlyph, ang::AngleD const & angle, float /*blOffset*/, GlyphStyle const * p, double depth)
|
||||
drawStraightTexturedPolygon(
|
||||
ptPivot,
|
||||
p->m_texRect.minX() + 1,
|
||||
p->m_texRect.minY() + 1,
|
||||
p->m_texRect.maxX() - 1,
|
||||
p->m_texRect.maxY() - 1,
|
||||
x0, y0, x1, y1,
|
||||
depth,
|
||||
p->m_pipelineID
|
||||
);
|
||||
}
|
||||
|
||||
void TextRenderer::drawGlyph(m2::PointD const & ptOrg,
|
||||
m2::PointD const & ptGlyph,
|
||||
ang::AngleD const & angle,
|
||||
float /*blOffset*/,
|
||||
GlyphStyle const * p,
|
||||
double depth)
|
||||
{
|
||||
float x0 = ptGlyph.x + (p->m_gi->m_metrics.m_xOffset - 1);
|
||||
float y1 = ptGlyph.y - (p->m_gi->m_metrics.m_yOffset - 1);
|
||||
|
|
|
@ -34,6 +34,11 @@ namespace yg
|
|||
|
||||
TextRenderer(Params const & params);
|
||||
|
||||
void drawStraightGlyph(m2::PointD const & ptOrg,
|
||||
m2::PointD const & ptGlyph,
|
||||
GlyphStyle const * p,
|
||||
float depth);
|
||||
|
||||
void drawGlyph(m2::PointD const & ptOrg,
|
||||
m2::PointD const & ptGlyph,
|
||||
ang::AngleD const & angle,
|
||||
|
|
|
@ -9,20 +9,30 @@ namespace yg
|
|||
Vertex::Vertex()
|
||||
{}
|
||||
|
||||
Vertex::Vertex(m2::PointF const & _pt, float _depth, m2::PointF const & _tex)
|
||||
: pt(_pt), depth(_depth), tex(_tex)
|
||||
Vertex::Vertex(m2::PointF const & _pt,
|
||||
float _depth,
|
||||
m2::PointF const & _normal,
|
||||
m2::PointF const & _tex)
|
||||
: pt(_pt),
|
||||
depth(_depth),
|
||||
normal(_normal),
|
||||
tex(_tex)
|
||||
{}
|
||||
|
||||
Vertex::Vertex(Vertex const & v)
|
||||
: pt(v.pt), depth(v.depth), tex(v.tex)
|
||||
: pt(v.pt),
|
||||
depth(v.depth),
|
||||
normal(v.normal),
|
||||
tex(v.tex)
|
||||
{}
|
||||
|
||||
Vertex const & Vertex::operator=(Vertex const & v)
|
||||
{
|
||||
{
|
||||
if (this != &v)
|
||||
{
|
||||
pt = v.pt;
|
||||
depth = v.depth;
|
||||
normal = v.normal;
|
||||
tex = v.tex;
|
||||
}
|
||||
return *this;
|
||||
|
@ -33,6 +43,9 @@ namespace yg
|
|||
OGLCHECK(glEnableClientStateFn(GL_VERTEX_ARRAY_MWM));
|
||||
OGLCHECK(glVertexPointerFn(3, GL_FLOAT, sizeof(Vertex), (void*)((char*)glPtr + Vertex::vertexOffset)));
|
||||
|
||||
OGLCHECK(glEnableClientStateFn(GL_NORMAL_ARRAY_MWM));
|
||||
OGLCHECK(glNormalPointerFn(2, GL_FLOAT, sizeof(Vertex), (void*)((char*)glPtr + Vertex::normalOffset)));
|
||||
|
||||
OGLCHECK(glEnableClientStateFn(GL_TEXTURE_COORD_ARRAY_MWM));
|
||||
OGLCHECK(glTexCoordPointerFn(2, GL_FLOAT, sizeof(Vertex), (void*)((char*)glPtr + Vertex::texCoordOffset)));
|
||||
}
|
||||
|
|
|
@ -13,13 +13,18 @@ namespace yg
|
|||
{
|
||||
m2::PointF pt;
|
||||
float depth;
|
||||
m2::PointF normal;
|
||||
m2::PointF tex;
|
||||
|
||||
static const int vertexOffset = 0;
|
||||
static const int texCoordOffset = sizeof(m2::PointF) + sizeof(float);
|
||||
static const int normalOffset = sizeof(m2::PointF) + sizeof(float);
|
||||
static const int texCoordOffset = sizeof(m2::PointF) + sizeof(float) + sizeof(m2::PointF);
|
||||
|
||||
Vertex();
|
||||
Vertex(m2::PointF const & _pt, float _depth = 0, m2::PointF const & _tex = m2::PointF());
|
||||
Vertex(m2::PointF const & _pt,
|
||||
float _depth = 0,
|
||||
m2::PointF const & _normal = m2::PointF(),
|
||||
m2::PointF const & _tex = m2::PointF());
|
||||
Vertex(Vertex const & v);
|
||||
Vertex const & operator=(Vertex const & v);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue