2006-07-18 23:21:48 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
|
2003-01-22 00:45:36 +08:00
|
|
|
*
|
|
|
|
* This library is open source and may be redistributed and/or modified under
|
|
|
|
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
|
|
|
|
* (at your option) any later version. The full license is in LICENSE file
|
|
|
|
* included with this distribution, and on the openscenegraph.org website.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* OpenSceneGraph Public License for more details.
|
|
|
|
*/
|
2001-11-12 18:04:57 +08:00
|
|
|
|
|
|
|
#ifndef OSGTEXT_FONT
|
2003-03-03 05:05:05 +08:00
|
|
|
#define OSGTEXT_FONT 1
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2004-08-04 16:27:43 +08:00
|
|
|
#include <string>
|
2005-11-07 19:05:16 +08:00
|
|
|
#include <istream>
|
2004-08-04 16:27:43 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
#include <osg/Vec2>
|
|
|
|
#include <osg/Image>
|
|
|
|
#include <osg/Texture2D>
|
|
|
|
#include <osg/StateSet>
|
|
|
|
#include <osg/buffered_value>
|
2006-08-29 03:37:40 +08:00
|
|
|
#include <osg/TexEnv>
|
2007-07-02 20:30:14 +08:00
|
|
|
#include <osgDB/ReaderWriter>
|
2007-12-23 21:18:40 +08:00
|
|
|
|
2001-11-12 18:04:57 +08:00
|
|
|
#include <osgText/Export>
|
2007-12-10 23:15:56 +08:00
|
|
|
#include <osgText/KerningType>
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2007-09-01 04:16:02 +08:00
|
|
|
#include <OpenThreads/Mutex>
|
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
namespace osgText {
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
class Font;
|
2003-03-04 20:34:42 +08:00
|
|
|
class Text;
|
2007-12-10 23:15:56 +08:00
|
|
|
|
2005-09-28 21:45:32 +08:00
|
|
|
/** Read a font from specified file. The filename may contain a path.
|
|
|
|
* It will search for the font file in the following places in this order:
|
|
|
|
* - In the current directory
|
|
|
|
* - All paths defined in OSG_FILE_PATH or OSGFILEPATH environment variable
|
|
|
|
* - Filename with path stripped: In the current directory
|
|
|
|
* - Filename with path stripped: All paths defined in OSG_FILE_PATH or OSGFILEPATH
|
|
|
|
*
|
|
|
|
* Then the file will be searched in OS specific directories in the following order:
|
|
|
|
* - Again in the current directory
|
|
|
|
* - Windows: In C:/winnt/fonts
|
|
|
|
* - Windows: In C:/windows/fonts
|
|
|
|
* - Windows: In the fonts directory of the windows install directory
|
|
|
|
* - Other OS: In /usr/share/fonts/ttf
|
|
|
|
* - Other OS: In /usr/share/fonts/ttf/western
|
|
|
|
* - Other OS: In /usr/share/fonts/ttf/decoratives
|
|
|
|
*
|
|
|
|
* If the given file could not be found, the path part will be stripped and
|
|
|
|
* the file will be searched again in the OS specific directories.
|
|
|
|
*/
|
2007-07-02 20:30:14 +08:00
|
|
|
extern OSGTEXT_EXPORT Font* readFontFile(const std::string& filename, const osgDB::ReaderWriter::Options* userOptions = 0);
|
2005-11-07 19:05:16 +08:00
|
|
|
|
|
|
|
/** read a font from specified stream.*/
|
2007-07-02 20:30:14 +08:00
|
|
|
extern OSGTEXT_EXPORT Font* readFontStream(std::istream& stream, const osgDB::ReaderWriter::Options* userOptions = 0);
|
2005-11-07 19:05:16 +08:00
|
|
|
|
2007-12-13 01:04:48 +08:00
|
|
|
extern OSGTEXT_EXPORT osg::ref_ptr<Font> readRefFontFile(const std::string& filename, const osgDB::ReaderWriter::Options* userOptions = 0);
|
|
|
|
|
|
|
|
extern OSGTEXT_EXPORT osg::ref_ptr<Font> readRefFontStream(std::istream& stream, const osgDB::ReaderWriter::Options* userOptions = 0);
|
|
|
|
|
2005-11-02 18:57:42 +08:00
|
|
|
extern OSGTEXT_EXPORT std::string findFontFile(const std::string& str);
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
/** Pure virtual base class for fonts.
|
|
|
|
* Concrete implementation are the DefaultFont found in src/osgText/DefaultFont.cpp
|
|
|
|
* and FreeTypeFont found in src/osgPlugins/freetype/FreeTypeFont.cpp*/
|
2001-11-12 18:04:57 +08:00
|
|
|
class OSGTEXT_EXPORT Font : public osg::Object
|
|
|
|
{
|
2003-03-03 05:05:05 +08:00
|
|
|
// declare the interface to a font.
|
|
|
|
public:
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
// forward declare nested classes.
|
|
|
|
class Glyph;
|
|
|
|
class GlyphTexture;
|
2003-03-07 01:11:24 +08:00
|
|
|
class FontImplementation;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2005-05-16 04:32:10 +08:00
|
|
|
public:
|
2003-03-07 01:11:24 +08:00
|
|
|
Font(FontImplementation* implementation=0);
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
virtual osg::Object* cloneType() const { return 0; } // cloneType() not appropriate
|
|
|
|
virtual osg::Object* clone(const osg::CopyOp&) const { return 0; } // clone() not appropriate
|
|
|
|
virtual bool isSameKindAs(const osg::Object* obj) const { return dynamic_cast<const Font*>(obj)!=NULL; }
|
|
|
|
virtual const char* className() const { return "Font"; }
|
|
|
|
virtual const char* libraryName() const { return "osgText"; }
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
virtual std::string getFileName() const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2006-08-29 03:37:40 +08:00
|
|
|
void setTexEnv(osg::TexEnv* texenv) { if (texenv) _texenv = texenv; }
|
|
|
|
inline osg::TexEnv* getTexEnv() { return _texenv.get(); }
|
|
|
|
inline const osg::TexEnv* getTexEnv() const { return _texenv.get(); }
|
2006-07-04 21:56:29 +08:00
|
|
|
|
|
|
|
void setStateSet(osg::StateSet* stateset) { _stateset = stateset; }
|
|
|
|
osg::StateSet* getStateSet() { return _stateset.get(); }
|
|
|
|
const osg::StateSet* getStateSet() const { return _stateset.get(); }
|
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
|
2003-06-27 00:21:49 +08:00
|
|
|
/** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/
|
2007-12-24 02:15:54 +08:00
|
|
|
virtual osg::Vec2 getKerning(const FontResolution& fontSize, unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType);
|
2003-06-27 00:21:49 +08:00
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
/** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/
|
2007-12-24 02:15:54 +08:00
|
|
|
virtual Glyph* getGlyph(const FontResolution& fontSize, unsigned int charcode);
|
2003-03-03 05:05:05 +08:00
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
/** Return true if this font provides vertical alignments and spacing or glyphs.*/
|
|
|
|
virtual bool hasVertical() const;
|
|
|
|
|
|
|
|
/** Set the margin around each glyph,
|
|
|
|
* to ensure that texture filtering doesn't bleed adjacent glyph's into each other.
|
2007-05-04 20:05:29 +08:00
|
|
|
* Default margin is 1 texels.*/
|
2003-03-10 17:15:59 +08:00
|
|
|
void setGlyphImageMargin(unsigned int margin);
|
|
|
|
unsigned int getGlyphImageMargin() const;
|
2003-03-07 01:11:24 +08:00
|
|
|
|
2007-05-04 20:05:29 +08:00
|
|
|
/** Set the margin ratio around each glyph, relative to the glyph's size.
|
|
|
|
* to ensure that texture filtering doesn't bleed adjacent glyph's into each other.
|
|
|
|
* Default margin is 0.05.*/
|
|
|
|
void setGlyphImageMarginRatio(float margin);
|
|
|
|
float getGlyphImageMarginRatio() const;
|
|
|
|
|
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
/** Set the size of texture to create to store the glyph images when rendering.
|
|
|
|
* Note, this doesn't affect already created Texture Glhph's.*/
|
|
|
|
void setTextureSizeHint(unsigned int width,unsigned int height);
|
|
|
|
|
2003-03-10 17:15:59 +08:00
|
|
|
unsigned int getTextureWidthHint() const;
|
|
|
|
unsigned int getTextureHeightHint() const;
|
2003-03-07 01:11:24 +08:00
|
|
|
|
|
|
|
/** Set the minification texture filter to use when creating the texture to store the glyph images when rendering.
|
|
|
|
* Note, this doesn't affect already created Texture Glhph's.*/
|
|
|
|
void setMinFilterHint(osg::Texture::FilterMode mode);
|
2003-03-10 17:15:59 +08:00
|
|
|
osg::Texture::FilterMode getMinFilterHint() const;
|
2003-03-07 01:11:24 +08:00
|
|
|
|
|
|
|
/** Set the magnification texture filter to use when creating the texture to store the glyph images when rendering.
|
|
|
|
* Note, this doesn't affect already created Texture Glhph's.*/
|
|
|
|
void setMagFilterHint(osg::Texture::FilterMode mode);
|
2003-03-10 17:15:59 +08:00
|
|
|
osg::Texture::FilterMode getMagFilterHint() const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 20:34:42 +08:00
|
|
|
// make Text a friend to allow it add and remove its entry in the Font's _textList.
|
2003-03-07 01:11:24 +08:00
|
|
|
friend class FontImplementation;
|
|
|
|
|
|
|
|
void setImplementation(FontImplementation* implementation);
|
|
|
|
|
2003-03-10 17:15:59 +08:00
|
|
|
FontImplementation* getImplementation();
|
|
|
|
const FontImplementation* getImplementation() const;
|
2003-03-07 01:11:24 +08:00
|
|
|
|
2007-01-09 04:40:29 +08:00
|
|
|
/** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/
|
|
|
|
virtual void setThreadSafeRefUnref(bool threadSafe);
|
|
|
|
|
|
|
|
/** Resize any per context GLObject buffers to specified size. */
|
|
|
|
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
|
|
|
|
2005-05-07 17:17:55 +08:00
|
|
|
/** If State is non-zero, this function releases OpenGL objects for
|
|
|
|
* the specified graphics context. Otherwise, releases OpenGL objexts
|
|
|
|
* for all graphics contexts. */
|
2005-05-08 04:47:09 +08:00
|
|
|
virtual void releaseGLObjects(osg::State* state=0) const;
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2007-09-01 04:16:02 +08:00
|
|
|
typedef OpenThreads::Mutex FontMutex;
|
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
protected:
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
virtual ~Font();
|
|
|
|
|
2007-12-24 02:15:54 +08:00
|
|
|
void addGlyph(const FontResolution& fontRes, unsigned int charcode, Glyph* glyph);
|
2003-03-03 05:05:05 +08:00
|
|
|
|
|
|
|
typedef std::vector< osg::ref_ptr<GlyphTexture> > GlyphTextureList;
|
|
|
|
typedef std::vector< osg::ref_ptr<osg::StateSet> > StateSetList;
|
|
|
|
typedef std::map< unsigned int, osg::ref_ptr<Glyph> > GlyphMap;
|
|
|
|
|
2007-12-24 02:15:54 +08:00
|
|
|
typedef std::map< FontResolution, GlyphMap > FontSizeGlyphMap;
|
2003-03-04 20:34:42 +08:00
|
|
|
|
2008-02-25 20:54:54 +08:00
|
|
|
mutable OpenThreads::Mutex _glyphMapMutex;
|
|
|
|
|
2006-08-29 03:37:40 +08:00
|
|
|
osg::ref_ptr<osg::TexEnv> _texenv;
|
2006-07-04 21:56:29 +08:00
|
|
|
osg::ref_ptr<osg::StateSet> _stateset;
|
2007-12-23 21:18:40 +08:00
|
|
|
FontSizeGlyphMap _sizeGlyphMap;
|
2003-03-07 01:11:24 +08:00
|
|
|
GlyphTextureList _glyphTextureList;
|
2003-03-04 20:34:42 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
// current active size of font
|
2008-02-25 20:54:54 +08:00
|
|
|
FontResolution _fontSize;
|
2003-03-07 01:11:24 +08:00
|
|
|
unsigned int _margin;
|
2007-05-04 20:05:29 +08:00
|
|
|
float _marginRatio;
|
2003-03-07 01:11:24 +08:00
|
|
|
|
|
|
|
unsigned int _textureWidthHint;
|
|
|
|
unsigned int _textureHeightHint;
|
|
|
|
osg::Texture::FilterMode _minFilterHint;
|
|
|
|
osg::Texture::FilterMode _magFilterHint;
|
|
|
|
|
|
|
|
osg::ref_ptr<FontImplementation> _implementation;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
|
|
|
|
// declare the nested classes.
|
|
|
|
public:
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2003-03-08 17:51:41 +08:00
|
|
|
class FontImplementation : public osg::Referenced
|
2003-03-07 01:11:24 +08:00
|
|
|
{
|
|
|
|
public:
|
|
|
|
|
2007-08-22 20:14:15 +08:00
|
|
|
FontImplementation():
|
2007-12-17 01:01:40 +08:00
|
|
|
osg::Referenced(true),
|
|
|
|
_facade(0) {}
|
2007-08-22 20:14:15 +08:00
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
virtual std::string getFileName() const = 0;
|
|
|
|
|
|
|
|
/** Get a Glyph for specified charcode, and the font size nearest to the current font size hint.*/
|
2007-12-24 02:15:54 +08:00
|
|
|
virtual Glyph* getGlyph(const FontResolution& fontRes, unsigned int charcode) = 0;
|
2003-03-07 01:11:24 +08:00
|
|
|
|
|
|
|
/** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/
|
2007-12-24 02:15:54 +08:00
|
|
|
virtual osg::Vec2 getKerning(const FontResolution& fontRes, unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType) = 0;
|
2003-03-07 01:11:24 +08:00
|
|
|
|
|
|
|
/** Return true if this font provides vertical alignments and spacing or glyphs.*/
|
|
|
|
virtual bool hasVertical() const = 0;
|
|
|
|
|
2007-12-24 02:15:54 +08:00
|
|
|
void addGlyph(const FontResolution& fontRes, unsigned int charcode, Glyph* glyph)
|
2003-03-07 01:11:24 +08:00
|
|
|
{
|
2007-12-24 02:15:54 +08:00
|
|
|
_facade->addGlyph(fontRes, charcode, glyph);
|
2003-03-07 01:11:24 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
Font* _facade;
|
|
|
|
};
|
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
class OSGTEXT_EXPORT GlyphTexture : public osg::Texture2D
|
|
|
|
{
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
public:
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
GlyphTexture();
|
2004-01-27 22:47:41 +08:00
|
|
|
|
|
|
|
const char* className() const { return "GlyphTexture"; }
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2003-03-11 21:30:03 +08:00
|
|
|
/** return -1 if *this < *rhs, 0 if *this==*rhs, 1 if *this>*rhs.*/
|
2003-03-12 05:42:55 +08:00
|
|
|
virtual int compare(const osg::StateAttribute& rhs) const;
|
2003-03-11 21:30:03 +08:00
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
/** Set the margin around each glyph, to ensure that texture filtering doesn't bleed adjacent glyph's into each other.*/
|
|
|
|
void setGlyphImageMargin(unsigned int margin) { _margin = margin; }
|
|
|
|
unsigned int getGlyphImageMargin() const { return _margin; }
|
|
|
|
|
2007-05-04 20:05:29 +08:00
|
|
|
void setGlyphImageMarginRatio(float margin) { _marginRatio = margin; }
|
|
|
|
float getGlyphImageMarginRatio() const { return _marginRatio; }
|
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
bool getSpaceForGlyph(Glyph* glyph, int& posX, int& posY);
|
2002-07-23 00:01:00 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
void addGlyph(Glyph* glyph,int posX, int posY);
|
|
|
|
|
|
|
|
virtual void apply(osg::State& state) const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2007-01-09 04:46:56 +08:00
|
|
|
/** Set whether to use a mutex to ensure ref() and unref() are thread safe.*/
|
|
|
|
virtual void setThreadSafeRefUnref(bool threadSafe);
|
|
|
|
|
|
|
|
/** Resize any per context GLObject buffers to specified size. */
|
|
|
|
virtual void resizeGLObjectBuffers(unsigned int maxSize);
|
|
|
|
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
protected:
|
2003-03-03 05:05:05 +08:00
|
|
|
|
|
|
|
virtual ~GlyphTexture();
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2007-09-04 20:32:47 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
// parameter used to compute the size and position of empty space
|
2007-12-11 01:30:18 +08:00
|
|
|
// in the texture which could accommodate new glyphs.
|
2003-03-07 01:11:24 +08:00
|
|
|
int _margin;
|
2007-05-04 20:05:29 +08:00
|
|
|
float _marginRatio;
|
2003-03-03 05:05:05 +08:00
|
|
|
int _usedY;
|
|
|
|
int _partUsedX;
|
|
|
|
int _partUsedY;
|
|
|
|
|
2003-03-04 00:12:00 +08:00
|
|
|
typedef std::vector< osg::ref_ptr<Glyph> > GlyphRefList;
|
|
|
|
typedef std::vector< const Glyph* > GlyphPtrList;
|
|
|
|
typedef osg::buffered_object< GlyphPtrList > GlyphBuffer;
|
2003-03-03 05:05:05 +08:00
|
|
|
|
2007-09-04 20:32:47 +08:00
|
|
|
GlyphRefList _glyphs;
|
|
|
|
mutable GlyphBuffer _glyphsToSubload;
|
|
|
|
|
|
|
|
mutable OpenThreads::Mutex _mutex;
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
};
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
class OSGTEXT_EXPORT Glyph : public osg::Image
|
|
|
|
{
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
public:
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2010-01-14 23:15:42 +08:00
|
|
|
Glyph(unsigned int glyphCode);
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2010-01-14 23:15:42 +08:00
|
|
|
unsigned int getGlyphCode() const { return _glyphCode; }
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setHorizontalBearing(const osg::Vec2& bearing);
|
|
|
|
const osg::Vec2& getHorizontalBearing() const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setHorizontalAdvance(float advance);
|
|
|
|
float getHorizontalAdvance() const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setVerticalBearing(const osg::Vec2& bearing);
|
|
|
|
const osg::Vec2& getVerticalBearing() const;
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setVerticalAdvance(float advance);
|
|
|
|
float getVerticalAdvance() const;
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setTexture(GlyphTexture* texture);
|
|
|
|
GlyphTexture* getTexture();
|
|
|
|
const GlyphTexture* getTexture() const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setTexturePosition(int posX,int posY);
|
|
|
|
int getTexturePositionX() const;
|
|
|
|
int getTexturePositionY() const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setMinTexCoord(const osg::Vec2& coord);
|
|
|
|
const osg::Vec2& getMinTexCoord() const;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
void setMaxTexCoord(const osg::Vec2& coord);
|
|
|
|
const osg::Vec2& getMaxTexCoord() const;
|
2003-03-03 05:05:05 +08:00
|
|
|
|
2003-03-04 00:12:00 +08:00
|
|
|
void subload() const;
|
2003-05-02 05:06:18 +08:00
|
|
|
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
protected:
|
|
|
|
|
2004-09-28 17:14:04 +08:00
|
|
|
virtual ~Glyph();
|
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
Font* _font;
|
|
|
|
unsigned int _glyphCode;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
osg::Vec2 _horizontalBearing;
|
|
|
|
float _horizontalAdvance;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
osg::Vec2 _verticalBearing;
|
|
|
|
float _verticalAdvance;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 00:12:00 +08:00
|
|
|
GlyphTexture* _texture;
|
2003-03-03 05:05:05 +08:00
|
|
|
int _texturePosX;
|
|
|
|
int _texturePosY;
|
|
|
|
osg::Vec2 _minTexCoord;
|
|
|
|
osg::Vec2 _maxTexCoord;
|
2003-05-02 05:06:18 +08:00
|
|
|
|
|
|
|
typedef osg::buffered_value<GLuint> GLObjectList;
|
|
|
|
mutable GLObjectList _globjList;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
};
|
2001-11-12 18:04:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
};
|
Added support for shallow and deep copy of nodes, drawables and state, via a
copy constructor which takes an optional Cloner object, and the old
osg::Object::clone() has changed so that it now requires a Cloner as paramter.
This is passed on to the copy constructor to help control the shallow vs
deep copying. The old functionality of clone() which was clone of type has
been renamed to cloneType().
Updated all of the OSG to work with these new conventions, implemention all
the required copy constructors etc. A couple of areas will do shallow
copies by design, a couple of other still need to be updated to do either
shallow or deep.
Neither of the shallow or deep copy operations have been tested yet, only
the old functionality of the OSG has been checked so far, such running the
viewer on various demo datasets.
Also fixed a problem in osg::Optimize::RemoveRendundentNodesVisitor which
was not checking that Group didn't have have any attached StateSet's, Callbacks
or UserData. These checks have now been added, which fixes a bug which was
revealled by the new osgscribe demo, this related to removal of group acting
as state decorator.
method
2002-01-29 05:17:01 +08:00
|
|
|
|
2002-02-03 20:33:41 +08:00
|
|
|
}
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
|
|
|
|
#endif
|