简体   繁体   English

具有DeviceContext的SharpDX / SolidColorBrush构造函数?

[英]SharpDX/SolidColorBrush constructor with DeviceContext?

I am learning Direct2D for a application (in c# using sharpdx) but I have an hard time to find which is the up-to-date way to work.. 我正在为应用程序学习Direct2D(使用Sharpdx在C#中),但是我很难找到哪种是最新的工作方式。

Here is my current problem : 这是我目前的问题:

At first, I used Direct2D only with the D2D1Factory like descripted in the "quick start" of MSDN. 首先,我仅将D2D1Factory与Direct2D一起使用,如MSDN的“快速入门”中所述。 But when looking to optimize performance, it seem that I should draw using the ID2D1DeviceContext to have access to some caching mechanism . 但是,当寻求优化性能时,似乎应该使用ID2D1DeviceContext进行绘制以访问某些缓存机制 So I followed this MSDN article to update my application. 因此,我遵循了这篇MSDN文章来更新我的应用程序。

But the SharpDX contructor of SolidColorBrush only accept RenderTarget as first parameter, it doesn't seem to have a constructor accepting a DeviceContext. 但是SolidColorBrush的SharpDX构造函数只接受RenderTarget作为第一个参数,它似乎没有构造函数来接受DeviceContext。 But it used to have it, I have found SharpDX code sample with it. 但是它曾经拥有它,我发现了SharpDX代码示例。

Is that method decrepated ? 该方法被否决了吗? Why SharpDX has deleted this constructor ? 为什么SharpDX删除了此构造函数? Because I need to initialize the Brushes from the DeviceContext to use them with my DeviceContext draw calls. 因为我需要从DeviceContext初始化画笔,才能将其与DeviceContext绘制调用一起使用。

Creating a RenderTarget from the ID2D1Factory to create my brushes and then try to use them with ID2D1DeviceContext.Draw_something() throw a DirectX resources exception (which seem logic...) 从ID2D1Factory创建一个RenderTarget来创建我的画笔,然后尝试将它们与ID2D1DeviceContext.Draw_something()一起使用,将引发DirectX资源异常(这似乎是逻辑...)

Anyone can light me up please ? 有人可以照亮我吗?

Thank a lot. 非常感谢。

According to SDK ID2D1DeviceContext is itself a render target, it inherits from ID2D1RenderTarget. 根据SDK,ID2D1DeviceContext本身就是一个渲染目标,它继承自ID2D1RenderTarget。 So you should be able to use device context pointer as render target pointer argument value. 因此,您应该能够将设备上下文指针用作呈现目标指针参数值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM