I’m trying to port a previous project to the new Qt5 OpenGL classes. I want to render to a texture using an FBO. The previous code utilized multiple textures which I attaching to the FBO on-demand. So, I would attach a certain texture object, perform the rendering, attach another texture and perform a different operation and have the output rendered to the newly attached texture, and so on.

I was wondering how would I go about doing this using the Qt5 OpenGL classes. For example, I can’t figure out how to attach a certain `QOpenGLTexture` object to a `QOpenGLFrameBufferObject` so that I can render to it. I can see that there is a `texture()` method and a `takeTexture()` method. But they both just return the texture id. Also, how can I change the active texture unit? For example, I want to sample from two textures in my shader program. So, I need to bind two textures to different texture units.

To clarify, the main problem I'm having with the new API is that I don’t see any method in `QOpenGLFrameBufferObject` that would return a `QOpenGLTexture` object. There is only the `toImage()` method and the `texture()` and `takeTexture()` methods. I guess I could just construct a `QOpenGLTexture` using the `QImage` returned from `toImage()`. But I’m not sure if that would be efficient. 

As for `texture()` and `takeTexture()`, I don’t see how their return values can be used using the new classes.