OpenGL TexFont problem

This topic is 4478 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi, I'm using TexFont (which is a C Texture mapped font library) to render text in my 3D engine. I have it compiling and running but all my text just comes out as blocks: Heres my font set up:
bool Visitor::setUpFonts() {
bool success = true;

if ( ptrFont == NULL )
success = false;
else
txfEstablishTexture( ptrFont, 0, GL_FALSE );

return success;
}


Heres my font printing function:
void Visitor::visit( Text2DNode* ptrText2DNode ) {
string strText = dynamic_cast<Text2D*>(ptrText2DNode->getResource())->getString();
char *ptrcText = const_cast<char*>( strText.c_str() );

Logger l;
l.quickLog("Text2D.txt", strText);

OpenMode2D();

glAlphaFunc(GL_GEQUAL, 0.0625);
glEnable(GL_ALPHA_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

glPushMatrix();
glEnable( GL_TEXTURE_2D );
glMatrixMode(GL_MODELVIEW);
glTranslated( 100.0, 80.0, 0.0 );
glColor3d( 1.0, 0.0, 0.0 );
txfRenderString( ptrFont, ptrcText, strlen(ptrcText) );
glPopMatrix();

glDisable(GL_BLEND);
CloseMode2D();
}


Now in the txfLoadFont() function i did go in and change:
Quote:
 #if 1 /* XXX Indigo2 IMPACT in IRIX 5.3 and 6.2 does not support the GL_INTENSITY internal texture format. Sigh. Win32 non-GLX users should disable this code. */ if (useLuminanceAlpha == 0) {
to:
Quote:
 #if 0
Which took care of a crash problem when rendering text. Also PolygonOffset is off. I am rendering the text in orthographic mode. So any ideas why it's readning all screwed up?

Share on other sites
no idea about the font library, but if it says disable in non GL-X systems and your not running linux then that should be fine.

It looks like your fonts just aren't being textured. Assuming the txf function dosn't have any problems with mapping the geometry, try moving the glEnable(GL_TEXTURE_2D) call after you change the matrix mode to model view. I'm not 100% sure myself, but i think i remeber having problems with enabling and setting this with the wrong matrix mode before.

try rendering a textured cube instead of your text, i imagine that it wont work. You can also try glEnable(GL_TEXTURE0);

Share on other sites
Awesome thanks for the reply man, I'll try these things out to night.

I also found a discussion where they were talking bout how the texture might be much larger then the polygon so it would look like this. So i'm going to play with scaling also.

• What is your GameDev Story?

In 2019 we are celebrating 20 years of GameDev.net! Share your GameDev Story with us.

• 24
• 15
• 10
• 10
• 11
• Forum Statistics

• Total Topics
634098
• Total Posts
3015521
×