zoukankan      html  css  js  c++  java
  • [译]GLUT教程

    Lighthouse3d.com >> GLUT Tutorial >> Fonts >> Stroke Fonts

    笔划字体是用线条生成的.跟位图字体相反,笔划字体看上去像三维对,例如,字体可以旋转,测量和转化.

    本节我们将会使用GLUT函数来生成一些笔划字体到屏幕.基础函数是glutStrokeCharacter.原型如下:

    void glutStrokeCharacter(void *font, int character)

    font - 用到的字体的名字

    character - 要渲染的字母,符号,数字等..

    字体的可选常量值有:

    GLUT_STROKE_ROMAN

    GLUT_STROKE_MONO_ROMAN (fixed width font: 104.76 units wide).

    下面文本演示了如何调用glutStrokeCharacter函数来输出单个字符到当前本地坐标:

    glutStrokeCharacter(GLUT_STROKE_ROMAN,'3');

    跟位图字体相反,笔划字体的渲染定位的声明方式跟原始图片一样,例如用转化,旋转和测量.

    下面函数在本地世界坐标中从指定位置开始渲染一串字符串:

    void renderStrokeFontString(
            float x,
            float y,
            float z,
            void *font,
            char *string) {
    
        char *c;
        glPushMatrix();
        glTranslatef(x, y,z);
    
        for (c=string; *c != ''; c++) {
            glutStrokeCharacter(font, *c);
        }
    
        glPopMatrix();
    }

    注意: GLUT是用线条来绘制笔划字体的,因此我们要用glLineWidth函数来指定线条的宽度.该函数用了浮点型来指定宽度.

    和位图字体一样,GLUT提供一个函数来返回字宽.glutStrokeWidth函数的原型如下:

    int glutStrokeWidth(void *font, int character);

    font -  GLUT中预定义的字体之一

    character - 我们想要知道字宽的字符

  • 相关阅读:
    导入导出模块
    jQuery复习
    vue记录
    angular 初探之父子组件之间传递数据
    webpack
    go语言语法记录
    dom元素的滚动(如何实现点击展开更多功能)
    正则回忆录
    Attributes 和 properties区别和联系?
    显示 隐藏DIV的技巧
  • 原文地址:https://www.cnblogs.com/live41/p/3393752.html
Copyright © 2011-2022 走看看