How exactly can I use glutBitmapString?
glColor4f(1.0, 1.0, 0.0, 1.0);
glRasterPos2i(200, 200);
glutBitmapString(GLUT_BITMAP_HELVETICA_18, "text");
VS08 shows: cannot convert argument 2 from "const char [5]" to "const unsigned char *"
But when I write this:
glColor4f(1.0, 1.0, 0.0, 1.0);
glRasterPos2i(200, 200);
glutBitmapString(GLUT_BITMAP_HELVETICA_18, (const unsigned char *)"text");
I can get through compilation but the program will automatically close.
How can I fix this problem?
BTW, why this function must use const unsigned char*, particularly unsigned?
Thanks in advance!
[EDIT]
here is the snippet of my display function:
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity(); glTranslatef(0.0, 0.0, zoom);
glRotatef(xrot, 1.0, 0.0, 0.0);
glRotatef(yrot, 0.0, 1.0, 0.0);
glBindTexture(GL_TEXTURE_2D, textureId[filter]);
glBegin(GL_QUADS);
glNormal3f(0.0, 0.0, 1.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(1.0, -1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, 1.0);
glNormal3f(0.0, 0.0, -1.0); glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, -1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, -1.0);
glNormal3f(-1.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(-1.0, -1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glNormal3f(1.0, 0.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(1.0, -1.0, 1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(1.0, -1.0, -1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0, 1.0, -1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(1.0, 1.0, 1.0);
glNormal3f(0.0, 1.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, 1.0, 1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(1.0, 1.0, 1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0, 1.0, -1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, 1.0, -1.0);
glNormal3f(0.0, -1.0, 0.0); glTexCoord2f(0.0, 0.0); glVertex3f(-1.0, -1.0, -1.0);
glTexCoord2f(1.0, 0.0); glVertex3f(1.0, -1.0, -1.0);
glTexCoord2f(1.0, 1.0); glVertex3f(1.0, -1.0, 1.0);
glTexCoord2f(0.0, 1.0); glVertex3f(-1.0, -1.0, 1.0);
glEnd();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor4f(1.0, 1.0, 0.0, 1.0);
glRasterPos2i(200, 200);
glutBitmapString(GLUT_BITMAP_HELVETICA_18, "text");
glFlush(); glutSwapBuffers();
}
[/EDIT]