Question

I'm using GLKit to create a game on the 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. I have searched around for an answer but all the solutions I tried to find can't be mixed in GLKView.

What is the best practice to render text in the GLKView?

Était-ce utile?

La solution

"the best" in a sense of easiest would be to make an UILabel, set all the text and background parameters you want and then create UIImage from label's layer to create or update the texture.

Autres conseils

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. 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.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top