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

本文介绍了如何在Windows Mobile平台上利用OpenGL ES进行字符串显示,涉及OpenGLFont和GlyphRun对象的使用,以及如何通过gl.Rotate和gl.Translate实现文字的旋转和缩放效果。文章附带相关文件供参考。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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

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

评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值