How do I bind a texture in QtGui OpenGL
-
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.
-
Hi,
I'm trying to do the same thing (using textures with the triangle in OpenGLWindow).
Do you have solve your problem ?Thanks.
-
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.
-
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.
-
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.