错误:
test.cpp:24:22: error: stray ‘\342’ in program
glutCreateWindow(“OpenGL 3D View”);
#include <GL/glut.h>
void init(void)
{
glClearColor(0.0, 0.0, 0.0, 0.0);
glMatrixMode(GL_PROJECTION);
glOrtho(-5, 5, -5, 5, 5, 15);
glMatrixMode(GL_MODELVIEW);
gluLookAt(0, 0, 10, 0, 0, 0, 0, 1, 0);
}
void display(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 0, 0);
glutWireTeapot(3);
glFlush();
}
int main(int argc, char *argv[])
{
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_RGB | GLUT_SINGLE);
glutInitWindowPosition(0, 0);
glutInitWindowSize(300, 300);
// glutCreateWindow(“OpenGL 3D View”); //这一句使用了中文符号,修改成英文即可
glutCreateWindow("OpenGL 3D View");
init();
glutDisplayFunc(display);
glutMainLoop();
}
原因:
glutCreateWindow(“OpenGL 3D View”); //这一句使用了中文符号,修改成英文即可
重新编译
gcc -o test test.cpp -lGL -lGLU -lglut
运行
./test
结果

本文介绍了一个关于OpenGL程序中因使用中文符号导致编译错误的问题,并提供了详细的解决方案,包括正确的代码示例及编译指令。
5887

被折叠的 条评论
为什么被折叠?



