Results 1 to 5 of 5

Thread: writing numbers on the screen

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    gainesville, fla, usa
    Posts
    17

    writing numbers on the screen

    Hi,
    I want to display a set of 3D (float) coordinates on the screen. I know you can use glRasterPos and glutBitmapCharacter to display a character but I am lost on writing float values. Any help is appreciated.

  2. #2
    Senior Member Regular Contributor nickels's Avatar
    Join Date
    Feb 2000
    Location
    Colorado
    Posts
    284

    Re: writing numbers on the screen

    I don't know, but if you can display any character, can you do something like this:

    float x;
    char *ptr;
    char buf[1024];
    x = 3.14 (etc...)
    sprintf(buf, "%f", x);
    for(ptr = &buf[0]; ptr; ptr++)
    {
    display_gl_char(*ptr);
    }

  3. #3
    Member Contributor
    Join Date
    Feb 2000
    Location
    San Diego Ca, USA
    Posts
    50

    Re: writing numbers on the screen

    use sprintf()
    this is what I got to work...

    char str[] //storage for string

    sprintf(str, "myfloat: %f", outputVar);

    glRasterPos2f(-50, -50);
    len = (int)strlen(str);
    for (i=0; i<len; i++)
    {
    glutBitmapCharacter(hudFont, str[i]);
    }




    [This message has been edited by mike j (edited 02-24-2000).]

  4. #4
    Senior Member Regular Contributor nickels's Avatar
    Join Date
    Feb 2000
    Location
    Colorado
    Posts
    284

    Re: writing numbers on the screen

    Wait a minute. That line has to be:

    for(ptr = &buf[0]; *ptr; ptr++)

    (Test for null at end of string)

  5. #5
    Junior Member Newbie
    Join Date
    Feb 2000
    Location
    gainesville, fla, usa
    Posts
    17

    Re: writing numbers on the screen

    Thanks alot mikej and nickels.


    glguru

Similar Threads

  1. numbers to screen
    By phil67rpg in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 03-19-2006, 11:54 PM
  2. Writing to the screen
    By doofus in forum OpenGL: General
    Replies: 2
    Last Post: 04-04-2004, 02:31 PM
  3. placing numbers either integer or float on screen
    By prashantgp in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 11-28-2002, 04:56 AM
  4. writing directly to the screen.
    By Super13 in forum OpenGL: macOS
    Replies: 0
    Last Post: 02-25-2002, 12:41 AM
  5. writing to buffer WITHOUT writing to screen
    By mrshirts in forum OpenGL: Advanced Coding
    Replies: 4
    Last Post: 10-01-2000, 02:08 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