2005-04-15 05:41:28 +08:00
|
|
|
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 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>
|
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
#include <osg/Vec2>
|
|
|
|
#include <osg/Image>
|
|
|
|
#include <osg/Texture2D>
|
|
|
|
#include <osg/StateSet>
|
|
|
|
#include <osg/buffered_value>
|
2003-12-09 19:31:33 +08:00
|
|
|
#include <osg/TexEnv>
|
2001-11-12 18:04:57 +08:00
|
|
|
|
|
|
|
#include <osgText/Export>
|
|
|
|
|
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;
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-06-27 00:21:49 +08:00
|
|
|
enum KerningType
|
|
|
|
{
|
|
|
|
KERNING_DEFAULT, //default locked to integer kerning values
|
2004-01-25 04:50:33 +08:00
|
|
|
KERNING_UNFITTED, //use floating point value for kerning
|
|
|
|
KERNING_NONE //no kerning
|
2003-06-27 00:21:49 +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.
|
|
|
|
*/
|
2003-03-03 05:05:05 +08:00
|
|
|
extern OSGTEXT_EXPORT Font* readFontFile(const std::string& filename);
|
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
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
/** Set the pixel width and height hint.*/
|
2005-01-27 19:10:50 +08:00
|
|
|
virtual void setFontResolution(unsigned int width, unsigned int height);
|
2003-03-03 05:05:05 +08:00
|
|
|
|
2005-01-27 19:10:50 +08:00
|
|
|
unsigned int getFontWidth() const;
|
|
|
|
unsigned int getFontHeight() const;
|
2001-11-12 18:04:57 +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.*/
|
|
|
|
virtual osg::Vec2 getKerning(unsigned int leftcharcode,unsigned int rightcharcode, KerningType kerningType);
|
|
|
|
|
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.*/
|
|
|
|
virtual Glyph* getGlyph(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.
|
|
|
|
* Default margin is 2 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
|
|
|
|
|
|
|
/** 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
|
|
|
|
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
|
|
|
|
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();
|
|
|
|
|
2003-03-04 20:34:42 +08:00
|
|
|
void addGlyph(unsigned int width, unsigned int height, 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;
|
|
|
|
|
2003-03-04 20:34:42 +08:00
|
|
|
typedef std::pair< unsigned int, unsigned int > SizePair;
|
|
|
|
typedef std::map< SizePair, GlyphMap > SizeGlyphMap;
|
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
SizeGlyphMap _sizeGlyphMap;
|
|
|
|
GlyphTextureList _glyphTextureList;
|
|
|
|
StateSetList _stateSetList;
|
2003-03-04 20:34:42 +08:00
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
// current active size of font
|
2003-03-07 01:11:24 +08:00
|
|
|
unsigned int _width;
|
|
|
|
unsigned int _height;
|
|
|
|
unsigned int _margin;
|
|
|
|
|
|
|
|
unsigned int _textureWidthHint;
|
|
|
|
unsigned int _textureHeightHint;
|
|
|
|
osg::Texture::FilterMode _minFilterHint;
|
|
|
|
osg::Texture::FilterMode _magFilterHint;
|
|
|
|
|
2003-12-09 19:31:33 +08:00
|
|
|
osg::ref_ptr<osg::TexEnv > _texEnv;
|
|
|
|
|
2003-03-07 01:11:24 +08:00
|
|
|
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:
|
|
|
|
|
|
|
|
virtual std::string getFileName() const = 0;
|
|
|
|
|
|
|
|
/** Set the pixel width and height hint.*/
|
2005-01-27 19:10:50 +08:00
|
|
|
virtual void setFontResolution(unsigned int width, unsigned int height) = 0;
|
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.*/
|
|
|
|
virtual Glyph* getGlyph(unsigned int charcode) = 0;
|
|
|
|
|
|
|
|
/** Get a kerning (adjustment of spacing of two adjacent character) for specified charcodes, w.r.t the current font size hint.*/
|
2003-06-27 00:21:49 +08:00
|
|
|
virtual osg::Vec2 getKerning(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;
|
|
|
|
|
2005-01-27 19:10:50 +08:00
|
|
|
void setFontWidth(unsigned int width) { _facade->_width = width; }
|
2003-03-07 01:11:24 +08:00
|
|
|
|
2005-01-27 19:10:50 +08:00
|
|
|
void setFontHeight(unsigned int height) { _facade->_height = height; }
|
2003-03-07 01:11:24 +08:00
|
|
|
|
|
|
|
void addGlyph(unsigned int width, unsigned int height, unsigned int charcode, Glyph* glyph)
|
|
|
|
{
|
|
|
|
_facade->addGlyph(width, height, charcode, glyph);
|
|
|
|
}
|
|
|
|
|
|
|
|
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-03 05:05:05 +08:00
|
|
|
void setStateSet(osg::StateSet* stateset) { _stateset = stateset; }
|
|
|
|
osg::StateSet* getStateSet() { return _stateset; }
|
|
|
|
const osg::StateSet* getStateSet() const { return _stateset; }
|
2001-11-12 18:04:57 +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; }
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
osg::StateSet* _stateset;
|
|
|
|
|
|
|
|
// parameter used to compute the size and position of empty space
|
|
|
|
// in the texture which could accomodate new glyphs.
|
2003-03-07 01:11:24 +08:00
|
|
|
int _margin;
|
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
|
|
|
|
2003-03-04 00:12:00 +08:00
|
|
|
GlyphRefList _glyphs;
|
2003-03-03 05:05:05 +08:00
|
|
|
mutable GlyphBuffer _glyphsToSubload;
|
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
|
|
|
|
2003-03-03 05:05:05 +08:00
|
|
|
Glyph();
|
2001-11-12 18:04:57 +08:00
|
|
|
|
2003-03-04 06:18:33 +08:00
|
|
|
unsigned int getGlyphCode() const;
|
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
|
|
|
osg::StateSet* getStateSet();
|
|
|
|
const osg::StateSet* getStateSet() 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
|
|
|
|
|
|
|
void draw(osg::State& state) 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
|
|
|
|
|
|
|
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
|