Qt C++ Library for Windows and OpenGL - c++

I am trying to experiment with the Qt library on Windows. On their downloads page, I notice that the binaries built using VS2012 are available in two forms, with and without OpenGL. What exactly is the difference between the two? In the OpenGL version, do they have some special API implemented using OpenGL or does all of Qt rendering depend on OpenGL? Also, is there a version of Qt that uses DirectX?

#Raman: The opengl variant is using the desktop opengl version just like with Qt4.
The non-opengl variant is using angle, and you need to have that installed alongside the DirectX SDK to get it working. Angle is an adapter between the directx and the opengles API. Only the latter is support directly by Qt, but unfortunately directx drivers tend to work better on Windows than the opengl(es) ones. There are no plans to support a directx backend inside Qt, so we leave with Google's Angle work in that regard.
As for providing some extra bit, there was a discussion about it recently on the mailing list, that this decision should not be build time, but more like run time. However, no one has stood up just yet to make that work. Hopefully, that will change soon. It is causing confusion for the end users just like, so do not feel alone. ;-)
Hope this explanation helps.

DirectX is supported via the ANGLE based library.

Note that this has changed and as of Qt 5.5 the prebuilt binaries you can download from the Qt website are configured with the -opengl dynamic option. This is what #lpapp above was talking about. Qt defaults to choosing either native OpenGL drivers or ANGLE at run time now.
Qt internally uses OpenGL to render unless you specify otherwise now. You can also render custom OpenGL content using Qt's QOpenGLxxx functions and classes.
For a simple introduction to Qt and OpenGL that covers this and more click here.

Related

How to set up mac for graphics programming to use openGL?

I am a new to programming and also to this platform so i apologize if
my question is not proper or seems stupid but i need help .None of the
resources on internet have been useful to me . If possible please
provide step by step instrction to set up mac for graphics
programming. thank you in advance.
I am a new to programming and i am trying to learn graphics programming .Till now i write c/c++ code in a text editor and compile and execute them to see the output in shell . I searched the web for setting up mac for opengl projects but none of them come close to clearing my doubts . Here are the doubts/questions :
my computer: macOS-Mojave :macbook pro mid 2012 (intel hd graphics 4000) supports openGL 4.1 according to apple website
1. do i have to download some files to use openGL ? or is it just a an api implemented by the computer hardware manufacturer(here apple in my case ).
2. according to recent news apple deprecated openGL. And i don't know which version of openGL is on my macbook . is there a way to find out ?None of the answers listed have worked for me.
3.Can i compile openGL code through terminal like i have been doing till now or do i have to use xcode ?
1. do i have to download some files to use openGL?
So far, not yet. Everything required ships with the compilers by default. You just add -framework OpenGL to your compiler invocations and are good to go.
2. according to recent news apple deprecated OpenGL. And i don't know which version of openGL is on my macbook. is there a way to find out? None of the answers listed have worked for me.
You're mixing two different concepts here:
The deprecation of OpenGL in the macOS platform means, that OpenGL will disappear from that OS altogether, irrespective of what OpenGL version actually is supported. Eventually you'll have to either move to Metal, or use some wrapper like MoltenGL (which implements OpenGL on top of Metal) or MoltenVK (which implements Vulkan on top of Metal).
With macOS the highest OpenGL version supported is determined entirely by the version of macOS installed. That is different from other OS, where a mere driver update may give you a higher OpenGL version, as long as the installed graphics hardware meets the requirements of that higher OpenGL version.
3. Can i compile openGL code through terminal like i have been doing till now or do i have to use xcode?
Yes. And there's no difference between compiling from the command line, and through Xcode, because Xcode is just doing the very same command calls as you'd do through the terminal.

Qt 5.7 black screen on windows

I have just upgraded my project to use Qt 5.7, on Mac I am able to load the html pages using Qt Webengine but on Window 7, the pages are not displayed, instead a black screen is shown.
I have also compiled simple browser example and it too only shows a black screen.
I am using the visual studio 2013 build of Qt 5.7
Does anyone know why it is not displaying the pages.
Does Qt 5.7 need any third party libraries for it render correctly on Windows.
We had a similar problem, whenever we started an application with a QWebEngineView it would only show a black screen or even crash on another machine. The problems occured due to wrong versions of api-ms-*.dlls and d3dcompiler_47.dll we had packaged with our app.
We found the correct versions on our developer machine with installed Windows SDK under "C:\Program Files (x86)\Windows Kits\10\Redist".
On a side note: We found that deployement of QWebEngine under windows is quite a hassle.. you also need to include "qtwebengine_locales" from qtbase\translations and "resources" from qtbase as well as "QtWebEngineProcess.exe" from qtbase\bin.
A thing that helped tracking down the problem, was putting "CONFIG += console" in the pro-file. That way the console output with relevant error information is shown on deployement targets.
With help of this comment from peppe
One can use temporary workaround with graphic drivers not supporting DirectX11 but supporting DirectX9
As said here
https://doc.qt.io/qt-5/windows-requirements.html#dynamically-loading-graphics-drivers
Graphics Drivers
For Qt Quick 2 to work, a graphics driver that provides OpenGL 2.1 or higher is required. The default driver from Windows is OpenGL 1.1. Qt includes a version of the ANGLE project which is included from the Windows Qt installers. ANGLE implements the OpenGL ES 2.0 API on top of DirectX 11 or DirectX 9. ANGLE requires that the DirectX SDK is installed when building Qt.
ANGLE chooses the render backend depending on availability. DirectX 11 is usually preferable. However, some graphics cards may not fully support it. For these cases, the environment variable QT_ANGLE_PLATFORM (introduced in Qt 5.4) can be used to control the render backend. Possible values are d3d11, d3d9 and warp.
So this may help
set QT_ANGLE_PLATFORM=d3d9
Or use mesa with
https://www.mesa3d.org/llvmpipe.html
Qt::AA_UseSoftwareOpenGL is special in the sense that it will try to load an OpenGL implementation with a non-standard name. The default name is opengl32sw.dll. This allows shipping a software-only OpenGL implementation, for example a build of Mesa with llvmpipe, under this name. If necessary, the filename can be overridden by setting the QT_OPENGL_DLL environment variable.
Edit 1:
One can use fallback method for one-time login to Dropbox Windows client ( made with QT framework ) for example
Dynamically Loading Graphics Drivers
In addition to the build time configuration, Qt supports choosing and loading the OpenGL implementation at runtime. To use this mode, pass -opengl dynamic to the configure script.
Note: As of Qt 5.5 this is the configuration used by the official, pre-built binary packages of Qt. It is strongly recommended to use it also in custom builds, especially for Qt binaries that are deployed alongside applications.
...
This configuration is the most flexible because no dependencies or assumptions are hardcoded about the OpenGL implementation during build time. It allows robust application deployment. When a given environment fails to provide a proper OpenGL 2.0 implementation, it will fall back automatically to ANGLE. This fallback will be completely transparent to the application, and will allow Qt Quick or other OpenGL code to function by translating to Direct3D. Such a fallback could, for example, take place on a Windows 7 PC with no additional graphics drivers installed. On other machines, where there is sufficient OpenGL support, the normal desktop OpenGL drivers will be used. Additionally, pure software-based OpenGL implementations may be available as additional fallbacks in the future, allowing running Qt Quick applications without a GPU.
When configured with -opengl dynamic, neither Qt nor the applications built using qmake will link to the opengl32 (standard desktop OpenGL) or QtANGLE libraries. Instead, the appropriate library is chosen at runtime. By default, Qt will determine whether the system's opengl32.dll provides OpenGL 2 functions. If these are present, opengl32.dll is used, otherwise the ANGLE libraries (libEGL.dll and libGLESv2.dll) will be used. In case the ANGLE libraries are missing or initialization fails for some reason, an additional fallback is attempted by trying to load opengl32sw.dll. See below for details.
Such a fallback could, for example, take place on a Windows 7 PC with
no additional graphics drivers installed.
To emulate this conditions one can use RDP session with mandatory 8 bpp to Windows machine

Force Unreal Engine to use opengl on windows executable

I'm attempting to make a video game in Unreal Engine 4.9. I'm building it for Windows, but I'd like to have it use opengl instead of directx in the executable. However, I've found no options that let you do this. Unreal Engine uses OpenGL when it creates executables for Linux and Mac, but there seems to be no way to use OpenGL with Windows.
Am I missing something? Is there some way to force Unreal Engine to use OpenGL in Windows executables?
EDIT: The reason I want to use OpenGL is because I want this game to run without having to install anything on the end user's computer (DirectX has to be installed to work)
Microsoft doesn't really support OpenGL, they typically go out of their way to make it very difficult to use OpenGL on Windows and strongly encourage people to use DirectX instead.
The simplest way to get a working OpenGL context in windows is sometimes to use ANGLE which is a compatibility layer which translates OpenGL calls to DirectX calls. This is what Chrome and Firefox use to support WebGL on windows. I doubt that Unreal Engine is integrated with this, so you might have a hard time.
Edit:
EDIT: The reason I want to use OpenGL is because I want this game to run without having to install anything on the end user's computer (DirectX has to be installed to work)
One thing you could do is cross-compile the Mesa3D drivers, as described here: https://wiki.qt.io/Cross_compiling_Mesa_for_Windows
But then you won't get hardware acceleration.

Where to download opengl sdk (v. 3 or v. 4)?

Wikipedia says that OpenGl V4.x is the latest. However my Visual Studio 2012 just offers the following version
#define GL_VERSION_1_1 1
So my questions:
Which version is the most common that I should use? E.g. version 2.x because there are many tutorials, it is backward compatible etc.? I may have to mention that I normally prefer to write in C++, so is any version of Opengl e.g. offering namespaces? Are there huge differences between OpenGl 2,3 and 4?
And where can I get the Libs+Header files e.g. for OpenGl 4?
And where can I get the Libs+Header files e.g. for OpenGl 4?
You don't. OpenGL uses the so called "extension mechanism" to load functionality that's beyond the system ABI version. There exist third party libraries that do the extension loading and provide a header with the extended functionality.
Most popular is GLEW, which has its homepage at http://glew.sourceforge.net ; be warned though that right now of writing this GLEW is not up to date with OpenGL-3 and later core profiles. You must use compatibility profiles with GLEW or things get unstable.
AFAIK, the most popular GL development library is GLEW:
http://glew.sourceforge.net
There is no official OpenGL SDK. If you want to use newer functions you have to use a third party library such as GLEW or GLFW.

Qt 4.x/5.x and OpenGL for Desktop Gui application: What module to choose?

I am starting a new GUI application project using Qt and OpenGL for Linux/Windows desktops. My assumptions so far: use Qt GUI (C++ ... not QML/QtQuick 2) with OpenGL 4.1 or higher (requirement). After some reading, I am completely lost about what path to choose. What path will keep my application future-proof in term of support and libraries.
Qt 4.x or Qt 5.x?
Standard OpenGL or QGL or QOpenGL or QtOpenGL wrappers?
QWidget/QGLWidget (Qt 4.x) or QWindow (Qt 5.x)?
The application is intended to run in desktop environment and will do a lot of file (geometry) opening/saving, instanced 3D painting and some imaging. Could someone point me out to the best combination to choose with some explanation if possible?
Sean Harmer presentation on Qt 5 and OpenGL did answer some parts of my questions but I was a bit lost when he started using QML and QtQuick 2. I felt like QOpenGL was a lightweighted version to be used with QtQuick 2. Correct me If I am wrong on that please.
Qt 5.0 is still in beta, therefore if your project is serious, you should go with qt 4.8, because that is the latest stable release. However, if you must have some Qt 5.0 features, then you have no other choice but to go with 5.0.
Since you chosen Qt, you should stick to it. That means using QtOpenGL. That doesn't mean you are not going to use standard OpenGL. QtOpenGL provides you API to simplify some OpenGL calls, and make them more object oriented. After all, OpenGL is set of C functions, not set of c++ classes.