`
yarin
  • 浏览: 171996 次
  • 性别: Icon_minigender_1
  • 来自: 成都
社区版块
存档分类
最新评论

OpenGL ES显示字符串2(Windows Mobile)

阅读更多

发现了OpenGLFont,所以这里备份一下。

 

例子:使用OpenGL ES画“Hello World!”

1:首先声明OpenGLFont font和GlyphRun title,然后在SetupScene使用

OpenGLFont font; 
GlyphRun title; 
protected override void SetupScene() 
{ 
    base.SetupScene(); 

    font = new OpenGLFont(new Font(FontFamily.GenericSerif, 12, FontStyle.Regular)); 
    title = new GlyphRun(font, "Hello World!", new Size(int.MaxValue, int.MaxValue), OpenGLTextAlignment.Left, true); 
}

2:最后在DrawScene函数中调用

protected override void DrawScene() 
{ 
            base.DrawScene(); 

            title.Draw(); 
}

效果如下:



 3:如果要对文字进行旋转和尺度变化,我们需要使用gl.Rotate和gl.Translate方法

  

gl.Translatef(50.0f,50.0f,0); 
gl.Rotatef(40.0f,0,0,1.0f); 
title.Draw(); 

效果如下:



  

 

 最后附上所需的文件(见附件!)。

 

  • 大小: 1.8 KB
  • 大小: 2.5 KB
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics