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. HowTo: OpenGL Texture Buffers with Qt?
Forum Updated to NodeBB v4.3 + New Features

HowTo: OpenGL Texture Buffers with Qt?

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 3.2k 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.
  • S Offline
    S Offline
    StridaHD
    wrote on 7 Jun 2014, 22:00 last edited by
    #1

    I'd like to make use of OpenGL's Texture Buffers with Qt, as it is shown in this non-Qt example:

    https://gist.github.com/roxlu/5090067

    Following this command
    @glBufferData(GL_TEXTURE_BUFFER, sizeof(tbo_data), tbo_data, GL_STATIC_DRAW);@
    it looks like I have to use the QOpenGLBuffer class, but only the QOpenGLTexture has a target for it.
    So i tried to create the latter resulting in two errors:
    @Buffer textures do not allocate storage
    QOpenGLTexture::setData(): Texture target does not support pixel data upload@

    So my questions are:
    Can you point me in the right direction?
    Do I have to use QOpenGLBuffer and/or QOpenGLTexture?
    If I have to use QOpenGLTexture, how can I "setData" i.e. transfer the data to the texture buffer?

    1 Reply Last reply
    0
    • B Offline
      B Offline
      BlastDV
      wrote on 10 Jun 2014, 21:38 last edited by
      #2

      Hi StridaHD, I think it depends on what you want to do.

      If you want to give your texture to the graphics card, you cand do it like this:
      @
      GLuint texture;

      texture= bindTexture(QPixmap(QString("URL of your texture")), GL_TEXTURE_2D);
      @

      And that's all... Save that GLuint to refer to your texture whenever you want to draw it.

      Now, I said "it depends" because it actually does on the way you want OpenGL to render the frame.

      What are you using? VBOs?

      (8) Just live your life blind like me (8)

      1 Reply Last reply
      0
      • S Offline
        S Offline
        StridaHD
        wrote on 11 Jun 2014, 11:27 last edited by
        #3

        Hi BlastDV,

        I try to use as much OpenGL as provided with Qt. So QOpenGLTexture( QImage( ... ) ) works fine for adding 2D Textures.
        I use the textures together with VBOs and Shaders (OpenGL 3.2 CoreProfile). So far I could realize everything with QOpenGLBuffer and QOpenGLShader.

        I'd like to use texture buffers to pass non-Image data (arbitrary floats) to the shaders and access it e.g. by @myTextureBufferFunctionValue[gl_PrimitiveID]@ (assuming a 1D texture buffer).

        If possible I would like to do the same to e.g. pass bitarrays as unsigend integers to the shaders, which I can't do with Qt because of the rescaling issue with strided data: https://qt-project.org/forums/viewthread/38929/

        1 Reply Last reply
        0

        1/3

        7 Jun 2014, 22:00

        • Login

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