Qt and OpenGL for game development - qt

I have a few questions about Qt.
I already know that Qt and OpenGL can be used together. At the
moment we are using GLUT at my university (for window and input
management). I saw that Qt is able to do the same thing. Are there
any disadvantages of using Qt instead of GLUT? (performance
wise)
I also know that Qt can be used to build a ingame GUI. I even saw
this 3d GUI example WolfenQt. So it is possible. But does it
make sense to use Qt for an ingame GUI if you care about
perfomance?

Qt, like any other tool can be misused. But just because you use Qt this does not mean, OpenGL performance will suffer. OpenGL doesn't care about what and how its context and the drawable it's bound to are created. The biggest impact Qt has is, how it manages and delivers events; the signal/slots mechanism.

Related

Differences in OpenGL on Qt 5.2 and on 5.10

I’m working now on some project built on Qt 5.2.1. The project makes some basic rendering (using QPixmap, GraphicsScene, etc). The goal is to switch this mechanism to OpenGL as quickly as possible. In addition we plan to move the whole project to Qt 5.10.
Is there some benefit first moving to Qt 5.10 and only then switch to OpenGL over first switching to OpenGL and afterwards move to Qt 5.10?
Is there possibility of some unexpected difficulties if we first switch to OpenGL (on Qt 5.2.1) and only then upgrading to Qt 5.10 (some features got deprecated or some new nice-to-use features appear)?
My experience with OpenGL on Qt is it being full of both old and new bugs, poor integration capabilities, poor platform support (Intel=NOPE) and no error handling of Qt-internals (e.g. context creation). At least of you use the built-in OpenGL-widgets.
That said there is much development going on right now of the Qt-OpenGL support, judging from which Qt-version certain OpenGL related features I have found in he manual. If you must use Qt-OpenGL, I would assume you get most features and few(er) bugs jumping onto latest and greatest.

What happens to blacklisted graphic cards in Qt 5.6 when running a QML app?

The upcoming Qt 5.6 introduces a blacklist to mark some graphic cards which are known to insufficiently support OpenGL or Angle.
Confirm e.g.
https://bugreports.qt.io/browse/QTBUG-47435
https://codereview.qt-project.org/#/c/140418/5//ALL
But what happens to QML apps on cards that have both disable_desktopgl and disable_angle set? Can those users not run QML apps at all?
They can't use OpenGL to accelerate Qt Quick, no. Which is a pretty severe drawback. Unfortunately the status of OpenGL on Windows is a nightmare. The "average" Windows computer will have an Intel-based GPU with ancient drivers, which are buggy enough to cause Qt not even try to use any 3D at all (OpenGL nor Direct3D). NVIDIA and AMD are usually better, as at least they tend to be more up-to-date.
Usually upgrading the Intel drivers solves most issues, but you are not always in the position of asking your users to upgrade their drivers (they might not even be able to do so, for instance lacking administrator privileges, and/or using laptops where the driver version has been pinned by the vendor).
Note that even other projects, such as Chromium or Firefox, have their own fine-grained driver bug blacklists (example).
In case your card is totally blacklisted you can:
use an OpenGL CPU implementation, such as Mesa. If you ship opengl32sw.dll with your application, it can be picked up by Qt. See the explaination here.
use the Qt Quick 2D renderer, which is a specialized CPU-based renderer for a subset of Qt Quick items. Compared to Mesa it's incredibly faster (because it doesn't need to go through the OpenGL pipeline in order to draw, say, a rectangle -- it can just draw the rectangle using a 2D rasterizer); on the other hand, certain things stop working, like shader effects. Currently it's available only under a commercial license, but in 5.8 it's going to be open source.
(Nitpick: QML is the language, Qt Quick is the framework/library to build UIs which you program using QML).

How GUI implemented from video card to Qt framework?

I've been curious about how GUIs are implemented for a long time. I know how to write Qt (or other) code, and I want to know:
How Qt calls Xlib (under Linux), and implements the Qt framework.
How Xlib calls linux system calls
How Linux controls the video card
Are there any good articles for introducing GUI implementations?
http://en.wikipedia.org/wiki/X_Window_System#Design

What's easier and cleaner? GTK or QT? [duplicate]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic for Stack Overflow as they tend to attract opinionated answers and spam. Instead, describe the problem and what has been done so far to solve it.
Closed 9 years ago.
Improve this question
Can someone suggest what's the best uses for those libraries today? Is it just GUI, or do they have database, XML, networking, threading, etc support too?
I was reading about them, and considered starting to learning/using one of them.
What is the most common one? What's the difference between them? Why would you choose one over the other?
As you seem to primarily target Linux, then the choice mostly depends on the programming language you want to use.
If you code in C, then obviously go for GTK+
If you code in C++, go for Qt, otherwise you will need Gtkmm (a C++ wrapper over GTK+)
If you code in Python, both GTK+ and Qt have bindings for the language: see PyGtk, PyQt and PySide (the one launched by Nokia themselves).
If you code in Java, Qt is no more a viable option imho as Nokia discontinued Qt Jambi (the Java bindings for Qt).
Also, Qt is more top-notch regarding its scenegraph QGraphicsScene API, its scripting engine built over Javascript Core (the engine powering WebKit), its state machine and animations framework, and the declarative UI.
GTK+ doesn't offer that much although you can use Clutter alongside with it.
If you're specifically looking into DB, XML (GTK+ has a parser for a subset of XML) and threading (GTK+ has GLib) features then Qt will offer all that in QtSql, QtXml and QtConcurrent.
All in all, I would say Qt is a sure choice. But GTK+ is very capable as well.
I'm not sure you will get a crystal clear answer for your question, which explains why some people keep preferring Gnome over KDE or vice-versa. Choose what works best for you.
PS: I you plan to also target Symbian, then go for Qt.
EDIT: Something that is also great with Qt is QtWebView: it brings Chromium into your Qt application to display web content. Others are embedding web content into their application using for instance Awesomium or Berkelium.
I've used GTK+, QT and wxWidgets before. Here's a brief summary:
For my first cross platform UI project I decided to go for wxWidgets mainly because at the time the license wasn't as restrictive as QT's (QT was GPL and only for Linux) and it had platform specific UI (unlike GTK). The project worked out well but there were quite a few glitches getting it to compile and run properly in other platforms - sometimes some events were fired up differently and such. Also GDI in wxWidgets was pretty slow.
Next I used GTK for a different project in python. For this I used the python bindings and everything worked out more or less smoothly. I didn't quite like the fact that the UI didn't look native on Windows and Mac and also when you launch a GTK+ app it always debug outputs loads of CRITICAL warnings which seem fine to ignore. :S
Finally, I did a very simple QT project now that Nokia has acquired it and was brilliant. The best of the three. First off, if you're not an old schooler who prefers VI or Emacs, QtCreator is brilliant. I really love VI and used it for years but I much prefer QtCreator for C++ QT projects. Regarding the library I also liked a lot the documentation and the APIs provided. QT has a concept of slots and signals which introduce new C++ keywords and a preprocessor. Basically, after reading a tutorial you'll get it easily and will start to love it. I'm now doing iPhone dev and it does feel a bit like Cocoa's/Interface Builder's UI paradigm.
Summary: I'd go for QT hands down. The license is pretty good and the SDK and documentation really nice.
I have never used GTK, but from my personal experience using Qt:
It is much more than a simple GUI. It's a whole application framework. I used to think of it as the Java libraries for C++. It provides all you mention -- database, XML, networking and threading, and more. It also provides things such as containers and iterators, and counterparts to a number of boost libraries.
The thing that impressed me most when starting to use Qt was the extremely extensive documentation. You get a program called Qt Assistant, which provides fully indexed and searchable API documentation on your desktop, as well as numerous code examples and tutorials. I found it made a big difference in searching the web each time for API info. Very quick access when you need to remember a method signature.
I am not sure which is most common; that's probably hard to measure accurately. They're certainly both popular. As Gnome is the default desktop of Ubuntu, and Gnome sits on top of GTK, it obviously has widespread usage. Of course, KDE is very popular as well. Nokia is heavily pushing Qt in the mobile space -- their Maemo OS, used on the new N900 for example, is soon to switch to Qt as the default toolkit (currently it is GTK.) I believe Qt will also soon become the default toolkit for Symbian OS.
I have not used Qt Creator, but I have heard many good things about it. It is a C++ IDE with obvious heavy integration with Qt. It also has fake vim emulation which is always nice if you like that kind of thing!
Qt uses qmake for build configuration. I found this much nicer than having to write your own makefiles. I do not know what GTK uses for building.
A couple of things I found a bit offputting with Qt at first was its big uses of preprocessor macros. The signal/slots system provides a nice mechanism for event/message passing in your application, but it does feel a bit like magic that may not be easily portable to another toolkit if you ever want to. Also, the moc (meta-object compiler), while I'm not entirely sure what it does, also feels a bit too much like magic going on behind the scenes.
All in all, though, I would recommend Qt, particularly if you are learning. It has really amazing documentation and a nice IDE, and busy forums. You'll be able to build C++ apps very rapidly with it, particularly with the QML coming in 4.7.
It probably depends on what you want to do. I would recommend Qt, because it's more than GUI, it has nice Python bindings (so does Gtk), and GUI libraries themselves are (subjectively speaking) more pleasant then Gtk.
Gtk is on the other hand more common in linux world, so you can probably get more help on the web. Reason for widespread of Gtk probably has more to do with Gnome and Ubuntu, rather then technical merits, but if you want you software to blend nicely with those two, you'll achieve that more easily with Gtk.
Qt for one sure has solid DB, network, threading support etc... It does a lot more then just cross-platform GUI (and it does most of it quite well).
I'd recommend it over GTK+.
Qt. It's not only object oriented, is "good" object oriented.
It's based on a "subset" of C++ that doesn't rely on the obscurity of C++ (but you are allowed to stick with them, if you fancy masochism ;) ).
It has a strong momentum now that Nokia bought it (actually Nokia did ~2/3 years ago). It's going to be in all Nokia AND Intel mobile devices (smartphones, netbooks, tablets).
It's the backbone of KDE, so it's very mature, but it's designed in a very flexible way, that makes it possible to support TODAY all the latest "cool stuff" that a more-then-just-GUI framework should have.
Go for it.
Just adding QT advantages to other answers.. QT has great documentation, its own IDE & GUI creator and enhances C++ with some new concepts like slots/signals (basically events).
I am not a GTK developer, so I can't compare those to the GTK world :(
It also looks like Nokia is about to use Qt everywhere, like on Maemo
If you want your app to run on iOS, Android, Blackberry, other mobile platforms, Windows, Mac OSX, and Linux, use Qt.
qt-project.org

Jdesktop or Qt for better Desktop application

I will make a desktop application. I searched on web which one is better. Can someone say positive and negative sides of these components.
I can add some information about QT:
QT is a well designed, portable library that covers nearly everything you'll need for a desktop application. QT covers GUI, networking, SQL, Graphics and more.
Pros:
very extensive library
high performance
portable
Cons:
It's C++
special preprocessor / make tool needed.
Setting up a QT compile environment is a little bit more difficult than setting up a C++ compile environment. C++ is - especially if you are not used to it - very difficult and the learning curve is steep. QT helps alot with appropriate helper classes (QPointer, ...) and library magic (QObjects freeing children, ...) in the background. There are bindings to other languages as well. Just to mention a few - Jambi is a binding for Java and there's a binding for python as well.
For your decision consider the following things
which programming language do you know best
which libray reduces your amout of work for this application the most
how much performance do you REALLY need. C++ code can be very fast, but there's no reason to work with manual memory management and pointers if you don't need the performance.
which library offers you the look and feel you want to have for your desktop application
If you need portability: Do you want to "compile once run everywhere" (Java) or do you want to "run your app everywhere once you compiled it for this plattform" (QT)
Here's the link to QT-Jambi Wiki: http://qt.gitorious.org/qt-jambi/pages/Home. According to Nokia: "Qt Jambi is the Qt GUI toolkit for Java developers"
Qt is the best cross platform GUI framework at the moment. It renders the widgets with a native look on each platform and it has a very easy to use API.
Using Qt doesn't mean that you have to use C++. You can program Qt in Java (Qt Jambi) or Python (PyQt) for instance.

Resources