From Max, fixes to UniCode support for bitmap fonts.

This commit is contained in:
Robert Osfield 2003-01-30 01:31:22 +00:00
parent 8422040e97
commit 787bbef714
3 changed files with 95 additions and 56 deletions

View File

@ -235,12 +235,14 @@ void setScene(osg::Group* rootNode)
geode->setName("BitmapFont");
geode->addDrawable( text );
// textMaterial = new osg::Material();
// textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
// textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
// textState = new osg::StateSet();
// textState->setAttribute(textMaterial );
// geode->setStateSet( textState );
/*
osg::Material* textMaterial = new osg::Material();
textMaterial->setColorMode( osg::Material::AMBIENT_AND_DIFFUSE);
textMaterial->setDiffuse( osg::Material::FRONT_AND_BACK,TEXT_COL_3D);
textState = new osg::StateSet();
textState->setAttribute(textMaterial );
geode->setStateSet( textState );
*/
rootNode->addChild(geode);
@ -309,7 +311,8 @@ void setScene(osg::Group* rootNode)
// textState->setAttribute(textMaterial );
textState->setAttribute(transp);
// textState->setMode(GL_BLEND,osg::StateAttribute::ON);
textState->setMode(GL_BLEND,osg::StateAttribute::ON);
textState->setTextureMode(0,GL_TEXTURE_2D,osg::StateAttribute::ON);
textState->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
geode->setStateSet( textState );
@ -463,57 +466,61 @@ protected:
}
virtual void keyboard(int key, int x, int y)
virtual void keyboard(int key, int x, int y, bool keydown)
{
switch(key)
if (keydown)
{
case '1':
{ // change DrawMode
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setDrawMode(osgText::Text::TEXT ^ (*itr)->getDrawMode());
}
return;
case '2':
{ // change DrawMode
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setDrawMode(osgText::Text::BOUNDINGBOX ^ (*itr)->getDrawMode());
}
return;
case '3':
{ // change DrawMode
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setDrawMode(osgText::Text::ALIGNMENT ^ (*itr)->getDrawMode());
}
return;
///////////////////////////////////////////////////////////////////
case '4':
{ // change BoundingBoxType to GEOMETRY
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
osgText::Text::BoundingBoxType type=(*itr)->getBoundingBox()==osgText::Text::GLYPH ?
osgText::Text::GEOMETRY :
osgText::Text::GLYPH;
for(;itr!=gTextList.end();itr++)
(*itr)->setBoundingBox(type);
}
return;
///////////////////////////////////////////////////////////////////
case '5':
{ // change the textAlignment
gAlignment=(osgText::Text::AlignmentType)((int)gAlignment+1);
if(gAlignment>osgText::Text::RIGHT_BOTTOM)
gAlignment=osgText::Text::LEFT_TOP;
switch(key)
{
case '1':
{ // change DrawMode
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setDrawMode(osgText::Text::TEXT ^ (*itr)->getDrawMode());
}
return;
case '2':
{ // change DrawMode
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setDrawMode(osgText::Text::BOUNDINGBOX ^ (*itr)->getDrawMode());
}
return;
case '3':
{ // change DrawMode
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setDrawMode(osgText::Text::ALIGNMENT ^ (*itr)->getDrawMode());
}
return;
///////////////////////////////////////////////////////////////////
case '4':
{ // change BoundingBoxType to GEOMETRY
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
osgText::Text::BoundingBoxType type=(*itr)->getBoundingBox()==osgText::Text::GLYPH ?
osgText::Text::GEOMETRY :
osgText::Text::GLYPH;
for(;itr!=gTextList.end();itr++)
(*itr)->setBoundingBox(type);
}
return;
///////////////////////////////////////////////////////////////////
case '5':
{ // change the textAlignment
gAlignment=(osgText::Text::AlignmentType)((int)gAlignment+1);
if(gAlignment>osgText::Text::RIGHT_BOTTOM)
gAlignment=osgText::Text::LEFT_TOP;
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setAlignment(gAlignment);
}
return;
default:
Viewer::keyboard(key,x,y);
};
std::vector<osg::ref_ptr<osgText::Text> >::iterator itr=gTextList.begin();
for(;itr!=gTextList.end();itr++)
(*itr)->setAlignment(gAlignment);
}
return;
default:
break;
}
}
Viewer::keyboard(key,x,y,keydown);
}
};

View File

@ -65,10 +65,33 @@ void FTGLBitmapFont::render( const wchar_t* string,unsigned int renderContext)
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
#if (FREETYPE_MAJOR >= 2) && (FREETYPE_MINOR>=1)
glPixelStorei( GL_UNPACK_ALIGNMENT, 2);
#else
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
#endif
FTFont::render( string,renderContext);
glPopClientAttrib();
}
// mrn@changes
void FTGLBitmapFont::render( std::vector<int>::const_iterator first,
std::vector<int>::const_iterator last,
unsigned int renderContext)
{
glPushClientAttrib( GL_CLIENT_PIXEL_STORE_BIT);
glPixelStorei( GL_UNPACK_LSB_FIRST, GL_FALSE);
glPixelStorei( GL_UNPACK_ROW_LENGTH, 0);
#if (FREETYPE_MAJOR >= 2) && (FREETYPE_MINOR>=1)
glPixelStorei( GL_UNPACK_ALIGNMENT, 2);
#else
glPixelStorei( GL_UNPACK_ALIGNMENT, 1);
#endif
FTFont::render( first,last,renderContext);
glPopClientAttrib();
}

View File

@ -43,6 +43,15 @@ class FTGL_EXPORT FTGLBitmapFont : public FTFont
// mrn@changes
void render( const wchar_t* string, unsigned int renderContext=0);
/**
* Renders a string of characters
*
* @param string unicode string to be output.
*/
// mrn@changes
void render( std::vector<int>::const_iterator first,
std::vector<int>::const_iterator last,
unsigned int renderContext=0);
// attributes
private: