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. How do I bind a texture in QtGui OpenGL

How do I bind a texture in QtGui OpenGL

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 2.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.
  • H Offline
    H Offline
    hatfarm
    wrote on last edited by
    #1

    Hello all,

    I posted this to the games area, but it's really more broad than that, so I'd ask this here. I’m newish to OpenGL, but not C++. I am wanting to learn more about OpenGL. I was able to follow along with the triangle example for QtGui’s OpenGL stuff (found at http://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html). However, I cannot figure out how to add a texture to OpenGL. I know how to do it via OpenGL in general and in Qt 4.8 you could use the bindTexture() function of a QGLWidget. However, since with Qt 5.0 they recommend you don’t use that for new programs, I’d like to avoid using it. My hope is to be able to do something like the qt cube example (available here: http://qt-project.org/doc/qt-4.8/opengl-cube.html) but with using the QOpenGL classes instead of QGL classes. Can anyone help me with the texture binding information so I can use that instead? Thanks ahead of time.

    1 Reply Last reply
    0
    • M Offline
      M Offline
      MiLk
      wrote on last edited by
      #2

      Hi,

      I'm trying to do the same thing (using textures with the triangle in OpenGLWindow).
      Do you have solve your problem ?

      Thanks.

      1 Reply Last reply
      0
      • H Offline
        H Offline
        hatfarm
        wrote on last edited by
        #3

        Well, no, I didn't solve my problem. I found this article and it has a method for doing it:

        http://www.kdab.com/opengl-in-qt-5-1-part-5/

        I just decided to use OpenGL outside of Qt since they broke it a bit for a while. I use GLEW with SFML if you're interested in what I did. Hope that article helps you, the texture code is in the zip file attached to the article.

        1 Reply Last reply
        0
        • M Offline
          M Offline
          MiLk
          wrote on last edited by
          #4

          Hi,

          Thanks for you fast answer.

          I just tried to use the Texture class found in zip, but I still have the same problem. I obtain a SIGSEV when I call the glDrawArrays function.

          I can't launch the terrain tesselation program, because it requires OpenGL 4.0 and I only have 3.0 on this computer (Intel HD with Ivy bridge).

          I look this link too: http://stackoverflow.com/questions/14915167/how-to-load-and-bind-a-texture-with-qts-opengl-classes
          And I have the same problem.

          I will do more investigation.

          1 Reply Last reply
          0
          • M Offline
            M Offline
            MiLk
            wrote on last edited by
            #5

            Hi,

            In fact, I should stop work on OpenGL the evening.
            I just forget to pass the texCoord parameter ...

            This code works: https://gist.github.com/MiLk/6374829

            It uses QGLContext::bindImage() with a QImage().

            Hope, it can help someone.

            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