Search code examples
ctextglutfreeglut

Write a text using GLUT and C


I'm actually working on a game using GLUT and C and I would like to display the score on my window, I'm searching for something similar to printf so I can display my text "score" and it value that can change.

I've found a function name DrawBitmapText but whith that function I can only display text, I couldn't display a variable.

Thanks for your help.


Solution

  • sprintf() will create the text you want in a buffer:

    char buf[256];
    sprintf(buf, "Score: %d", score);
    DrawBitmapText(..., buf);