Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. OpenGL array textures in Qt
Forum Updated to NodeBB v4.3 + New Features

OpenGL array textures in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
12 Posts 2 Posters 4.7k Views 1 Watching
  • 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.
  • Chris KawaC Offline
    Chris KawaC Offline
    Chris Kawa
    Lifetime Qt Champion
    wrote on last edited by
    #2

    For new code you should definitely switch from QGL* to QOpenGL* classes.
    As part of them there's QOpenGLTexture that has support for texture arrays.

    Btw. Why 5.2.1? There's 5.5.1 already and 5.6. on its way.

    1 Reply Last reply
    0
    • D Offline
      D Offline
      delt
      wrote on last edited by
      #3

      Thanks for the info.

      ...yeah, the problem is that most linux distributions aren't shipping versions 5.5 yet. Ubuntu and derivatives are still on 5.2.1 for their LTS version which currently is 14.04.

      So, it looks like i'll have to write my own functions to do some pixel managing...?

      1 Reply Last reply
      0
      • Chris KawaC Offline
        Chris KawaC Offline
        Chris Kawa
        Lifetime Qt Champion
        wrote on last edited by
        #4

        Not at all. According to the docs I linked QOpenGLTexture is supported starting with Qt5.2, so you should be good to go.

        1 Reply Last reply
        0
        • D Offline
          D Offline
          delt
          wrote on last edited by
          #5

          Oh, right. Thanks again!

          1 Reply Last reply
          0
          • D Offline
            D Offline
            delt
            wrote on last edited by
            #6

            ...however, there seems to be a typo or some kind of mismatch in the QOpenGLTexture docs.

            From https://www.opengl.org/wiki/Array_Texture --

            "2D array textures are created similarly; bind a newly-created texture object to GL_TEXTURE_2D_ARRAY, then use the "3D" image functions to allocate storage. The depth​ parameter sets the number of layers in the array.

            Each 2D row/column sequence of pixel data in the "3D" array of pixels is considered a separate 2D layer. "

            From http://doc.qt.io/qt-5/qopengltexture.html --

            "QOpenGLTexture::Target2DArray 0x8C1A An array of 1-dimensional textures. Equivalent to GL_TEXTURE_2D_ARRAY"

            1 Reply Last reply
            0
            • Chris KawaC Offline
              Chris KawaC Offline
              Chris Kawa
              Lifetime Qt Champion
              wrote on last edited by
              #7

              Yeah, looks like a copy/paste error in the description. The value seems to be correct though, so the functionality should work fine.
              You can report a documentation defect on https://bugreports.qt.io.

              1 Reply Last reply
              0
              • D Offline
                D Offline
                delt
                wrote on last edited by
                #8

                You're right, a rough test with single textures seems to work perfectly, yay! :D

                ...Could you paste a quick example of how i would load an array texture of multiple texture layers into a QOpenGLTexture object? (just the Qt specific stuff) ...thanks!

                1 Reply Last reply
                0
                • Chris KawaC Offline
                  Chris KawaC Offline
                  Chris Kawa
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  Hm, it seems that all the setData() overloads usefull for 2D arrays have been introduced in Qt 5.3. The only one in 5.2 is the one taking QImage, but it can't produce a texture array.
                  Ok, then in 5.2 you can use QOpenGLTexture to create and manage the lifetime, binding etc, but you'll have to upload the data using vanilla OpenGL i.e. using glTexImage3D and glTexSubImage3D or, if you have EXT_direct_state_access glTextureImage3DEXT and glTextureSubImage3DEXT.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    delt
                    wrote on last edited by
                    #10

                    ...so, i could simply not use QOpenGLTexture and instead use OpenGL directly for 2d texture arrays, by writing simple function(s) that take pixel data from a QImage and arrange this data in a way that OpenGL functions can accept... sounds like a good approach?

                    1 Reply Last reply
                    0
                    • Chris KawaC Offline
                      Chris KawaC Offline
                      Chris Kawa
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      You could, but if you use Qt anyway it's convenient to use QOpenGLTexture, as it plays nice with other Qt OpenGL classes like shaders or FBOs. You could just make a function that uses vanilla GL to upload the data.
                      Your choice I guess.

                      1 Reply Last reply
                      0
                      • D Offline
                        D Offline
                        delt
                        wrote on last edited by
                        #12

                        Thanks again for your valuable help.

                        Can you post a quick example/pseudocode of how i'd create a QOpenGLTexture object and add an array texture to it?

                        1 Reply Last reply
                        0

                        • Login

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