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项目里试用,能够用,尽管还不是很方便。


  • 相关阅读:
    8 Range 对象
    7 Worksheet 对象
    6 Workbook 对象
    5 Application 对象
    Windows路径
    windows 下操作目录(使用DOS命令)
    Windows 批处理
    6 WPF控件
    Lexer and parser generators (ocamllex, ocamlyacc)
    4.9 Parser Generators
  • 原文地址:https://www.cnblogs.com/eyye/p/782632.html
Copyright © 2011-2022 走看看