zoukankan      html  css  js  c++  java
  • OpenGL如何显示文本?

          不管是DirectX9还是GDI,处理文本都是很方便的,但是在OpenGL中,我似乎没找到很方便的处理方式,在网上搜了一下,结果如下: 
          在http://www.opengl.org/resources/features/fontsurvey/ 里说,处理OpenGL处理文本有三种方式,我试用了一种。
          这里要用到glut(把glut下载下来,把头文件glut.h放到...\PlatformSDK\Include\gl下,把两个lib放到...\PlatformSDK\Lib,把两个dll放到system32下)

    void* bitmap_fonts[7= {
          GLUT_BITMAP_9_BY_15,
          GLUT_BITMAP_8_BY_13,
          GLUT_BITMAP_TIMES_ROMAN_10,
          GLUT_BITMAP_TIMES_ROMAN_24,
          GLUT_BITMAP_HELVETICA_10,
          GLUT_BITMAP_HELVETICA_12,
          GLUT_BITMAP_HELVETICA_18     
       }
    ;
    print_bitmap_string(
    void* font,const char* s)
    {
       
    if (s && strlen(s)) {
          
    while (*s) {
             glutBitmapCharacter(font, 
    *s);
             s
    ++;
          }

       }

    }

    int CDGL::TextOut(int x,int y,const char* cstr,int color)
    {     
       
       glRasterPos2f(x, y);
              print_bitmap_string(
    bitmap_fonts[4], cstr);

              
    return 1;
    }

    我在我的Plot3D项目里试用,能够用,尽管还不是很方便。


  • 相关阅读:
    一意孤行
    叶子书签
    漫舞
    男朋友
    ubuntu自动关机命令,ubuntu 无法关机解决方法
    情人节
    生死由天
    春暖花开
    android开发学习中的问题:error: device not found解决办法
    暗恋
  • 原文地址:https://www.cnblogs.com/eyye/p/782632.html
Copyright © 2011-2022 走看看