[Interest] Problems with OpenGL in Windows and Qt5
Carlos
aarkham2k3 at yahoo.com
Fri Mar 21 14:13:39 CET 2014
Hello Till
Thanks for your answer. I did not define the OpenGL version nor the profile. I've trying to use OpenGL 4.4 with compatibility profile and it didn't make any difference: it works fine in Qt4 but is displaced in Qt5.
I only use Qt to interface with the system and I use the QGLWidget. As the game also worked in Meego and Symbian I didn't have a choice. Also as the Qt use is quite limited I really did not care.
I am completely lost and I have prepared a reduced project that I have attached to Sean answer.
Again, thanks for your help
Carlos
On Friday, March 21, 2014 10:13 AM, Till Oliver Knoll <till.oliver.knoll at gmail.com> wrote:
Am 20.03.2014 um 15:04 schrieb Carlos <aarkham2k3 at yahoo.com>:
...
>
>I've tried Qt 5.2 MSVC2010 32bit OpenGL and Qt 5.2 MinGW 32 bit and it fails in both. In Qt4 the OpenGL version is 4.3.0 and in Qt5 is 2.1.2,
Just to interrogate the Usual Suspects: you /are/ explicitly asking for an OpenGL 4.3 "CoreProfile" context, aren't you?
If not, it might be by pure chance what the underlying OpenGL driver is offering you.
Also, are you using the (not quite yet) deprecated "QGL" APIs (QGLWidget, QGLFormat,...), or the new "QOpenGL" APIs such as QSurfaceFormat, QOpenGLContext?
I remember there was an issue in some initial Qt 5 release which prevented to create an OpenGL 3.x context, because some deprecated GL function was still being used within Qt itself, causing the "context creation/testing" function to fail, and hence always the default 2.x GL context was returned.
But as I said, that was on a Mac and my memory is very sketchy (and now that I write these lines I think the problem was not creating a 3.2 context at that time, but rather executing a GLSL 1.50 shader with QGLShaderProgram, as its internal code was still trying to bind uniforms with a GLSL 1.20 syntax, or so I vaguely remember...).
Anyway, you might want to start over with a quick "Hello GL" application (and QOpenGLShaderProgram & Co. is now the way to rock these days!).
Sean's blog is probably a good point to start ;)
http://www.kdab.com/opengl-in-qt-5-1-part-1/
You will notice though that it uses QWindow instead of the good ol' QGLWidget, and that quite some "boilerplate code" is needed to get the convenient initializeGL/paintGL/resizeGL etc. methods back that were offered by QGLWidget. Let alone that QWindow represents a "top-level" window, which you still need to "wrap" into a QWidget hierarchy compatible widget (I think QWidget::createWindowContainer does that). For a full screen game QWindow however is probably all you need anyway.
Here is an example which uses a QWindow with an "OpenGL surface":
https://qt-project.org/doc/qt-5.0/qtgui/openglwindow.html
It's funny: this example code seems only to be available in the Qt 5.0 and 5.1 docs, but not in the current 5.2 docs. It is also not listed in the "official Qt examples" chapter. And note that the shader code uses the "OpenGL ES 2.0" (GLSL 1.20?) syntax and the example does not explicitly ask for an OpenGL context, because an OpenGL ES 2.0 compatible context is probably (supposedly?) what you get by default on most desktops anyway, if you don't ask for it explicitly.
So take this example with care, but it should demonstrate the effort required to get a "QGLWidget like experience".
My understanding is that the old QGLWidget /should/ still work, especially also with more recent GL context than "OpenGL ES 2.0" (because that is what Qt itself has to restrict itself internally!). That means you would still have to use the old QGLContext and QGLFormat classes as to create an OpenGL 3.x or 4.x context, but then you could (should) use the new "QOpenGL" API such as QOpenGLShaderProgram etc. (if you use them at all).
As I just realised myself the upcoming QOpenGLWidget itself is only scheduled for Qt 5.4 (QTBUG-36899), so that still leaves us in a somewhat weird situation when you want to write QWidget-based OpenGL applications: either you hack away with QWindow (and wrap it into a container), or you mix old "QGL" with new "QOpenGL" APIs (in the hope that the former still behave nice with recent OpenGL 4.x context).
I hope that gives you a few pointers to experiment with ;)
Cheers,
Oliver
_______________________________________________
Interest mailing list
Interest at qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20140321/f0fdf00f/attachment.html>
More information about the Interest
mailing list