OpenGL program does not compile with QT 5.0 - qt

I followed this turial to create a very simple openGL program with QT.
I have QT 5.0. I created a new empty QT project, created all files as in the tutorial but the compilation failed. The cause is that certain methods like glShadeModel() are not recognized.
I tried include GL/glu.h (which include glShadeModel for instance) but this time there is a conflict with several openGL types. But according to the tutorial all opengl methods should be included in QtOpenGL. Maybe I have a too much recent version of QT. I'm lost.
Does anyone can help me ?

Qt5 is based on OpenGL ES 2.0, and this is a subset of desktop OpenGL, even some Qt tutorials are not adapted to this change yet. You will have to build Qt 5.0 with normal OpenGL if you wish to compile those tutorials.

i may only give you some points to check.
in .pro
*QT += opengl
*check your GPU for supporting the opengl version you are using, for example my laptop is only compatible with 2.1 opengl.
also please use "Qt" instead "QT", QT stands for quicktime by Apple.

Related

How to use OpenCL 2.0 kernel language in Qt Creator?

Several days ago, when I started to learn OpenCL, I needed a good IDE to write OpenCL C kernel language, which provides some basic functions like syntax highlighting and static analysis. I was surprised to find out that Qt Creator is able to do the job.
Everything was fine until today I started to use some feature in OpenCL 2.0:
It looks like Qt Creator use libclang to do the parsing and libclang treats my source files as OpenCL 1.0. But My machine supports OpenCL 3.0 and the code was ok to compile and run. So I doubt it only supports OpenCL 1.0.
My questions are:
How to make Qt Creator (or the libclang plugin in it) support OpenCL 2.0?
How do you guys write OpenCL 2.0? Is there any better IDEs or editors?
Thank you guys, I am really a newbie here.
I tried to rename the file's postfix to ".cl2", but it doesn't work.
I read the OpenCL support documentation of LLVM, but failed to find out the solution.
QtCreator uses KDE syntax highlighting engine. The definitions are simple XML files. You can find them here, but opencl.xml doesn't look updated for 2.0/3.0 language. You can try to change it, and then put it into $HOME/.config/QtProject/qtcreator/generic-highlighter/syntax and it should pick it up.
In QtCreator, you can download newer definitions by going to Tools -> Options, select "Text editor" in left, then "Generic highlighter" tab. This will put the updated files in $HOME.local/share/org.kde.syntax-highlighting/

QT5.0.2 project needs more DLLs than QT4.8

Recently we moved to QT 5.0.2 from QT4.8. Our project now needs more DLL files than the earlier. It requires qml, opengl, printer modules. However we did not use any of these modules in our application. The size of exe file increased due to additional DLLs.
QT-= qml opengl -> did not exclude this module from our application.
Are these additional DLLs are compulsory for Qt 5.0.2 ? Is there any way to come out from this? We need to exclude these dlls to reduce exe size.
Some of the modules you use may be dependent on those you don't, which means your project depends on them indirectly. For example, by default, some modules (QtWebKit, QtMultimedia) utilize ANGLE which uses OpenGL. You can try to trace those dependencies by using a program named Dependency Walker (available here). The Qt GUI has changed a lot since 4.8, and there are now separate modules for printing and other functions (see here).
Sources:
Qt 5 on Windows ANGLE and OpenGL
Qt 5 Deployment on Windows
By the way, someone has (had) a similar problem: http://www.qtcentre.org/archive/index.php/t-52102.html. (Unfortunately, there is no solution in that link.)
It turned out that this is actually a bug in Qt.

Re-built Qt5.0.2 with OpenGL, how to use with Qt Creator

I need to move my code from a C++/OpenGL and Config.txt situation to a UI friendly space. I was told here to try Qt and installed it in Windows.
The issue I ran into is that it did not support the OpenGL version I needed out of the box and I had to rebuild with the -opengl desktop parameter.
First time doing this, but was able to follow the instructions (and a ton of Google) and it "succesfully" was built. My issue now is I am unsure how to make the files I have work with Qt Creator.
I copied over all the folders from the qt5 folder created by git over to the Src folder in Qt5.0.1/5.0.1/Src but the hellogl example still wouldn't build.
I checked the options and it was pointing to a qmake in Qt5.0.1/5.0.1/msvc2010/bin so I copied over the qmake.exe from qtbase/qmake over to this folder (renaming the old one) and now Qt Creator builds the hellogl example on my Windows system.
My worry is, did I do this the right way? I fumbled around and got something, but is this the way I should have proceeded after I built the qt5 from git? If not what was the way I should have gone about making it all work with the Qt Creator?
The typical way to utilize the modern OpenGL the feature set (post fixed-function pipeline) in Qt is by utilizing a extension wrangler (GLEW) that finds all the OpenGL functions your graphics drivers support BEFORE Qt includes any OpenGL headers.
To accomplish this simply do the following:
If you already haven't, download GLEW (or another extension wrangler if you wish) and install it in your system path. I would recommend the 32 bit package as it will be easier to work with.
#include glew.h in your source code before any other Qt header includes that may use OpenGL headers. Just to be safe, make glew.h the first header included in your source code.
In your Qt project's .pro file add the line LIBS += -lGLEW (mac/linux) or LIBS += -lglew32 (windows).
Note: Beware of using Qt OpenGL wrappers when implementing an application that uses post fixed-function pipeline facilities. Qt 5's OpenGL wrappers all operate using the OpenGL ES 2.0 specification which may cause problems when interleaved with your OpenGL 3/4 code. Even QPainter can become troublesome when performing overpainting on a QGLWidget due to it's heavy use of the fixed-function transformation stack. I am currently developing a library called QGLX that provides alternative Qt wrappers designed for complying to the modern desktop OpenGL specification. The beta will hopefully be released by the end of this year for Qt 4 & Qt 5.

Appearance difference between Qt4 and Qt5

I use Ubuntu 12.10 64 bit. I installed Qt4 from Ubuntu repo.
Version is Qt 4.8.3 and Qt Creator 2.5.2
I also downloaded Qt5 from qt-project.org and its version number is
Qt 5.0.1 and Qt Creator 2.6.2
When I compiled and run same project, their appearance slightly different.
What is the reason for that? Is it because of Ubuntu or Qt5?
Qt5 brought in some major changes of the GUI code, if you spot differences it's likely to be down to that rather than anything else.
New graphics architecture. Qt 5 introduces a new graphics architecture for Qt Quick using Scenegraph on top of OpenGL. OpenGL (ES) 2.0 is mandated for this to work. The new architecture makes it easier to integrate OpenGL-based content, such as shader effects, with Qt Quick-based applications. The QWidget-based stack continues to work as in Qt 4.x (based on QPainter), but supported back-ends have been limited to SW rasterization, pixmaps, and images, an OpenGL backend for GL surface,s and a backend for PDF generation and printing. X11 and CoreGraphics are no longer supported.
From Dr Dobbs Qt5 beta tour.

Qt with OpenGL extensions and OpenCL

Use Qt as my GUI library.
Now I need to use OpenGL with extensions and maybe with OpenCL.
First of all I need to load OpenGL extensions.
In glextensions.cpp/glextensions.h (c:\QtSDK\Demos\4.7\boxes) it's done in such way:
#define RESOLVE_GL_FUNC(f) ok &= bool((f = (_gl##f) context->getProcAddress(QLatin1String("gl" #f))));
RESOLVE_GL_FUNC(GenFramebuffersEXT);
Can you explain how it works?
Also I need to create special type of context to use OpenGL in conjuction with OpenCL.
Can I do it with QGLContext?
The QGLWidget class in Qt wraps all of the OpenGL extensions you are ever likely to need. Check these classes which wrap the relevant extensions:
Frame buffers: QGLFramebufferObject
Pixel buffers: QGLPixelBuffer
GLSL shaders: QGLShaderProgram
Start with Qt's OpenGL examples here.
To use OpenCL in this context check the Qt teams blog post and follow these installation instructions here. Works perfectly with Qt 4.8 on Ubuntu 12.04 (64-bit).

Resources