C++ 在 DirectX 中使用 Qt?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1641286/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Using Qt with DirectX?
提问by Tom J Nowell
What exactly are my options? I have programs I need to write in OpenGLand DirectX, and I'd like to use Qtfor OpenGL, and not have to re-implement half my program for the DirectX components of my task.
我的选择究竟是什么?我有需要用OpenGL和DirectX编写的程序,我想将Qt用于 OpenGL,而不必为我的任务的 DirectX 组件重新实现我的一半程序。
I've looked on Google and I have found references to people complaining about Direct3Dbeing a dependency of Qt, and people talking about implementing QD3DWidget sub-classing QWidget in a similar fashion to QGLWidget, yet nobody talked about how to implement it or where any examples are.
我在谷歌上看过,我发现有人抱怨Direct3D是 Qt 的依赖项,有人在谈论以与 QGLWidget 类似的方式实现 QD3DWidget 子类化 QWidget,但没有人谈论如何实现它或在哪里例子是。
I need help. I want to know if it is possible? What would I need to do to get it working? Has it been done before?
我需要帮助。我想知道是否可以?我需要做什么才能让它工作?以前做过吗?
回答by blueskin
its pretty straightforward than I thought,
它比我想象的要简单,
-> Create a QWidget
-> Override paintEngine() method, does nothing, just returns NULL
-> Assign HWND to widget->winId()
#ifdef USE_QTGUI
QApplication a(argc, argv);
CD3DWidget wndw; wndw.show(); wndw.resize(1280,960);
hWnd = wndw.winId();
#else
hWnd = CreateAppWindow(name,300,300);
#endif
//CD3DWidget class contains only the following definitions
CD3DWidget::CD3DWidget(QWidget * parent):QWidget(parent){ }
QPaintEngine *CD3DWidget::paintEngine (){ return NULL; }
Thanks,
谢谢,
CV
简历
回答by TopSergey
List of changes:
更改列表:
Qt 4.6 introduces many new features and improvements as well as bugfixes over the 4.5.x series.
Qt 4.6 在 4.5.x 系列上引入了许多新功能和改进以及错误修正。
......................
......................
- The experimental Direct3D paint engine has been removed. The reason for this is that Nokia focuses on OpenGL for desktop hardware accelerated rendering.
- 实验性 Direct3D 绘制引擎已被删除。这样做的原因是诺基亚专注于桌面硬件加速渲染的 OpenGL。
......................
......................
回答by Extrakun
For all its worth, here is how to get Ogre3D's output to a Qt 4.5 window. Basically, you grab a rendering surface and you use it to render the output. This is a "Qt in D3D/OpenGL application approach".
无论如何,这里是如何将 Ogre3D 的输出输出到 Qt 4.5 window。基本上,您获取一个渲染表面并使用它来渲染输出。这是“D3D/OpenGL 应用程序中的 Qt 方法”。
Here are OpenGL examples with Qt 4.5 using OpenGL window.
以下是使用 OpenGL window 的 Qt 4.5 的OpenGL 示例。
If I understand it correctly, the Direct3D support is experimental and is only used for painting of windows.
如果我理解正确的话,Direct3D 支持是实验性的,仅用于绘制 windows。