DirectX和WPF [英] DirectX and WPF

查看:348
本文介绍了DirectX和WPF的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试开发一个应用程序,其中UI部分是由WPF设计的,而引擎是使用C ++开发的. 我试图通过使用WindowsFormsHost方法从WPF获取窗口的句柄来使用DirectX在本机代码中渲染场景.

I am trying to develop an application where the UI part is designed by WPF and the engine is developed using C++. I am trying to render a scene using DirectX in native code by getting the window's handle from WPF using WindowsFormsHost method.

尽管我没有收到任何错误,但屏幕上没有图像.

Though i do not get any error, no image renders on the screen.

就句柄而言,我没有看到任何问题,因为当我使用OpenGL在本机代码中使用相同的句柄渲染场景时,它可以正常工作.

As far as the handle is concerned, I dont see a problem because when i render the scene using OpenGL using the same handle in native code, it works properly.

就初始化部分和渲染部分而言,我没有看到任何问题,因为同一部分代码在单独的Win32项目中可以正常工作.

As far as the initialization part and rendering part is concerned, I dont see a problem because the same part of code works fine in a separate Win32 project.

此问题可能是什么原因? 使用的DirectX版本是DirectX10,使用的操作系统是Vista.

What might be the cause of this problem? The version of DirectX being used is DirectX10 and OS used is Vista.

谢谢.

推荐答案

我认为您的问题可能是由于WPF也在使用DirectX渲染窗口这一事实引起的. OpenGL可能只是因为与众不同而解决了这个问题.

I think your problem might be caused by the fact that WPF is also using DirectX to render the window. OpenGL probably gets around the issue just by being different.

如果要在WPF应用程序中渲染DirectX,请看看使用D3DImage.

If you want to render DirectX in a WPF app, have a look at using D3DImage.

http://www.codeproject.com/KB/WPF/D3DImage.aspx

这篇关于DirectX和WPF的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆