Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. QOpenGLTexture and QOpenGLFrameBufferObject
Forum Update on Monday, May 27th 2025

QOpenGLTexture and QOpenGLFrameBufferObject

Scheduled Pinned Locked Moved Game Development
4 Posts 2 Posters 4.6k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    informer2000
    wrote on 31 Jul 2014, 10:08 last edited by
    #1

    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.

    Thanks in advance..

    1 Reply Last reply
    1
    • C Offline
      C Offline
      Cmdr
      wrote on 31 Jul 2014, 13:16 last edited by
      #2

      Regarding the second question: There is an overload of the bind() method in QOpenGLTexture that takes an argument for the desired texture unit:

      http://qt-project.org/doc/qt-5/qopengltexture.html#bind-2

      Don't know about the first question, sorry.

      1 Reply Last reply
      0
      • I Offline
        I Offline
        informer2000
        wrote on 1 Aug 2014, 00:18 last edited by
        #3

        Thanks Cmdr. That is helpful. The main problem I have now 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.

        1 Reply Last reply
        0
        • C Offline
          C Offline
          Cmdr
          wrote on 1 Aug 2014, 01:37 last edited by
          #4

          No, the QImage won't help here. I suggest you use vanilla OpenGL functions on the texture id returned by QOpenGLFramebufferObject::texture() and don't use QOpenGLTexture for this purpose at all. This shouldn't be too difficult: use glActiveTexture to set the texture unit you want to bind the texture to, and then glBindTexture to bind it. I don't know which parameters QOpenGLFrameBufferObject sets on the texture, so you might need to disable mip mapping with glTexParameteri.

          1 Reply Last reply
          0

          2/4

          31 Jul 2014, 13:16

          • Login

          • Login or register to search.
          2 out of 4
          • First post
            2/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved