Further work on getting osgText compiling.
This commit is contained in:
21
src/Demos/osgtext/Makefile
Normal file
21
src/Demos/osgtext/Makefile
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!smake
|
||||||
|
include ../../../Make/makedefs
|
||||||
|
|
||||||
|
C++FILES = \
|
||||||
|
main.cpp
|
||||||
|
|
||||||
|
TARGET = ../../../bin/osgtext
|
||||||
|
|
||||||
|
TARGET_BIN_FILES = osgtext
|
||||||
|
|
||||||
|
#note, use this library list when using the Performer osgPlugin.
|
||||||
|
#LIBS = ${PFLIBS} -losgGLUT -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||||
|
|
||||||
|
#note, standard library list.
|
||||||
|
LIBS = -losgGLUT -losgText -losgUtil -losgDB -losg $(GLUTLIB) -lGLU -lGL -lm -lXmu -lX11 -lXi
|
||||||
|
|
||||||
|
C++FLAGS += -I../../../include -g
|
||||||
|
LDFLAGS += -L../../../lib
|
||||||
|
|
||||||
|
include ../../../Make/makerules
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@
|
|||||||
#include <osgGLUT/Viewer>
|
#include <osgGLUT/Viewer>
|
||||||
#include <GL/glut.h>
|
#include <GL/glut.h>
|
||||||
|
|
||||||
#include <osgText/text.h>
|
#include <osgText/Text>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
|
|
||||||
@@ -47,74 +47,74 @@ std::string ttfPath1("./fonts/verdana.ttf");
|
|||||||
int gFontSize=18;
|
int gFontSize=18;
|
||||||
int gFontSize1=24;
|
int gFontSize1=24;
|
||||||
std::vector<osg::ref_ptr<osgText::Text > > gTextList;
|
std::vector<osg::ref_ptr<osgText::Text > > gTextList;
|
||||||
osgText::Text::AlignmentType gAlignement=osgText::Text::AlignmentType::LEFT_BOTTOM;
|
osgText::Text::AlignmentType gAlignement=osgText::Text::LEFT_BOTTOM;
|
||||||
|
|
||||||
|
|
||||||
void set2dScene(osg::Group* rootNode)
|
void set2dScene(osg::Group* rootNode)
|
||||||
{
|
{
|
||||||
osgText::Text* text;
|
osgText::Text* text;
|
||||||
osg::Geode* geode;
|
osg::Geode* geode;
|
||||||
osg::Material* textMaterial;
|
osg::Material* textMaterial;
|
||||||
osg::Vec4 textColor;
|
osg::Vec4 textColor;
|
||||||
osg::StateSet* textState;
|
osg::StateSet* textState;
|
||||||
double xOffset=250;
|
double xOffset=250;
|
||||||
double yOffset=gFontSize+10;
|
double yOffset=gFontSize+10;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setup the texts
|
// setup the texts
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// BitmapFont
|
// BitmapFont
|
||||||
osgText::BitmapFont* bitmapFont=new osgText::BitmapFont(ttfPath,
|
osgText::BitmapFont* bitmapFont=new osgText::BitmapFont(ttfPath,
|
||||||
gFontSize1);
|
gFontSize1);
|
||||||
text=new osgText::Text(bitmapFont);
|
text=new osgText::Text(bitmapFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string("2d ")+std::string(TEXT_BITMAP));
|
text->setText(std::string("2d ")+std::string(TEXT_BITMAP));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("BitmapFont");
|
geode->setName("BitmapFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
geode->setStateSet( textState );
|
geode->setStateSet( textState );
|
||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
xOffset+=90;
|
xOffset+=90;
|
||||||
yOffset+=120;
|
yOffset+=120;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// PixmapFont
|
// PixmapFont
|
||||||
osgText::PixmapFont* pixmapFont=new osgText::PixmapFont(ttfPath,
|
osgText::PixmapFont* pixmapFont=new osgText::PixmapFont(ttfPath,
|
||||||
gFontSize1);
|
gFontSize1);
|
||||||
text=new osgText::Text(pixmapFont);
|
text=new osgText::Text(pixmapFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string("2d ")+std::string(TEXT_PIXMAP));
|
text->setText(std::string("2d ")+std::string(TEXT_PIXMAP));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("PixmapFont");
|
geode->setName("PixmapFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_2D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_2D);
|
||||||
// to get antiaA pixmapFonts we have to draw them with blending
|
// to get antiaA pixmapFonts we have to draw them with blending
|
||||||
osg::Transparency *transp=new osg::Transparency();
|
osg::Transparency *transp=new osg::Transparency();
|
||||||
transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
textState->setAttribute(transp);
|
textState->setAttribute(transp);
|
||||||
textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||||
@@ -123,33 +123,33 @@ void set2dScene(osg::Group* rootNode)
|
|||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
xOffset+=90;
|
xOffset+=90;
|
||||||
yOffset+=120;
|
yOffset+=120;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// TextureFont
|
// TextureFont
|
||||||
osgText::TextureFont* textureFont=new osgText::TextureFont(ttfPath1,
|
osgText::TextureFont* textureFont=new osgText::TextureFont(ttfPath1,
|
||||||
gFontSize1);
|
gFontSize1);
|
||||||
text=new osgText::Text(textureFont);
|
text=new osgText::Text(textureFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string("2d ")+std::string(TEXT_TEXTURE));
|
text->setText(std::string("2d ")+std::string(TEXT_TEXTURE));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("TextureFont");
|
geode->setName("TextureFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||||
// to get antiaA pixmapFonts we have to draw them with blending
|
// to get antiaA pixmapFonts we have to draw them with blending
|
||||||
transp=new osg::Transparency();
|
transp=new osg::Transparency();
|
||||||
transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
textState->setAttribute(transp);
|
textState->setAttribute(transp);
|
||||||
|
|
||||||
@@ -159,129 +159,129 @@ void set2dScene(osg::Group* rootNode)
|
|||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
xOffset+=90;
|
xOffset+=90;
|
||||||
yOffset+=120;
|
yOffset+=120;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// PolygonFont
|
// PolygonFont
|
||||||
osgText::PolygonFont* polygonFont=new osgText::PolygonFont(ttfPath,
|
osgText::PolygonFont* polygonFont=new osgText::PolygonFont(ttfPath,
|
||||||
gFontSize1,
|
gFontSize1,
|
||||||
3);
|
3);
|
||||||
text=new osgText::Text(polygonFont);
|
text=new osgText::Text(polygonFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string("2d ")+std::string("TEXT_POLYGON"));
|
text->setText(std::string("2d ")+std::string("TEXT_POLYGON"));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("PolygonFont");
|
geode->setName("PolygonFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
geode->setStateSet( textState );
|
geode->setStateSet( textState );
|
||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
xOffset+=90;
|
xOffset+=90;
|
||||||
yOffset+=120;
|
yOffset+=120;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// OutlineFont
|
// OutlineFont
|
||||||
osgText::OutlineFont* outlineFont=new osgText::OutlineFont(ttfPath,
|
osgText::OutlineFont* outlineFont=new osgText::OutlineFont(ttfPath,
|
||||||
gFontSize1,
|
gFontSize1,
|
||||||
3);
|
3);
|
||||||
|
|
||||||
text=new osgText::Text(outlineFont);
|
text=new osgText::Text(outlineFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string("2d ")+std::string(TEXT_OUTLINE));
|
text->setText(std::string("2d ")+std::string(TEXT_OUTLINE));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("OutlineFont");
|
geode->setName("OutlineFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK, TEXT_COL_2D);
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
geode->setStateSet( textState );
|
geode->setStateSet( textState );
|
||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
}
|
}
|
||||||
|
|
||||||
void setScene(osg::Group* rootNode)
|
void setScene(osg::Group* rootNode)
|
||||||
{
|
{
|
||||||
osgText::Text* text;
|
osgText::Text* text;
|
||||||
osg::Geode* geode;
|
osg::Geode* geode;
|
||||||
osg::Material* textMaterial;
|
osg::Material* textMaterial;
|
||||||
osg::Vec4 textColor;
|
osg::Vec4 textColor;
|
||||||
osg::StateSet* textState;
|
osg::StateSet* textState;
|
||||||
double xOffset=0;
|
double xOffset=0;
|
||||||
double yOffset=0;
|
double yOffset=0;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// setup the texts
|
// setup the texts
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// BitmapFont
|
// BitmapFont
|
||||||
osgText::BitmapFont* bitmapFont=new osgText::BitmapFont(ttfPath,
|
osgText::BitmapFont* bitmapFont=new osgText::BitmapFont(ttfPath,
|
||||||
gFontSize);
|
gFontSize);
|
||||||
text=new osgText::Text(bitmapFont);
|
text=new osgText::Text(bitmapFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string(TEXT_BITMAP));
|
text->setText(std::string(TEXT_BITMAP));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("BitmapFont");
|
geode->setName("BitmapFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
geode->setStateSet( textState );
|
geode->setStateSet( textState );
|
||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
yOffset+=gFontSize+5;
|
yOffset+=gFontSize+5;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// PixmapFont
|
// PixmapFont
|
||||||
osgText::PixmapFont* pixmapFont=new osgText::PixmapFont(ttfPath,
|
osgText::PixmapFont* pixmapFont=new osgText::PixmapFont(ttfPath,
|
||||||
gFontSize);
|
gFontSize);
|
||||||
text=new osgText::Text(pixmapFont);
|
text=new osgText::Text(pixmapFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string(TEXT_PIXMAP));
|
text->setText(std::string(TEXT_PIXMAP));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("PixmapFont");
|
geode->setName("PixmapFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
||||||
// to get antiaA pixmapFonts we have to draw them with blending
|
// to get antiaA pixmapFonts we have to draw them with blending
|
||||||
osg::Transparency *transp=new osg::Transparency();
|
osg::Transparency *transp=new osg::Transparency();
|
||||||
transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
transp->setFunction(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
textState->setAttribute(transp);
|
textState->setAttribute(transp);
|
||||||
textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||||
@@ -290,98 +290,98 @@ void setScene(osg::Group* rootNode)
|
|||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
yOffset+=gFontSize+5;
|
yOffset+=gFontSize+5;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// TextureFont
|
// TextureFont
|
||||||
osgText::TextureFont* textureFont=new osgText::TextureFont(ttfPath,
|
osgText::TextureFont* textureFont=new osgText::TextureFont(ttfPath,
|
||||||
gFontSize);
|
gFontSize);
|
||||||
text=new osgText::Text(textureFont);
|
text=new osgText::Text(textureFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string(TEXT_TEXTURE));
|
text->setText(std::string(TEXT_TEXTURE));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("TextureFont");
|
geode->setName("TextureFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
||||||
// to get antiaA pixmapFonts we have to draw them with blending
|
// to get antiaA pixmapFonts we have to draw them with blending
|
||||||
transp=new osg::Transparency();
|
transp=new osg::Transparency();
|
||||||
transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
transp->setFunction(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
textState->setAttribute(transp);
|
textState->setAttribute(transp);
|
||||||
|
|
||||||
// textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
// textState->setMode(GL_BLEND,osg::StateAttribute::ON);
|
||||||
textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON);
|
textState->setMode(GL_TEXTURE_2D,osg::StateAttribute::ON);
|
||||||
textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
|
||||||
geode->setStateSet( textState );
|
geode->setStateSet( textState );
|
||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
yOffset+=gFontSize+5;
|
yOffset+=gFontSize+5;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// PolygonFont
|
// PolygonFont
|
||||||
osgText::PolygonFont* polygonFont=new osgText::PolygonFont(ttfPath,
|
osgText::PolygonFont* polygonFont=new osgText::PolygonFont(ttfPath,
|
||||||
gFontSize,
|
gFontSize,
|
||||||
3);
|
3);
|
||||||
text=new osgText::Text(polygonFont);
|
text=new osgText::Text(polygonFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string(TEXT_POLYGON));
|
text->setText(std::string(TEXT_POLYGON));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("PolygonFont");
|
geode->setName("PolygonFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
geode->setStateSet( textState );
|
geode->setStateSet( textState );
|
||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
yOffset+=gFontSize+5;
|
yOffset+=gFontSize+5;
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////
|
||||||
// OutlineFont
|
// OutlineFont
|
||||||
osgText::OutlineFont* outlineFont=new osgText::OutlineFont(ttfPath,
|
osgText::OutlineFont* outlineFont=new osgText::OutlineFont(ttfPath,
|
||||||
gFontSize,
|
gFontSize,
|
||||||
3);
|
3);
|
||||||
|
|
||||||
text=new osgText::Text(outlineFont);
|
text=new osgText::Text(outlineFont);
|
||||||
gTextList.push_back(text);
|
gTextList.push_back(text);
|
||||||
text->setText(std::string(TEXT_OUTLINE));
|
text->setText(std::string(TEXT_OUTLINE));
|
||||||
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
text->setPosition(osg::Vec3(xOffset,yOffset,0));
|
||||||
text->setDrawMode( osgText::Text::DrawModeType::TEXT |
|
text->setDrawMode( osgText::Text::TEXT |
|
||||||
osgText::Text::DrawModeType::BOUNDINGBOX |
|
osgText::Text::BOUNDINGBOX |
|
||||||
osgText::Text::DrawModeType::ALIGNEMENT );
|
osgText::Text::ALIGNEMENT );
|
||||||
text->setAlignement(gAlignement);
|
text->setAlignement(gAlignement);
|
||||||
geode = new osg::Geode();
|
geode = new osg::Geode();
|
||||||
geode->setName("OutlineFont");
|
geode->setName("OutlineFont");
|
||||||
geode->addDrawable( text );
|
geode->addDrawable( text );
|
||||||
|
|
||||||
textMaterial = new osg::Material();
|
textMaterial = new osg::Material();
|
||||||
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
|
||||||
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
|
||||||
textState = new osg::StateSet();
|
textState = new osg::StateSet();
|
||||||
textState->setAttribute(textMaterial );
|
textState->setAttribute(textMaterial );
|
||||||
geode->setStateSet( textState );
|
geode->setStateSet( textState );
|
||||||
|
|
||||||
rootNode->addChild(geode);
|
rootNode->addChild(geode);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -471,30 +471,30 @@ protected:
|
|||||||
{ // change DrawMode
|
{ // change DrawMode
|
||||||
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
||||||
for(;itr!=gTextList.end();itr++)
|
for(;itr!=gTextList.end();itr++)
|
||||||
(*itr)->setDrawMode(osgText::Text::DrawModeType::TEXT ^ (*itr)->getDrawMode());
|
(*itr)->setDrawMode(osgText::Text::TEXT ^ (*itr)->getDrawMode());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case '2':
|
case '2':
|
||||||
{ // change DrawMode
|
{ // change DrawMode
|
||||||
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
||||||
for(;itr!=gTextList.end();itr++)
|
for(;itr!=gTextList.end();itr++)
|
||||||
(*itr)->setDrawMode(osgText::Text::DrawModeType::BOUNDINGBOX ^ (*itr)->getDrawMode());
|
(*itr)->setDrawMode(osgText::Text::BOUNDINGBOX ^ (*itr)->getDrawMode());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
case '3':
|
case '3':
|
||||||
{ // change DrawMode
|
{ // change DrawMode
|
||||||
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
||||||
for(;itr!=gTextList.end();itr++)
|
for(;itr!=gTextList.end();itr++)
|
||||||
(*itr)->setDrawMode(osgText::Text::DrawModeType::ALIGNEMENT ^ (*itr)->getDrawMode());
|
(*itr)->setDrawMode(osgText::Text::ALIGNEMENT ^ (*itr)->getDrawMode());
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
///////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////
|
||||||
case '4':
|
case '4':
|
||||||
{ // change BoundingBoxType to GEOMETRY
|
{ // change BoundingBoxType to GEOMETRY
|
||||||
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
||||||
osgText::Text::BoundingBoxType type=(*itr)->getBoundingBox()==osgText::Text::BoundingBoxType::GLYPH ?
|
osgText::Text::BoundingBoxType type=(*itr)->getBoundingBox()==osgText::Text::GLYPH ?
|
||||||
osgText::Text::BoundingBoxType::GEOMETRY :
|
osgText::Text::GEOMETRY :
|
||||||
osgText::Text::BoundingBoxType::GLYPH;
|
osgText::Text::GLYPH;
|
||||||
for(;itr!=gTextList.end();itr++)
|
for(;itr!=gTextList.end();itr++)
|
||||||
(*itr)->setBoundingBox(type);
|
(*itr)->setBoundingBox(type);
|
||||||
}
|
}
|
||||||
@@ -503,8 +503,8 @@ protected:
|
|||||||
case '5':
|
case '5':
|
||||||
{ // change the textAlignement
|
{ // change the textAlignement
|
||||||
gAlignement=(osgText::Text::AlignmentType)((int)gAlignement+1);
|
gAlignement=(osgText::Text::AlignmentType)((int)gAlignement+1);
|
||||||
if(gAlignement>osgText::Text::AlignmentType::RIGHT_BOTTOM)
|
if(gAlignement>osgText::Text::RIGHT_BOTTOM)
|
||||||
gAlignement=osgText::Text::AlignmentType::LEFT_TOP;
|
gAlignement=osgText::Text::LEFT_TOP;
|
||||||
|
|
||||||
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
|
||||||
for(;itr!=gTextList.end();itr++)
|
for(;itr!=gTextList.end();itr++)
|
||||||
|
|||||||
@@ -24,10 +24,10 @@ C++FILES = \
|
|||||||
Version.cpp
|
Version.cpp
|
||||||
|
|
||||||
|
|
||||||
TARGET_BASENAME = osgGLUT
|
TARGET_BASENAME = osgText
|
||||||
|
|
||||||
|
|
||||||
LIBS = -L../../lib -losgDB -losgUtil -losg $(GLUTLIB) -lGLU -lGL -lm
|
LIBS = -L../../lib -lfreetype -losgDB -losgUtil -losg -lGLU -lGL -lm
|
||||||
|
|
||||||
LIB = ../../lib/lib$(TARGET_BASENAME).so
|
LIB = ../../lib/lib$(TARGET_BASENAME).so
|
||||||
#LIB = ../../lib/lib$(TARGET_BASENAME).a
|
#LIB = ../../lib/lib$(TARGET_BASENAME).a
|
||||||
@@ -38,7 +38,7 @@ TARGET_INCLUDE_FILES = \
|
|||||||
osgText/Version\
|
osgText/Version\
|
||||||
osgText/Text
|
osgText/Text
|
||||||
|
|
||||||
C++FLAGS += -I ../../include -I /usr/local/include/freetype2 -I /usr/local/include/freetype2/freetype
|
C++FLAGS += -I ../../include -I /usr/local/include/freetype2
|
||||||
|
|
||||||
include ../../Make/makerules
|
include ../../Make/makerules
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user