简体   繁体   English

iOS GLKit,在GLKView中绘制文本

[英]iOS GLKit, draw text in GLKView

I'm using GLKit to create a game on the iPhone. 我正在使用GLKit在iPhone上创建游戏。 setting up the GLKit context and drawing sprites on it isn't that hard but when I try to add text to it, it seems impossible to do. 设置GLKit上下文并在其上绘制精灵并不难,但是当我尝试向其添加文本时,似乎无法做到。 I have searched around for an answer but all the solutions I tried to find can't be mixed in GLKView. 我一直在寻找答案,但是我试图找到的所有解决方案都无法在GLKView中混合使用。

What is the best practice to render text in the GLKView? 在GLKView中呈现文本的最佳实践是什么?

从最简单的意义上说,“最佳”是制作一个UILabel,设置所需的所有文本和背景参数,然后从标签图层创建UIImage来创建或更新纹理。

The simplest answer is sometimes the best. 最简单的答案有时是最好的。 While the documentation has some words discouraging compositing between GLES and Quartz, it can work quite well to overlay a GLKView with a standard UIKit view, such as a UITextView. 尽管文档中有些词语不鼓励在GLES和Quartz之间进行合成,但将GLKView与标准UIKit视图(如UITextView)叠加在一起可以很好地工作。 You will, of course, want to confirm the performance impact on your least capable supported hardware / software configuration, but on a newer configuration, total rendering time remained below 1ms for an animating model while scrolling an overlaid UITextView with a clear background, set to be non-opaque. 当然,您将要确认性能对最不支持的硬件/软件配置的影响,但是在较新的配置上,动画模型的总渲染时间保持在1ms以下,同时滚动带有清晰背景的UITextView,设置为不透明。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM