PDA

View Full Version : glut font



Xrid3r
09-05-2010, 01:40 PM
Hi!
I got a problem with my font code in glut with codeblocks.

I got this anoying warning that says "warning: deprecated conversion from string constant to 'char*"

So here is the code :

void renderBitmapString(
float x,
float y,
void *font,
char *string) {
char *c;
glRasterPos2f(x, y);
for (c=string; *c != '\0'; c++) {
glutBitmapCharacter(font, *c);
}
}

And for the relevant information in the display function:

renderBitmapString(5,30,GLUT_BITMAP_TIMES_ROMAN_24 ,"3D hello");

Hope you guys can tell me what's wrong and how i get rid of the warning message..

Oh and I got from Lighthouse (http://www.lighthouse3d.com/opengl/glut/index.php?bmpfontortho) .

~Xrid3r.

marshats
09-05-2010, 03:24 PM
Two possible solutions:

1. add explicit cast


renderBitmapString(5,30,GLUT_BITMAP_TIMES_ROMAN_24 ,(char *)"3D hello");

or 2. redeclare function as


void renderBitmapString(
float x,
float y,
void *font,
const char *string)