Don’t use QT OpenGL anymore? - c++

I am new to C++, OpenGL, and QT. In fact, I’ve never even touched QT. The reason for this is the following; I’ve made games in a few other languages in the past (mostly C# with Unity). Now I want to get into games with c++. However, I want to use pure C++, not even Unreal (maybe one day ), for games. To do this I know that for graphics I should almost definitely be using OpenGL (which I’m currently learning). I also am going to need to make GUIs. When I looked up what to use, it looked like the best option would probably be QT. This means I need QT to work with OpenGL. So again I looked it up. I found QT OpenGL on this post: How to work with OpenGL and QT?. When I looked up Qt OpenGL (https://doc.qt.io/qt-5/qtopengl-index.html) it said:
Warning: This module should not be used anymore for new code. Please use the corresponding OpenGL classes in Qt GUI.
So what is QT GUI?
And, how easy it to use QT with OpenGL?

As the new features of Qt 5.4 point out, the Qt Opengl module has been declared deprecated.
Deprecated features
Qt OpenGL:
The Qt OpenGL module (which contain classes that start with "QGL") is now deprecated in favor of the Qt GUI module (which contain
classes that start with "QOpenGL"). QGLWidget can now be replaced by
QOpenGLWidget.
That does not imply that:
the module has been removed but at any time Qt could remove it without notice.
You cannot use opengl in Qt, only you should not use the QGLX classes that belong to the Qt OpenGL package but you must use the QOpenGLX classes of the Qt Gui module, for example replace QGLWidget with QOpenGLWidget.
You can also find several examples here.

Qt is probably not the right tool for you. For one you want to use GLFW, which would cross into the turf of Qt and vice versa. A much better choice for game UI stuff is Dear ImGUI which is far better suited for the needs of game development.

Related

OpenGL in Qt Quick cross platform application

I'm trying to develop a cross platform (or at least desktop + embedded hardware) application. I would like to use Qt Quick to create a touch friendly GUI. I have been implemented a classical application with a QGLWidget displaying data. It is important that only a part of the window is in OpenGL. Because of this there are problems with EGLFS and LinuxFB. Only X11 (or maybe Wayland) can display the application properly (others generates a couple of errors about missing setParent function and the whole screen is black). Now I'm trying to achieve the same thing in QML. I want to use this OpenGL renderer as part of my QML application and some Qt Quick widgets around it. I found a couple of people asking about the same thing and the answer is always to subclass QDeclarativeItem and call the painter's beginNativePainting() (the others says to export it through QDeclarativeItem, but I cannot figure out how to do this). The problem is that on desktop, Qt 5.11 the native painter is not OpenGL. And in QT5 there is no way to force OpenGL graphics system. So when I try to get the OpenGL context (QGLContext::currentContext()) I always get NULL. Another problem: If I export my widget with qmlRegisterType("Test", 1, 0, "Test"); it becomes only visible when I use QDeclarativeView, but then it doesn't sees Qt Quick. If I use QQuickView it says module "Test" is not installed. How can I implement this properly?
QDeclarativeItem is from Qt Quick 1 and Qt4. With Qt 5 and Qt Quick 2 you should use QQuickItem.
There is at least 1 example of this provided with qt docs, which you can find in Qt Creator in the Welcome tab in the Examples section.

difference of freeglut vs glew?

I've recently started learning OpenGL (> 3.3) & I've noticed a lot of examples & tutorials use both freeglut & glew, but don't really explain the difference at all. The best description I've found, after googling & reading ad nauseum, has been this OpenGL Related toolkits and APIs but found it lacking. I've even read the tag info on SO.
As someone really new to OpenGL I'm still trying to get a grasp of the different concepts. I've gotten to the stage of creating a basic program that uses glew, create context (on windows, VS2010), & draw really basic shapes, all without the need for explicitly including freeglut. So I don't understand why I would need it.
So my question then is, what's the difference between:
-freeglut
-glew
-(& glfw)
What can one do that the other can't?
The OpenGL Extension Wrangler (GLEW) is used to access the modern OpenGL API functions(version 3.2 up to latest version).If we use an ancient version of OpenGL then we can access the OpenGL functions simply including as #include <GL/gl.h>.But in modern OpenGL, the API functions are determined at run time, not compile time. GLEW will handle the run time loading of the OpenGL API.About GLEW see here
GLFW or freeglut will allow us to create a window, and receive mouse and keyboard input in a cross-platform way. OpenGL does not handle window creation or input, so we have to use these library for handling window, keyboard, mouse, joysticks, input and other purpose.
GLFW and freeglut are alternative for us according to our need we can choose any one but GLEW is different from them which is used for run time loading of the OpenGL API.
I'm using both of them for some work at my university.
GLEW is a "cross-platform open-source C/C++ extension loading library" (from its website), while freeglut is a window manager that replaces the default OpenGL Utility Toolkit (GLUT) library.
So, as you see, both different have different purposes. The point of using freeglut is that it's still maintained, while the default GLUT isn't, so if you want bug fixes and new features you should use it :)

Gui library for game

I'm making a game with OpenGL render api. Now I need in level editor. It should consist of lots of widgets parents/children etc, so it's hard to write need widgets by hands.
Any ideas about good gui-system which can be easilly connected with opengl? The most important part is gui editing. I really need some editing-tool for it.
Thanks
You should have a look to http://qt.nokia.com/ .
It is very easy to inject the OpenGL rendering into Qt widgets.
To easily edit your GUI, you can use Qt Creator ( http://qt.nokia.com/products/developer-tools ).
You have several options (and this has been answered before, but probably not exactly like this):
SDL: very good abstraction layer for audio, graphics and anything related. It will force you to write your widget stuff by hand.
Qt: has an OpenGL module that makes it easy to set up an OpenGL context. It will make widgets and everything very easy.
wxWidgets: same as Qt, but has slightly worse documentation and tools (if I might be so blunt)
I'd go with number two: it has a beautiful Designer tool to create Widgets with all the fancyness you'll need. OpenGL is also built right in.
If you're running Windows (can't confirm Mono will do it), another option would be to use C# and WinForms to make your life significantly easier.
Check out CEGUI:
http://www.cegui.org.uk/wiki/index.php/Main_Page
It defines its GUIs in XML and has editors for it.

What is most commonly used as a window manager for OpenGL nowadays?

Glut seems rather old, and SDL also as if it's not the youngest anymore - what is being used as (cross-platform) window manager for OpenGL nowadays?
Cross platform UI toolkit
1. wxwidgets
2. fltk
3. qt
4. glut(freeglut)
5. sdl
I have used glui. Sucks real bad(in terms of performance). There huge difference in performance penalty just by including glui(without actually using it) in your apps.
To be honest, i prefer platform specific UI toolkit. Faster. Reliable.
Depends on how you want to use it. Don't think there is a clear winner.
I like to use Qt because I'm familiar with it so it feels easy to me, and because I use it for other UI elements in my mostly windowed openGL apps.
Haven't tried it myself, yet, but want to in my next project. It seems to be very popular.
SFML . It`s the "successor" to SDL written in C++
I am using freeglut, but it is just a bit improved glut.
You can also use QT
I think GLFW is the best choice for small to medium applications/games. This type of libraries should be easy,small and fast with no extra services such as image helper functions and so on. GLFW is going to remove all helper functions to focus on the main goal.
QT is the best for graphics applications but not for games or small applications.

C++ OpenGL Window Kit

Besides Qt, GTK, wxWidgets... What are the recommendations for a cross platform, open source GUI framework library that works with OpenGL?
Its not quite a GUI framework. But GLFW is good for an OpenGL window with some extra features like keyboard and joystick handling.
I found the other framework I was looking for. It is SFML. I only used it briefly but I do remember liking it very much. It does contain a lot of nice extras going a step further than GLFW. If I recall correctly the documentation was stellar.
For a full featured cross-platform GUI framework I think you would be hard pressed to beat QT, GTK, or wx.
I'm not sure, but at a guess, the other framework mfperzel was trying to think of might have been fltk (the "fast light tool kit"). Where glfw is mostly an OpenGL window with some ability to read the mouse and keyboard, fltk is a GUI framework that supports OpenGL (but as the name implies it's still quite a bit smaller and faster than most GUI frameworks). I haven't tried it yet, but there's a new GUI builder program for it (FLUID) that looks fairly promising as well. One warning though: FLTK uses its own widgets, which tend to look at least a little foreign to most users.