• GLUT Tutorials 14:笔画字体


    博客转自:http://www.lighthouse3d.com/tutorials/glut-tutorial/stroke-fonts/

    笔画是一种利用直线绘制的字体,对比位图字体,笔画字体更像3维物体。例如字体可以旋转、缩放和平移。这个小节内,我们将呈现GLUT 将笔画字体显示在屏幕上的函数。基本上只需要一个函数 glutStrokeCharacter。

    void glutStrokeCharacter(void *font, int character)
    
    Parameters:
    
    font – the name of the font to use (see bellow for a list of what’s available
    character – what to render, a letter, symbol, number, etc…

    The font options available are:

    • GLUT_STROKE_ROMAN
    • GLUT_STROKE_MONO_ROMAN (fixed width font: 104.76 units wide).

    The following line of text exemplifies a call to the glutStrokeCharacter function to output a single character at the current local coordinates:

    glutStrokeCharacter(GLUT_STROKE_ROMAN,'3');

    As opposed to bitmap fonts, the render location for stroke fonts is specified in the same way as for any graphical primitive, i.e. using translations, rotations and scales.The following function renders a string starting at the specified position in local world coordinates:

    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();
    }

    Note: GLUT uses lines to draw stroke fonts, therefore we can specify the width of the line with the function glLineWidth. This function takes a float specifying the width as the only parameter.

    As for bitmap fonts, GLUT provides a function that returns the width of a character. The function is glutStrokeWidth and the syntax is as follows:

    int glutStrokeWidth(void *font, int character);
    
    Parameters:
    
    font – one of the pre defined fonts in GLUT, see above.
    character – the character which we want to know the width

    显示效果如下

  • 相关阅读:
    Windows XP SP1 Privilege Escalation
    A way escape rbash
    A trick in Exploit Dev
    wget.vbs & wget.ps1
    IDEA创建普通java和web项目教程
    初始Mybatis
    JAVA高级面试题
    JVM执行原理
    java-- 位运算
    JAVA---XML
  • 原文地址:https://www.cnblogs.com/flyinggod/p/12941702.html
Copyright © 2020-2023  润新知