Merged the Text::GlyphQuads cooordinate arrays

This commit is contained in:
Robert Osfield
2017-02-28 16:34:33 +00:00
parent e5685dfca5
commit 138af70bd8
4 changed files with 384 additions and 154 deletions

View File

@@ -295,20 +295,42 @@ public:
public:
typedef osg::ref_ptr<osg::Vec3Array> Coords;
typedef osg::ref_ptr<osg::Vec2Array> TexCoords;
typedef osg::ref_ptr<osg::Vec4Array> ColorCoords;
#ifdef NEW_APPROACH
Coords _coords;
ColorCoords _colorCoords;
TexCoords _texcoords;
unsigned int addCoord(const osg::Vec2& c) { unsigned int s = _coords->size(); _coords->push_back(osg::Vec3(c.x(), c.y(), 0.0f)); return s; }
unsigned int addCoord(const osg::Vec3& c) { unsigned int s = _coords->size(); _coords->push_back(c); return s; }
void getCoord(unsigned int i, osg::Vec2& c) const { c.set((*_coords)[i].x(), (*_coords)[i].y()); }
void getCoord(unsigned int i, osg::Vec3& c) const { c = (*_coords)[i]; }
Coords& getCoords() { return _coords; }
const Coords& getCoords() const { return _coords; }
void addTexCoord(const osg::Vec2& tc) { _texcoords->push_back(tc); }
#endif
// internal structures, variable and methods used for rendering of characters.
struct OSGTEXT_EXPORT GlyphQuads
{
typedef std::vector<Glyph*> Glyphs;
typedef std::vector<unsigned int> LineNumbers;
typedef osg::ref_ptr<osg::Vec3Array> Coords;
typedef osg::ref_ptr<osg::Vec2Array> TexCoords;
typedef osg::ref_ptr<osg::Vec4Array> ColorCoords;
typedef std::vector< osg::ref_ptr<osg::DrawElementsUShort> > Primitives;
Glyphs _glyphs;
#ifndef NEW_APPROACH
Coords _coords;
ColorCoords _colorCoords;
TexCoords _texcoords;
#endif
unsigned int _coordBase;
Primitives _primitives;
@@ -324,8 +346,9 @@ public:
Glyphs& getGlyphs() { return _glyphs; }
const Glyphs& getGlyphs() const { return _glyphs; }
void addCoord(const osg::Vec2& c) { _coords->push_back(osg::Vec3(c.x(), c.y(), 0.0f)); }
void addCoord(const osg::Vec3& c) { _coords->push_back(c); }
#ifndef NEW_APPROACH
unsigned int addCoord(const osg::Vec2& c) { unsigned int s = _coords->size(); _coords->push_back(osg::Vec3(c.x(), c.y(), 0.0f)); return s; }
unsigned int addCoord(const osg::Vec3& c) { unsigned int s = _coords->size(); _coords->push_back(c); return s; }
void getCoord(unsigned int i, osg::Vec2& c) const { c.set((*_coords)[i].x(), (*_coords)[i].y()); }
void getCoord(unsigned int i, osg::Vec3& c) const { c = (*_coords)[i]; }
@@ -334,6 +357,7 @@ public:
const Coords& getCoords() const { return _coords; }
void addTexCoord(const osg::Vec2& tc) { _texcoords->push_back(tc); }
#endif
/** Resize any per context GLObject buffers to specified size. */
void resizeGLObjectBuffers(unsigned int maxSize);