Fixed Glyph::TextureInfo assignment bug

This commit is contained in:
Robert Osfield
2017-10-24 11:36:00 +01:00
parent 55a1764712
commit 1cd0a5fe03
4 changed files with 23 additions and 13 deletions

View File

@@ -100,16 +100,9 @@ public:
float texelMargin;
};
void setTextureInfo(ShaderTechnique technique, TextureInfo* info)
{
if (technique>=_textureInfoList.size()) _textureInfoList.resize(technique+1);
_textureInfoList[technique] = info;
}
void setTextureInfo(ShaderTechnique technique, TextureInfo* info);
const TextureInfo* getTextureInfo(ShaderTechnique technique) const
{
return (technique<_textureInfoList.size()) ? _textureInfoList[technique].get() : 0;
}
const TextureInfo* getTextureInfo(ShaderTechnique technique) const;
TextureInfo* getOrCreateTextureInfo(ShaderTechnique technique);

View File

@@ -456,12 +456,12 @@ void Font::assignGlyphToGlyphTexture(Glyph* glyph, ShaderTechnique shaderTechniq
itr!=_glyphTextureList.end() && !glyphTexture;
++itr)
{
if ((*itr)->getSpaceForGlyph(glyph,posX,posY)) glyphTexture = itr->get();
if ((*itr)->getShaderTechnique()==shaderTechnique && (*itr)->getSpaceForGlyph(glyph,posX,posY)) glyphTexture = itr->get();
}
if (glyphTexture)
{
//cout << " found space for texture "<<glyphTexture<<" posX="<<posX<<" posY="<<posY<<endl;
//cout << " Font::assignGlyphToGlyphTexture() found space for texture "<<glyphTexture<<" posX="<<posX<<" posY="<<posY<<endl;
}
if (!glyphTexture)

View File

@@ -151,6 +151,7 @@ bool GlyphTexture::getSpaceForGlyph(Glyph* glyph, int& posX, int& posY)
void GlyphTexture::addGlyph(Glyph* glyph, int posX, int posY)
{
OpenThreads::ScopedLock<OpenThreads::Mutex> lock(_mutex);
if (!_image.valid()) createImage();
@@ -460,9 +461,26 @@ const osg::Vec2& Glyph::getVerticalBearing() const { return _verticalBearing; }
void Glyph::setVerticalAdvance(float advance) { _verticalAdvance=advance; }
float Glyph::getVerticalAdvance() const { return _verticalAdvance; }
void Glyph::setTextureInfo(ShaderTechnique technique, TextureInfo* info)
{
if (technique>=_textureInfoList.size())
{
_textureInfoList.resize(technique+1);
}
_textureInfoList[technique] = info;
}
const Glyph::TextureInfo* Glyph::getTextureInfo(ShaderTechnique technique) const
{
return (technique<_textureInfoList.size()) ? _textureInfoList[technique].get() : 0;
}
Glyph::TextureInfo* Glyph::getOrCreateTextureInfo(ShaderTechnique technique)
{
if (technique>=_textureInfoList.size()) _textureInfoList.resize(technique+1);
if (technique>=_textureInfoList.size())
{
_textureInfoList.resize(technique+1);
}
if (!_textureInfoList[technique])
{
_font->assignGlyphToGlyphTexture(this, technique);

View File

@@ -638,7 +638,6 @@ void Text::computeGlyphRepresentation()
const Glyph::TextureInfo* info = glyph->getOrCreateTextureInfo(_shaderTechnique);
if (info)
{
// Adjust coordinates and texture coordinates to avoid
// clipping the edges of antialiased characters.
osg::Vec2 mintc = info->minTexCoord;