使用WebGL在画布上呈现文本 [英] Render text on canvas using 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在画布上呈现文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!