Results 1 to 4 of 4

Thread: text vanishes

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2003
    Location
    Pakistan
    Posts
    23

    text vanishes

    hello guys
    i am presently working in an application where i am using multiple fonts to display text . i am using NEHE bitmap font building and printing basecode for my different fonts
    the problem is that both the fonts are displaying on the screen alright but after two to three minutes of my applicatiuon run the text disappears but other drawing like trianles lines etc are ok . but the text vanishes . i used the following code
    // Our Bitmap Font1
    GLvoid BuildFont_1(GLvoid)
    {
    HFONT font; // Windows Font ID

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

    font_size = -11;

    font = CreateFont( font_size, // 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
    "Ariel"); // Font Name


    SelectObject(hDC, font);

    wglUseFontBitmaps(hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32
    }

    // bitmap font 2
    GLvoid BuildFont_2(GLvoid)
    {
    HFONT font; // Windows Font ID

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

    font_size = -15;

    font = CreateFont( font_size, // 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
    "Courier New"); // Font Name


    SelectObject(hDC, font);

    wglUseFontBitmaps(hDC, 32, 96, base); // Builds 96 Characters Starting At Character 32
    }


    GLvoid KillFont(GLvoid) // Delete The Font
    {
    glDeleteLists(base, 96); // Delete All 96 Characters ( NEW )
    }


    GLvoid glPrint(const char *fmt, ...) // Custom GL "Print" Routine
    {
    char text[256]; // Holds Our String
    va_list ap;

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

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


    glPushAttrib(GL_LIST_BIT); // Pushes The Display List Bits ( NEW )
    glListBase(base - 32);

    glCallLists(strlen(text), GL_UNSIGNED_BYTE, text); // Draws The Display List Text ( NEW )
    glPopAttrib(); // Pops The Display List Bits

    }


    i am calling the function buildfont_1 whenever i have to print using font1 before glprint function along with glRasterPos()and similarly i call buildfont_2 for font2
    can any body help me out

    thanks
    kashif

  2. #2
    Senior Member OpenGL Pro
    Join Date
    May 2001
    Location
    Kristianstad,Skåne,Sweden
    Posts
    1,595

    Re: text vanishes

    Hi !

    Do you mean that you call the buildfont functions many times ? if so, then that's the problem, they genererate a number of display list data that you never erase as far as I can tell, so after a little while you will run out of memory.

    You need to erase the old display lists first and you should only call the build functions when you have to.

    Mikael

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jul 2000
    Location
    Arlon, Belgium
    Posts
    477

    Re: text vanishes

    Why don't you use 2 differents textures for your font ?

    Texture1 and 2 and before drawing your text, just change the texture number ?

    Not ?

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2003
    Location
    Pakistan
    Posts
    23

    Re: text vanishes

    hello mikael_aronsson
    i read your reply but how can i erase my old display list and use new and then erase that and use previous one please provide me with some help .
    how can i make a texture of different fonts
    thaks

Similar Threads

  1. Text rendering class does not draw text
    By th0masr0ss in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 01-23-2015, 09:10 PM
  2. Image vanishes when I call glutpostredisplay()
    By lunixer in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 10-10-2011, 08:34 AM
  3. Image vanishes on resize
    By Jon Jacobs in forum OpenGL: Basic Coding
    Replies: 12
    Last Post: 06-13-2008, 12:55 PM
  4. text vanishes
    By kashif saeed in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 05-14-2003, 09:02 PM
  5. Replies: 0
    Last Post: 11-15-2002, 02:58 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean