views:

396

answers:

3

I'm using this tutorial, but the font isn't antialiased. The font size is big, so it should antialiased it, but it doesn't. Do I need to enable something in openGL to make it antialiased?

A: 

This really depend on the library which you use to render the fonts. See here for hints how to get proper rendering quality.

Aaron Digulla
A: 

im not using any libraries, just the tutorial code, which is (slightly modified):

GLvoid BuildFont(GLvoid)           // Build Our Bitmap Font
{
    HFONT font;          // Windows Font ID
    HFONT oldfont;         // Used For Good House Keeping

    base = glGenLists(256);        // Storage For 96 Characters

    font = CreateFont( -48,       // Height Of Font
         0,        // Width Of Font
         0,        // Angle Of Escapement
         0,        // Orientation Angle
         FW_NORMAL,      // Font Weight
         FALSE,       // Italic
         FALSE,       // Underline
         FALSE,       // Strikeout
         ANSI_CHARSET,     // Character Set Identifier
         OUT_TT_PRECIS,     // Output Precision
         CLIP_DEFAULT_PRECIS,   // Clipping Precision
         ANTIALIASED_QUALITY,   // Output Quality
         FF_DONTCARE|DEFAULT_PITCH,  // Family And Pitch
         "good times");     // Font Name

    oldfont = (HFONT)SelectObject(hDC, font);           // Selects The Font We Want
    wglUseFontBitmaps(hDC, 0, 256, base);    // Builds 96 Characters Starting At Character 32
    SelectObject(hDC, oldfont);       // Selects The Font We Want
    DeleteObject(font);         // Delete The Font
}

GLvoid KillFont(GLvoid){
    glDeleteLists(base, 256);
}

GLvoid glPrint(const char *fmt, ...){
    char  text[256];        // Holds Our String
    va_list  ap;          // Pointer To List Of Arguments

    if (fmt == NULL)         // If There's No Text
     return;           // Do Nothing

    va_start(ap, fmt);         // Parses The String For Variables
        vsprintf(text, fmt, ap);      // And Converts Symbols To Actual Numbers
    va_end(ap);           // Results Are Stored In Text

    glPushAttrib(GL_LIST_BIT);       // Pushes The Display List Bits
    glListBase(base - 0);        // Sets The Base Character to 32
    glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text
    glPopAttrib();          // Pops The Display List Bits
}

i have enabled blending, is there something im missing?

Polygon antialiasing is a bit more complex than just enabling blending. You may want to look into using SDL and SDL_ttf for your daily cup of texture fonts.
Ivan Vučica
A: 

I'm a fan of this system. Works quite well when transliterated to C++.

genpfault