在这个范围内没有声明glutBitmapString()

glutBitmapString() was not declared in this scope

本文关键字:声明 glutBitmapString 范围内      更新时间:2023-10-16

当我尝试用以下代码绘制一些字符串时:

    // label min and max for current vector
    glRasterPos2f(nx+1,y1);
    glutBitmapString(GLUT_BITMAP_8_BY_13,"min");
    glRasterPos2f(nx+1,y2);
    glutBitmapString(GLUT_BITMAP_8_BY_13,"max");

我得到错误

error: ‘glutBitmapString’ was not declared in this scope

在编译。疯狂的是

    // label min and max for current vector
    glRasterPos2f(nx+1,y1);
    glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'1');
    glRasterPos2f(nx+1,y2);
    glutBitmapCharacter(GLUT_BITMAP_8_BY_13,'2');

编译得很好,所以它不像我没有包括过剩库或任何东西(我有glutSwapBuffers()和其他大量的过剩调用!)

为什么glutBitmapString()不会编译?我已经检查了拼写和所有的东西,它就是无法编译!

加一行:

#include < GL/freeglut.h>

该函数是由freeglut添加的新函数,在glut

中没有退出。

您使用的是哪种Glut实现?根据FreeGlut文档,原始的Glut不包括glutBitmapString

http://freeglut.sourceforge.net/docs/api.php FontRendering

确实,在Glut文档中没有提到glutBitmapStringhttp://www.opengl.org/resources/libraries/glut/spec3/node75.html SECTION000110000000000000000

如果你真的需要使用这个函数,看起来你需要使用FreeGlut