Converting an int to const GLvoid

I’m trying to take an integer I use for the score in a game I’m working on, and it draw it onto the screen, so I use this code:

wglUseFontBitmaps(hdc, 0, 256, 1000);
        glRasterPos3f(30.0f, 300.0f,0.0f);
        glCallLists(12, GL_INT, score);
    glDeleteLists(1000, 256);

It worked when I used “GL_BYTE” and used “I like pie” instead of score, but now it isn’t compiling, it gives me the error:

364 main.cpp invalid conversion from `int' to `const GLvoid*'

How can I fix this?

Apparently score is an int while it should be a pointer.
Where do you assign score?

e.g. “I like pie” returns a pointer to the first character.

Umm, it’s a global.

You’re not trying to print out an int value (score) using

glCallLists(12, GL_INT, score);

are you?

The lists contain characters (a,b,c,d,e,f,…) so if you do

glCallLists(4, GL_BYTE, “test”);

it will scan the char-array “test”
So first it calls the list corresponding to ‘t’
then the one for e
then the one for s
then the one for t

If you want to print out score you first have to convert your int to a char-array using itoa or sprintf and then print out the char array just like you did the others.

int score = 512;
char score_chars[100];
glCallLists(strlen(score_chars), GL_BYTE, &score_chars[0]);


That worked perfectly, thanks. :]

Sorry, there are two other things I am wondering, is it possible to increase the text size? and if so, is it also possible to center it?

You can’t scale using bitmaps from wglUseFontBitmaps. You can change the position of the text by altering the glRasterPos parameters but you’ll have to calculate the offsets for centering yourself.

If you’re looking for a font renderer where all of the transformation matrices apply (scale,translate,rotate,…), I recommend quesoglc.


Ok, thanks :]