本文介绍了glutBitmapString有什么问题?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我究竟该如何使用glutBitmapString?
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显示:无法将参数2从"const char [5]"转换为"const unsigned char *"
但是当我这样写的时候:
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");
我可以编译,但程序会自动关闭.
我该如何解决这个问题?
顺便说一句,为什么这个函数必须使用const unsigned char *,特别是unsigned?
提前谢谢!
这是我的显示功能的代码段:
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!
here is the snippet of my display function:
void display()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();//the display would be strange if this routine does not be called! reason is that the glTranslatef will be continuously accumulated!!!!!!!!!
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);//front face
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);//back face
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);//left face
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);//right face
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);//up face
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);//bottom face
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();//must be added in the end of display function
glutSwapBuffers();
}
[/EDIT]
[/EDIT]
推荐答案
这篇关于glutBitmapString有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!