Results 1 to 4 of 4

Thread: rendering contents of a variable in the screen

  1. #1
    Senior Member Regular Contributor
    Join Date
    Oct 2002
    Posts
    201

    rendering contents of a variable in the screen

    Ok I know how to draw text in open gl to the screen, but i have a variable that needs to have its contents printed to the screen. Can anyone tell me how this is done. thanks

  2. #2
    Senior Member Regular Contributor
    Join Date
    Mar 2001
    Posts
    184

    Re: rendering contents of a variable in the screen

    do you mean formatted text? you have some ints or floats and you want to see what numbers they represent? sprintf

    b

  3. #3
    Member Contributor
    Join Date
    Jul 2001
    Location
    Sherbrooke
    Posts
    95

    Re: rendering contents of a variable in the screen

    if you know how to draw text on the screen
    than You want to know how to convert numbers in text right
    you can convert an int with the _itoa function
    char buffer[10]; // 10 is the maximum number of digits your number can have
    _itoa(yourIntVariable, buffer, 10); // 10 means it's in decimal base...not binary nor octal
    then use buffer to draw text

    of as coredump said, you can use sprintf like this
    char buffer[numberOfDigitsWanted];
    sprintf(buffer, "%i", yourIntVariable);
    sprintf(buffer, "%f", yourFloatVariable);
    then use buffer to draw text...
    I'm not sure though if numberOfDigitsWanted have to fit the exact length of your number...maybe theere will be a lot of blank of garbage in the buffer variable...
    anyway good luck !

    --------------------------------
    Evil-Dog
    *Let's have a funny day*
    Let's have a funny day

  4. #4
    Member Contributor
    Join Date
    Jul 2001
    Location
    Sherbrooke
    Posts
    95

    Re: rendering contents of a variable in the screen

    And when I say "10 is the maximum number of digits your number can have"
    I mean that 10 is the length of the string you will put your number into. So if your number could be like 4500 then use 4...but if it can reach 15 digits use 15...
    anyway...

    --------------------------------
    Evil-Dog
    *Let's have a funny day*
    Let's have a funny day

Similar Threads

  1. Replies: 0
    Last Post: 09-11-2012, 02:48 PM
  2. output a variable to screen???
    By chuck norrrissss in forum OpenGL: Basic Coding
    Replies: 9
    Last Post: 05-11-2011, 04:47 PM
  3. Off-screen/screen rendering on different threads
    By martinakos in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 10-22-2010, 12:57 PM
  4. Off-screen and On-Screen frame buf rendering
    By awhig in forum OpenGL: Windows
    Replies: 11
    Last Post: 07-10-2009, 08:10 PM
  5. Replies: 5
    Last Post: 06-17-2004, 11:51 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