QT5 OpenGL include[SOLVED]
-
Hi folks,
i have a problem. I'm currently developing a project in qt 4.8.4 under windows (mingw).
I include the following files to use OpenGL:@
#include <QtOpenGL>
#include <GL/glext.h>
#include <GL/glu.h>
@That works perfect.
Now i want to use Qt5 (msvc2010). First of all there is no <GL/glext.h> header file. I've read about a #define which would manage to include the glext functions: #define GL_GLEXT_PROTOTYPES
If I do it that way I'll get the some "already defined" errors like: "glDouble already defined".
It seems that the define QT_OPENGL_ES_2 is always set, even if I undef it. Is there any reason for that? But I want to use OpenGL4.2.So that's what I tried in Qt5:
@
#define GL_GLEXT_PROTOTYPES
#include <QtOpenGL>
#include <GL/glu.h>
@Is there any preferred way to include OpenGL?
thanks in advance!
obab
-
Hi !
I think You can find what You want at ..
http://qt-project.org/doc/qt-5.0/qtopengl/qglformat.html
Regards
Fredrik -
Hello Obab,
It seems that in Qt 5 are still the old QGLXXX classes and new ones with the prefix QOpenGLXXX.
I had a look in the QGLXXX header files which include GL_ES_2 stuff and the QOpenGLXXX classes include the normal open gl stuff.Maybe you should just replace your QGLXXX classes with the new QOpenGLXXX classes. Give it a try.
I hope this will help you.
-
-
[quote author="obab30" date="1356019442"]Hey ZapB,
i just used the pre-build msvc2010 package!
[/quote]
OK that is the source of your issues then. The pre-compiled Windows desktop version of Qt5 is built against ANGLE which only provides OpenGL ES 2 support by implementing it on top of DirectX 9.
This was done to ensure that QtQuick2 works on all windows systems, including those with crappy Intel OpenGL drivers ;)
OpenGL ES 2 does not support the legacy fixed function pipeline, only a shader-based one.
There is a bug open to provide a build of Qt 5 using the native desktop OpenGL implementation for Qt 5.0.1. Please go vote for https://bugreports.qt-project.org/browse/QTBUG-28715 to see this happen.
For now, you have two choices:
- Live with OpenGL ES 2 support and don't use legacy OpenGL
- Build your own copy of Qt 5 to use the native OpenGL drivers by passing in
@
-opengl desktop
@to configure.
With the 2nd option you should have access to OpenGL from 1.0 up to 4.3 (if your card/driver support it).
-
OK that should solve my "thread":http://qt-project.org/forums/viewthread/22915/, too! Thanks ZapB!
I'll give it a try. Obab would you please respond here again if it worked?Thanks and merry x mas to everyone
-
I do as ZapB told but meet some problems when configure -opengl desktop.
My Qt version is 5.0.2.
I run the cmd.exe in windows and in the directory of D:\Qt\Qt5.0.2\5.0.2\Src\qtbase.
In order to compile Qt,
I input the commend "configure -opengl desktop". But it didn't work and no makefiles was got.
Could you tell me why? Dear ZapB? -
Which compiler are you trying to build with? If it's MSVC then you need to make sure that the environment is setup correctly by executing the MSVC Command Prompt rather than cmd.exe directly. This executes a batch script that correctly sets up the path to your compiler etc.
Can you paste the exact configure line and output that you get please?