Offscreen rendering

Sometimes, it is useful to render an OpenGL scene not to the screen but to some image that can be later processed externally or used as a texture in some other part of rendering. For that, the concept of Framebuffer Objects (FBO) was created. An FBO is a rendering surface that behaves like the regular device frame buffer, with the only exception that the resulting pixels do not land on the screen. An FBO target can be bound as a texture in an existing scene or dumped as an image to regular computer memory. In Qt, such an entity is represented by a QOpenGLFramebufferObject class.

Once you have a current OpenGL context, you can create an instance of QOpenGLFramebufferObject, using one of the available constructors. A mandatory ...

Get Game Programming using Qt 5 Beginner's Guide - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.