By using QOpenGLContext and OpenGLVertexBufferObject, rendering looks missed depth - c++

My platform information: Qt 5.4.1, ubuntu 14.04, windows 8.1
I have made QOpenGLWindow based on QWindow. To make it OpenGLWindow, I used QOpenGLContext and made OpenGL context for each of them. In QOpenGLWindow, to render object I used VertexBufferObject of native OpenGL. and I passed vertices, normals to buffer object and rendered it. here is my two situation of this application. first one worked on ubuntu 14.04, second one worked on windows 8.1.
I have got first one because I develop application mainly on ubuntu 14.04. It seems that it doesn't know depth when it is rendered. and it looks transparent for all front faces. I had hard time to figure out problem so I tested it on windows 8.1 with same version of Qt which is Qt 5.4.1. It works fine as you can see second picture.
So I'm thinking about Qt's issue for different platform. I had similar issue before(it was fixed to Qt 5.5): https://bugreports.qt.io/browse/QTBUG-45037
is there anyone with similar problem?

Related

Qt 5.12 D3D compiler module not found

I've installed Qt 5.12 , When i want to compile my project show this
errors:
Errors :
QOpenGLShaderProgram::uniformLocation(qt_Matrix): shader program is not linked
ensureInitialized(141): D3D compiler module not found.
QOpenGLShader::link: D3D compiler module not found.
shader compilation failed:
"D3D compiler module not found.\n"
Welcome to SO!
First of all, let's clarify what the error means.
Qt uses ANGLE on Windows, which is a layer that allows to run OpenGL software on systems where OpenGL is not available, by traslanting the OpenGL calls into DirectX calls. Qt decides whether to go with pure OpenGL or ANGLE depending on the configuration of the machine (video card model, video drivers version, etc).
More details on that are available at https://wiki.qt.io/Qt_5_on_Windows_ANGLE_and_OpenGL.
Even if you are not writing any OpenGL code yourself, the qml runtime surely has a lot of OpenGL calls that again, may go through ANGLE.
That is why the confusing error message (looking for the D3D shader compiler while dealing with OpenGL code!).
Now, the Qt project bugtracker reports the same issue you have https://bugreports.qt.io/browse/QTBUG-71510, although at the time of writing no solution has been provided. I would suggest to have a look at the bugtracker now and then to monitor the progress on this issue.
A couple of workarounds you may try:
Copy the d3dcompiler_xx.dll in the same directory where your exe is;
Force Qt to use OpenGL instead of DirectX, by setting the environment variable QT_OPENGL to desktop (more details on that are at http://doc.qt.io/qt-5/windows-requirements.html)
According to bugreports.qt this issue is now fixed from version QT 5.12.1.
https://bugreports.qt.io/browse/QTBUG-71510
I have the same issue on my older Del laptop. Placing d3dcompiler_43.dll in the exe folder does solve the issue. I found using one of the following commands also works, which I assume avoids ANGLE all together.
//To use pure OpenGL :
QCoreApplication::setAttribute(Qt::AA_UseDesktopOpenGL);
//Or use software emulated OpenGL :
QCoreApplication::setAttribute(Qt::AA_UseSoftwareOpenGL);
I just include the first pure OpenGL setting in the "int main(int argc, char *argv[])" bracket in main.cpp

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

Qt C++ Library for Windows and OpenGL

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.

Ogre3D Basic Framework issue on Ubuntu

I have been trying to learn to use Ogre3D and have gotten to the stage where I want to start something more serious than the examples it comes with so I found and copied the Basic Ogre Framework
I am using Ubuntu 9.10, but have compiled Ogre 1.7 from the Ogre3D website, I am using the Netbeans 6.8 IDE with the c++ plugin.
The Basic Ogre Framework Demo App compiles and runs, but gets to the main loop where is checks to see if the Render Window is active, otherwise it calls sleep(1000);
The if statement that is checking if(OgreFramework::getSingletonPtr()->m_pRenderWnd->isActive()) is always returning false, despite specifically setting the m_pRenderWnd->setActive(true);
From reading the forum posts related to it, nobody else is having this issue, but they are primarily using windows or Mac.
Is there issues with Ogre3D on Ubuntu, or is it possibly a problem with the autogenerated makefiles that netbeans is generating?
Have you configured the application to use the correct video drivers for your system? Since you're on ubuntu you'll need to use OpenGL. I found some drivers didn't work on some systems when using Ogre.