diff --git a/examples/osghud/osghud.cpp b/examples/osghud/osghud.cpp index c4ea8d14f..9706a237b 100644 --- a/examples/osghud/osghud.cpp +++ b/examples/osghud/osghud.cpp @@ -79,7 +79,7 @@ osg::Node* createHUD() geode->addDrawable( text ); text->setFont(timesFont); - text->setText("Then place a osg::Projection node above the subgraph\nto create an orthographic projection."); + text->setText("Then place an osg::Projection node above the subgraph\nto create an orthographic projection."); text->setPosition(position); position += delta; diff --git a/include/osg/Image b/include/osg/Image index 8ed9e8b47..b79ea758c 100644 --- a/include/osg/Image +++ b/include/osg/Image @@ -59,6 +59,8 @@ class SG_EXPORT Image : public Object virtual const char* libraryName() const { return "osg"; } virtual const char* className() const { return "Image"; } + /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ + virtual int compare(const Image& rhs) const; void setFileName(const std::string& fileName); inline const std::string& getFileName() const { return _fileName; } diff --git a/include/osgText/Font b/include/osgText/Font index 47f0b44ac..5cda9d13b 100644 --- a/include/osgText/Font +++ b/include/osgText/Font @@ -23,7 +23,6 @@ #include #include -#include namespace osgText { @@ -116,7 +115,6 @@ protected: typedef std::pair< unsigned int, unsigned int > SizePair; typedef std::map< SizePair, GlyphMap > SizeGlyphMap; - typedef std::set< Text* > TextList; SizeGlyphMap _sizeGlyphMap; GlyphTextureList _glyphTextureList; @@ -175,6 +173,9 @@ public: GlyphTexture(); + /** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/ + virtual int compare(const StateAttribute& rhs) const; + void setStateSet(osg::StateSet* stateset) { _stateset = stateset; } osg::StateSet* getStateSet() { return _stateset; } const osg::StateSet* getStateSet() const { return _stateset; } diff --git a/src/Demos/osghud/osghud.cpp b/src/Demos/osghud/osghud.cpp index 2344f7f91..b10e0119d 100644 --- a/src/Demos/osghud/osghud.cpp +++ b/src/Demos/osghud/osghud.cpp @@ -109,7 +109,7 @@ osg::Node* createHUD() geode->addDrawable( text ); text->setFont(timesFont); - text->setText("Then place a osg::Projection node above the subgraph\nto create an orthographic projection."); + text->setText("Then place an osg::Projection node above the subgraph\nto create an orthographic projection."); text->setPosition(position); position += delta; diff --git a/src/osg/Image.cpp b/src/osg/Image.cpp index 0417f2f32..069dc6537 100644 --- a/src/osg/Image.cpp +++ b/src/osg/Image.cpp @@ -81,6 +81,27 @@ void Image::deallocateData() } } +int Image::compare(const Image& rhs) const +{ + if (getFileName()rhs.getFileName()) return 1; + + // need to test against image contents here... + COMPARE_StateAttribute_Parameter(_s) + COMPARE_StateAttribute_Parameter(_t) + COMPARE_StateAttribute_Parameter(_internalTextureFormat) + COMPARE_StateAttribute_Parameter(_pixelFormat) + COMPARE_StateAttribute_Parameter(_dataType) + COMPARE_StateAttribute_Parameter(_packing) + COMPARE_StateAttribute_Parameter(_modifiedTag) + + // still need implement checks for + // _data + // _mipmapData + + return 0; +} + void Image::setFileName(const std::string& fileName) { _fileName = fileName; diff --git a/src/osg/State.cpp b/src/osg/State.cpp index a92603adf..8317d8171 100644 --- a/src/osg/State.cpp +++ b/src/osg/State.cpp @@ -212,7 +212,8 @@ void State::apply(const StateSet* dstate) //pushStateSet(dstate); //apply(); //popStateSet(); - + //return; + if (dstate) { diff --git a/src/osg/Texture1D.cpp b/src/osg/Texture1D.cpp index 608bee020..9ac7ece34 100644 --- a/src/osg/Texture1D.cpp +++ b/src/osg/Texture1D.cpp @@ -50,8 +50,8 @@ int Texture1D::compare(const StateAttribute& sa) const { if (rhs._image.valid()) { - if (_image->getFileName()getFileName()) return -1; - else if (_image->getFileName()>rhs._image->getFileName()) return 1;; + int result = _image->compare(*rhs._image); + if (result!=0) return result; } else { diff --git a/src/osg/Texture2D.cpp b/src/osg/Texture2D.cpp index 536738d35..7471d49ed 100644 --- a/src/osg/Texture2D.cpp +++ b/src/osg/Texture2D.cpp @@ -52,8 +52,8 @@ int Texture2D::compare(const StateAttribute& sa) const { if (rhs._image.valid()) { - if (_image->getFileName()getFileName()) return -1; - else if (_image->getFileName()>rhs._image->getFileName()) return 1;; + int result = _image->compare(*rhs._image); + if (result!=0) return result; } else { diff --git a/src/osg/Texture3D.cpp b/src/osg/Texture3D.cpp index 739a6a12b..5dd67d08c 100644 --- a/src/osg/Texture3D.cpp +++ b/src/osg/Texture3D.cpp @@ -57,8 +57,8 @@ int Texture3D::compare(const StateAttribute& sa) const { if (rhs._image.valid()) { - if (_image->getFileName()getFileName()) return -1; - else if (_image->getFileName()>rhs._image->getFileName()) return 1;; + int result = _image->compare(*rhs._image); + if (result!=0) return result; } else { diff --git a/src/osg/TextureCubeMap.cpp b/src/osg/TextureCubeMap.cpp index ee0da89d4..3f8c59dc8 100644 --- a/src/osg/TextureCubeMap.cpp +++ b/src/osg/TextureCubeMap.cpp @@ -129,8 +129,8 @@ int TextureCubeMap::compare(const StateAttribute& sa) const { if (rhs._images[n].valid()) { - if (_images[n]->getFileName()getFileName()) return -1; - else if (_images[n]->getFileName()>rhs._images[n]->getFileName()) return 1;; + int result = _images[n]->compare(*rhs._images[n]); + if (result!=0) return result; } else { diff --git a/src/osgPlugins/freetype/FreeTypeFont.cpp b/src/osgPlugins/freetype/FreeTypeFont.cpp index 469568451..fa97c7b1e 100644 --- a/src/osgPlugins/freetype/FreeTypeFont.cpp +++ b/src/osgPlugins/freetype/FreeTypeFont.cpp @@ -119,6 +119,8 @@ osgText::Font::Glyph* FreeTypeFont::getGlyph(unsigned int charcode) glyph->setVerticalAdvance((float)metrics->vertAdvance/64.0f); addGlyph(_facade->getWidth(),_facade->getHeight(),charcode,glyph.get()); + +// cout << " in getGlyph() implementation="<numVertices << std::endl; - long *command = (long *) ((unsigned char *) mapbase + md2_header->offsetGlCommands); + //long *command = (long *) ((unsigned char *) mapbase + md2_header->offsetGlCommands); MD2_FRAME *frame = (MD2_FRAME *) ((unsigned char *) mapbase + md2_header->offsetFrames + (md2_header->frameSize * curFrame)); MD2_VERTEX *frame_vertices = frame->vertices; diff --git a/src/osgText/Font.cpp b/src/osgText/Font.cpp index ced36af61..cc9b54c2c 100644 --- a/src/osgText/Font.cpp +++ b/src/osgText/Font.cpp @@ -210,6 +210,9 @@ bool Font::hasVertical() const void Font::addGlyph(unsigned int width, unsigned int height, unsigned int charcode, Glyph* glyph) { + + //cout << "charcode "<<(char)charcode<<" "<<&_glyphTextureList<getSpaceForGlyph(glyph,posX,posY)) glyphTexture = itr->get(); } + if (glyphTexture) + { + //cout << " found space for texture "<setGlyphImageMargin(_margin); @@ -277,6 +286,15 @@ Font::GlyphTexture::~GlyphTexture() { } +// return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs. +int Font::GlyphTexture::compare(const StateAttribute& rhs) const +{ + if (this<&rhs) return -1; + else if (this>&rhs) return 1; + return 0; +} + + bool Font::GlyphTexture::getSpaceForGlyph(Glyph* glyph, int& posX, int& posY) { diff --git a/src/osgText/Text.cpp b/src/osgText/Text.cpp index 422f34d2c..e65cc3616 100644 --- a/src/osgText/Text.cpp +++ b/src/osgText/Text.cpp @@ -219,6 +219,8 @@ void Text::computeGlyphRepresentation() _textureGlyphQuadMap.clear(); + if (_text.empty()) return; + osg::Vec2 startOfLine(0.0f,0.0f); osg::Vec2 cursor(startOfLine); osg::Vec2 local(0.0f,0.0f);