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();  
效果如下:

最後附上所需的文件(見附件!)。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章