Advertisement Jump to content
Sign in to follow this  

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.

If you intended to correct an error in the post then please contact us.

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: TexFont text Heres my font set up:
bool Visitor::setUpFonts() {
    bool success = true;

    ptrFont = txfLoadFont("data/fonts/default.txf");

    if ( ptrFont == NULL )
        success = false;
        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);


        glAlphaFunc(GL_GEQUAL, 0.0625);

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


Now in the txfLoadFont() function i did go in and change:
#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) {
#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 this post

Link to post
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 this post

Link to post
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.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!