DirectX 9 - 创建设备并渲染到 DLL 内的纹理?

发布于 2024-10-02 22:02:43 字数 760 浏览 0 评论 0原文

我试图在 DLL 中创建托管 DirectX 9 设备,然后使用该 DLL 将场景渲染到屏幕外表面。我知道如何进行离屏渲染,但我的问题是:

是否可以在 DLL 内创建 directx 设备?

无力的尝试 #1 (InvalidCallException< /code>):

Device device = new Device(0, DeviceType.Hardware, null, CreateFlags.SoftwareVertexProcessing, presentParams);

无力的尝试 #2 (InvalidCallException):

Device device = new Device(0, DeviceType.Hardware, new IntPtr(0), CreateFlags.SoftwareVertexProcessing, presentParams);

可用的设备构造函数重载是:

public Device(int, DeviceType, Control, CreateFlags, PresentParameters[]);
public Device(int, DeviceType, IntPtr, CreateFlags, PresentParameters[]);

任何帮助都可能让我开心!

I am trying to create a Managed DirectX 9 Device in a DLL and then use that DLL to render scenes to an offscreen surface. I know how to do the offscreen rendering, but my question is:

Is it possible to create a directx device inside a DLL?

Feeble attempt #1 (InvalidCallException):

Device device = new Device(0, DeviceType.Hardware, null, CreateFlags.SoftwareVertexProcessing, presentParams);

Feeble attempt #2 (InvalidCallException):

Device device = new Device(0, DeviceType.Hardware, new IntPtr(0), CreateFlags.SoftwareVertexProcessing, presentParams);

The device constructor overloads available are:

public Device(int, DeviceType, Control, CreateFlags, PresentParameters[]);
public Device(int, DeviceType, IntPtr, CreateFlags, PresentParameters[]);

Any help could quite possibly make my day!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

一瞬间的火花 2024-10-09 22:02:43

找到了答案。我创建了一个隐藏控件,适当地设置它的宽度和高度,然后将其设置为目标。作品完美。对于那些稍后可能会偶然发现这一点的人来说,这里是代码:

// Create the hidden control
Control hiddenControl = new Control();
control.Width = width;
control.Height = height;
control.Visible = false;         // Just for good measure, it wouldn't be displayed anyways

// Present Parameters
PresentParamaters presentParams = new PresentParamaters();
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.Windowed = true;

// Create the device
Device device = new Device(0, DeviceType.Hardware, hiddenControl, CreateFlags.SoftwareVertexProcessing, presentParams);

这就是所需要的一切,假设就像我在渲染纹理之前所说的那样。我不确定如果您实际渲染到此控件会发生什么(如果有的话)。

Found the answer. I created a hidden control, set the width and the height of it appropriately and then set it as the target. Works perfect. For those who may stumble upon this later here is the code:

// Create the hidden control
Control hiddenControl = new Control();
control.Width = width;
control.Height = height;
control.Visible = false;         // Just for good measure, it wouldn't be displayed anyways

// Present Parameters
PresentParamaters presentParams = new PresentParamaters();
presentParams.SwapEffect = SwapEffect.Discard;
presentParams.Windowed = true;

// Create the device
Device device = new Device(0, DeviceType.Hardware, hiddenControl, CreateFlags.SoftwareVertexProcessing, presentParams);

Thats all it takes, assuming like I said before you are rendering to a texture. I'm not sure what (if anything) would happen if you were to actually render to this control.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文