Results 1 to 3 of 3

Thread: Urgent help needed. How can I use the glutBitmapCharacter to display ints? mdog1234?

  1. #1
    Senior Member Regular Contributor
    Join Date
    Jul 2003
    Location
    London
    Posts
    163

    Urgent help needed. How can I use the glutBitmapCharacter to display ints? mdog1234?

    mdog1234, you some code for me, which will use glutBitmapCharacter to display char*. I'm trying (with no luck) to rewrite that function so that it will display integers (>9999, that is over 4 digits long).
    How can I rewrite this function (below) to accept and display integers.
    I'd really appreciate your help.
    Thank you,
    Luke

    void Text: rintText (void* font, char* string, int x, int y) {

    if (string && strlen(string))
    {
    glPushMatrix();
    glLoadIdentity();
    glRasterPos2d(x,y);
    while (*string)
    {
    glutBitmapCharacter(font,*string);
    string++;
    }
    glPopMatrix();
    }

    }

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Urgent help needed. How can I use the glutBitmapCharacter to display ints? mdog1234?

    You have to use a function like itoa to convert say a int to a ascii number or use sprintf.

    Note itoa is not a standard C/C++ call (windows), for linux use the sprintf

    int score;
    char txt[32]; // space to put the converted data

    itoa(score, txt, 10); // base 10 conversion

    printText (...., txt, x, y);

    or

    sprintf( txt, "%6d", score ); // 6d = 000000 convert to six digits max

    [This message has been edited by nexusone (edited 10-24-2003).]

    [This message has been edited by nexusone (edited 10-24-2003).]

  3. #3
    Senior Member Regular Contributor
    Join Date
    Jul 2003
    Location
    London
    Posts
    163

    Re: Urgent help needed. How can I use the glutBitmapCharacter to display ints? mdog1234?

    OK, thank you for the help.

Similar Threads

  1. Urgent help needed please!
    By OreoMan in forum OpenGL: Windows
    Replies: 6
    Last Post: 11-04-2017, 02:34 PM
  2. Urgent help needed!!
    By Mikael Ara in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 11-18-2012, 12:55 PM
  3. Urgent Help Needed... PLZ
    By rahulraina7 in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-15-2012, 02:45 PM
  4. glutBitmapCharacter delayed display
    By newbie1002 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-02-2011, 02:56 PM
  5. PLEASE HELP! URGENT HELP NEEDED
    By iceblink2 in forum OpenGL: User Software
    Replies: 8
    Last Post: 01-10-2002, 07:57 PM

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