【问题标题】:C++ OpenGL / FreeType scrolling fontC++ OpenGL / FreeType 滚动字体
【发布时间】:2011-09-10 15:55:11
【问题描述】:

寻找关于滚动文本的最佳方式的意见,我在 Slackware 上使用带有 OpenGL/c++ 的 freetype 库。

我基本上将 nehe 示例用于 freetype 设置/打印方法。 http://nehe.gamedev.net/tutorial/freetype_fonts_in_opengl/24001/

比如说,我想让一些文本从下往上慢慢腐蚀,逐个像素,有什么想法吗?

虽然我还没有完全检查过他们的代码,但最好是更改 TexCoord/Vertex 数据吗?

glBegin(GL_QUADS);
glTexCoord2d(0,0); glVertex2f(0,bitmap.rows);
glTexCoord2d(0,y); glVertex2f(0,0);
glTexCoord2d(x,y); glVertex2f(bitmap.width,0);
glTexCoord2d(x,0); glVertex2f(bitmap.width,bitmap.rows);
glEnd();
glPopMatrix();
glTranslatef(face->glyph->advance.x >> 6 ,0,0);

任何建议都会有所帮助

【问题讨论】:

    标签: c++ opengl freetype


    【解决方案1】:

    您可以为此使用剪切平面。他们将确定将呈现文本的区域。您可以在每一帧移动剪切平面,以便剪切/可见区域发生变化,您的文本将 slowly erode from the bottom up, pixel by pixel

    此代码从左右剪切文本:

    procedure TRenderUI.SetupClipX(X1,X2:smallint);
    var cp:array[0..3]of real; //Function uses 8byte floats //ClipPlane X+Y+Z=-D
    begin
      glEnable(GL_CLIP_PLANE0);
      glEnable(GL_CLIP_PLANE1);
      FillChar(cp, SizeOf(cp), 0);
      cp[0] := 1; cp[3] := -X1; //Upper edge
      glClipPlane(GL_CLIP_PLANE0, @cp);
      cp[0] := -1; cp[3] := X2; //Lower edge
      glClipPlane(GL_CLIP_PLANE1, @cp);
    end;
    
    //Release all clipping planes
    procedure TRenderUI.ReleaseClip;
    begin
      glDisable(GL_CLIP_PLANE0);
      glDisable(GL_CLIP_PLANE1);
    end;
    

    您最多可以同时使用 4 个剪切平面。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-08-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-09-03
      • 1970-01-01
      相关资源
      最近更新 更多