如何使用glutBitmapCharacter

时间:2016-03-31 09:18:53

标签: opengl bitmap glut

我正在尝试在SDL的窗口和glutBitmapCharacter上写字体。

但我很想编译它。

我的编译器错误信息是:

 undefine reference to « glutBitmap9By15 »
 undefine reference to « glutBitmapCharacter »

此代码:

    #include <SDL/SDL.h>
    #include <GL/gl.h>
    #include <GL/glu.h>
    #include <GL/glut.h>
    #include <cstdlib>
    #include <cmath>
    #include <string>
    #include <iostream>

int main()
{    
      SDL_Init(SDL_INIT_VIDEO);
      atexit(SDL_Quit);
      SDL_SetVideoMode(WIDTH, HEIGHT, 32, SDL_OPENGL);
      glMatrixMode(GL_PROJECTION);
      glLoadIdentity();
      gluOrtho2D(0,WIDTH,0,HEIGHT);
      SDL_EnableKeyRepeat(100,100);

      glMatrixMode(GL_PROJECTION);
      glPushMatrix();
      glLoadIdentity();
      gluOrtho2D(0.0, WIDTH, 0.0, HEIGHT);

      glMatrixMode(GL_MODELVIEW);
      glPushMatrix();
      glLoadIdentity();
      glColor3f(0.0, 1.0, 0.0); // Green                                                                                 

      glRasterPos2i(10, 10);

      std::string s = "Respect mah authoritah!";
      void * font = GLUT_BITMAP_9_BY_15;
      for (std::string::iterator i = s.begin(); i != s.end(); ++i)
        {
          char c = *i;
          glutBitmapCharacter(font, c);
        }

      glMatrixMode(GL_MODELVIEW);
      glPopMatrix();

      glMatrixMode(GL_PROJECTION);
      glPopMatrix();
}

有人知道我必须做些什么才能让它发挥作用吗?

谢谢

0 个答案:

没有答案