[SOLVED] Qt and DirectX
-
Hi,
I am using Qt 5.2.1 Windows ANGLE build and I would like to retrieve underlying DirectX informations.
I have a GLWidget in which I do some OpenGL stuff and I want to get pointers to DirectX textures, swapchain, contexts that are instantiated by Qt (or more exactly by ANGLE).
Is it possible from Qt ? -
I am not familiar with ANGLE but I have looked up doing something similar using a graphics engine that can make use of DirectX so I can give you a basic answer.
You can't do this from Qt directly but you can incorporate DirectX into a Qt application. You can even host a direct X drawing surface inside a Qt widget. You just have to realize that Qt won't be able to access DirectX for you. You must create the interface yourself and link the drawing surface to the Qt widget's handle.
You can find examples of this and similar tasks around the internet. "Here":https://code.google.com/p/qtdxsample/ is one example to give you a head start.
-
Hi,
[quote author="apap_" date="1410424647"]I don't want to do DirectX stuff, I just want to retrieve DirectX resources instantiated by Qt/ANGLE.
[/quote]That's not possible unfortunately. ANGLE does not expose any DirectX resources -- it only provides an implementation for pure OpenGL API.What do you want to do with the DirectX resources?
-
I need to provide these resources to Oculus SDK which do some stuff on texture before displaying it (lens distortion, correction of chromatic aberration, ...).
There something that I do not understand, when does ANGLE wraps OpenGL calls to DirectX ? I did not find any direct call to ANGLE API from Qt source code.
Qt ANGLE is based on D3D9 right ? Is it possible to wrap to D3D11 ?After looking to ANGLE source code in Qt sources, I find private members which hold the needed resources (swapchain, device, texture, ...), should it possible to patch Qt ANGLE to have these resources exposed public ?
-
[quote author="apap_" date="1410464937"]I need to provide these resources to Oculus SDK which do some stuff on texture before displaying it (lens distortion, correction of chromatic aberration, ...).[/quote]Neat!
[quote author="apap_" date="1410464937"]There something that I do not understand, when does ANGLE wraps OpenGL calls to DirectX ? I did not find any direct call to ANGLE API from Qt source code.[/quote]ANGLE API = OpenGL functions
ANGLE does not provide its own API. It is an implementation of the OpenGL API. This implementation calls DirectX functions, which then interact with the GPU.
Similarly, graphics card vendors also provide their own implementation of OpenGL that are optimized for their GPUs. These implementations become available on your PC when you install your graphics drivers (e.g. AMD drivers or Nvidia drivers). These implementations interact directly with the GPU.
Qt code simply calls OpenGL functions. It doesn't care who provides the implementation.
To think about it a different way, these headers form the ANGLE API: https://qt.gitorious.org/qt/qtbase/source/src/3rdparty/angle/include (notice that they are OpenGL functions that are called by Qt)
[quote author="apap_" date="1410464937"]Qt ANGLE is based on D3D9 right ? Is it possible to wrap to D3D11 ?[/quote]For the upcoming Qt 5.4.0 release, you don't need to do anything special. ANGLE will use D3D11 by default. If the GPU doesn't support D3D11, ANGLE will automatically fall back to D3D9.
For Qt 5.3 and earlier, use the following option when you configure Qt (you will need to build Qt yourself):
@-angle-d3d11@(If you're interested, here is the patch which made D3D11 default: https://codereview.qt-project.org/#/c/93618/ The commit message contains an explanation.)
[quote author="apap_" date="1410464937"]After looking to ANGLE source code in Qt sources, I find private members which hold the needed resources (swapchain, device, texture, ...), should it possible to patch Qt ANGLE to have these resources exposed public ?[/quote]It should be possible, in theory. You will have to patch and build ANGLE yourself.
-
You're welcome. Good luck with your project!
If your questions have been resolved, please edit your original post to add "[SOLVED]" to the title.