View Full Version : glut font

09-05-2010, 12:40 PM
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) .


09-05-2010, 02: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)