使用WebGL在画布上呈现文本 [英] Render text on canvas using WebGL

查看:263
本文介绍了使用WebGL在画布上呈现文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用WebGL在画布上渲染一些文本,应该使用WebGL的哪个API?

I want to render some text on a canvas using WebGL, which API of WebGL should be used?

注意:text可以是纯文本或HTML CSS样式的片段

Note: "text" can be either plain text or HTML snippet with CSS style

推荐答案

我看过的任何类型的文本(如FPS计数器)一个HTML元素,包含他们想要的文本,并将其放置在画布上。这可能是一个很好的方法,大多数文本,你想要显示在一个画布(即:菜单)。

Most demos that I've seen that do text of any sort (like a FPS counter) simply create an HTML element with the text they want and position it over the canvas. This would probably be a good approach for most text that you would want to show "in" a canvas (ie: menus).

唯一的例外是,如果你想让文本成为3d场景的实际部分(比如,广告牌上的文字),在这种情况下,将与在标准OpenGL中呈现文本不同。您可以在这里找到一个非常好的示例: http://dmedia.dprogramming.com/? n = Tutorials.TextRendering1

The only exception would be if you want the text to be an actual part of the 3d scene (like, say, text on a billboard), in which case the methodologies wouldn't be any different than rendering text in standard OpenGL. You can find a very good robust example here: http://dmedia.dprogramming.com/?n=Tutorials.TextRendering1

还有有关此处的文本的WebGL教程

这篇关于使用WebGL在画布上呈现文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆