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. [SOLVED] QImage and glTexImage2D()
QtWS25 Last Chance

[SOLVED] QImage and glTexImage2D()

Scheduled Pinned Locked Moved Game Development
4 Posts 3 Posters 8.5k 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.
  • S Offline
    S Offline
    Seraph
    wrote on 5 Jan 2014, 21:31 last edited by
    #1

    Hi there,

    I am using Qt 5 and want to know what the current approach to use glTexImage2D() with QImage or QPixmap is. I used to do it like this:

    @QImage tmpImage("someTex.jpg");
    QImage image = QGLWidget::convertToGLFormat(tmpImage);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.bits());@

    Since QGLWidget is or will be deprecated (i at least do believe so), i want to get rid of this approach.
    I also do not want to use QOpenGLTexture because the software i am writing is for learning OpenGL.

    Thanks in advance.
    Happy new year!

    1 Reply Last reply
    0
    • A Offline
      A Offline
      agocs
      wrote on 6 Jan 2014, 12:24 last edited by
      #2

      Starting with Qt 5.2 you can use image.convertToFormat(QImage::Format_RGBA8888) instead.

      1 Reply Last reply
      0
      • Z Offline
        Z Offline
        ZapB
        wrote on 6 Jan 2014, 13:31 last edited by
        #3

        Also, deprecated does not mean that QGLWidget will go away. Also look at the implementation of QOpenGLTexture and it's helpers to see what it does.

        Nokia Certified Qt Specialist
        Interested in hearing about Qt related work

        1 Reply Last reply
        0
        • S Offline
          S Offline
          Seraph
          wrote on 11 Jan 2014, 11:28 last edited by
          #4

          OK thanks,

          It can also be done like this:
          @
          QImage tmpImage("someTex.jpg");
          QImage image = tmpImage.mirrored();

          glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, image.width(), image.height(), 0, GL_BGRA, GL_UNSIGNED_BYTE, image.bits());
          @

          1 Reply Last reply
          0

          1/4

          5 Jan 2014, 21:31

          • Login

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