[SOLVED] QImage and glTexImage2D()
-
wrote on 5 Jan 2014, 21:31 last edited by
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! -
wrote on 6 Jan 2014, 12:24 last edited by
Starting with Qt 5.2 you can use image.convertToFormat(QImage::Format_RGBA8888) instead.
-
wrote on 6 Jan 2014, 13:31 last edited by
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.
-
wrote on 11 Jan 2014, 11:28 last edited by
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/4