Jump to content
  • Advertisement
Sign in to follow this  
Wavesonics

OpenGL TexFont problem

This topic is 4323 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;
    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 this post


Link to post
Share on other sites
Advertisement
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 GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!