diff --git a/include/osgText/Text b/include/osgText/Text index df0414552..4300788a5 100644 --- a/include/osgText/Text +++ b/include/osgText/Text @@ -317,11 +317,13 @@ public: void updateQuadIndices(); GlyphQuads(); + GlyphQuads(const GlyphQuads& gq); + void initGlyphQuads(); void initGPUBufferObjects(); - Glyphs getGlyphs() { return _glyphs; } - const Glyphs getGlyphs() const { return _glyphs; } + Glyphs& getGlyphs() { return _glyphs; } + const Glyphs& getGlyphs() const { return _glyphs; } Coords2& getCoords() { return _coords; } const Coords2& getCoords() const { return _coords; } @@ -334,6 +336,18 @@ public: LineNumbers& getLineNumbers() { return _lineNumbers; } const LineNumbers& getLineNumbers() const { return _lineNumbers; } + + /** Resize any per context GLObject buffers to specified size. */ + virtual void resizeGLObjectBuffers(unsigned int maxSize); + + /** If State is non-zero, this function releases OpenGL objects for + * the specified graphics context. Otherwise, releases OpenGL objexts + * for all graphics contexts. */ + virtual void releaseGLObjects(osg::State* state=0) const; + + private: + + GlyphQuads& operator = (const GlyphQuads&) { return *this; } }; typedef std::map,GlyphQuads> TextureGlyphQuadMap; diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index c6a123b5f..84e71b378 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -723,7 +723,15 @@ void Text::computePositions(unsigned int contextID) const ++titr) { GlyphQuads& glyphquad = titr->second; + //OSG_NOTICE<<"Text::computePositions("<size(); i += 4) { _quadIndices->push_back(i); @@ -2087,3 +2124,34 @@ void Text::GlyphQuads::initGPUBufferObjects() _quadIndices->setElementBufferObject(new osg::ElementBufferObject()); } + + +void Text::GlyphQuads::resizeGLObjectBuffers(unsigned int maxSize) +{ + _transformedCoords.resize(maxSize); + + for (int j = 0; j < 8; j++) + { + for (size_t i = 0; i < _transformedBackdropCoords[j].size(); i++) + { + _transformedBackdropCoords[j][i]->resizeGLObjectBuffers(maxSize); + } + } + + _quadIndices->resizeGLObjectBuffers(maxSize); + + initGPUBufferObjects(); +} + +void Text::GlyphQuads::releaseGLObjects(osg::State* state) const +{ + for (int j = 0; j < 8; j++) + { + for (size_t i = 0; i < _transformedBackdropCoords[j].size(); i++) + { + _transformedBackdropCoords[j][i]->releaseGLObjects(state); + } + } + + _quadIndices->releaseGLObjects(state); +}