How to write text in an OpenGL ES game?

I want to have an instructions page in my OpenGL ES game. One approach is to combine 2d and 3d rendering and use eglSwapBuffers.

I read about this on this forum and it seems messy, so maybe it is better to write all the instructions on a texture, which I then put on a rectangle which is shown directly in front of the camera? This approach would avoid any mixed rendering.

If it is better to combine 2d and 3d rendering and use eglSwapBuffers, has anyone an example on how to implement this?

Mixed rendering is common in these kind of cases, often a UI/text might be rendered with some other API (e.g. openvg etc…), as scalar graphics and the API might be better suited for rendering a better looking UI. Then both UI and GL game elements are composited to get final displayed results . If you have a limited UI with a simple layout, then textures are good a option for display it. But keep in mind, you’ll either want to display a pre-render image which won’t change, or you can render to a texture with frame buffer objects for more flexibility.

I read about more about combining 2d and 3d rendering. It seems messy and I only want to have an instructions page, so maybe it is better to write all the instructions on a texture, which I then put on a rectangle which is shown directly in front of the camera? This approach would avoid any mixed rendering.

The instructions page won’t change, but I also need a “game over” page with the results. This image will change with the results, so then I could render to a texture with frame buffer objects like you suggested. Do you have any example on how to implement this?

Whenever performance is an issue you should avoid mixed rendering and render everything with OpenGL using predefined textures. When you need to render dynamic text, you should use a texture which contains every glyph you need and draw text as a list of triangles, with two textured triangles per character.

However, for static screens you could simply draw a full-screen textured quad, with the texture either created once (e.g. the instructions page) or created at runtime using a different drawing API, then grabbing the resulting pixels and passing them to GL through glTexImage2D. Or maybe you don’t need to use GL in those cases at all.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.