TexFont problem

Started by
1 comment, last by Wavesonics 17 years, 6 months ago
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?
==============================
A Developers Blog | Dark Rock Studios - My Site
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);
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.
==============================
A Developers Blog | Dark Rock Studios - My Site

This topic is closed to new replies.

Advertisement