SlimDX - 设置状态块
我想在 SlimDX Direct3d9 设备中设置状态。
我在frameRender 函数的开头有该代码。
device.BeginStateBlock();
device.SetRenderState(RenderState.ZEnable, false);
device.SetRenderState(RenderState.Lighting, false);
device.SetRenderState(RenderState.CullMode, Cull.None);
device.EndStateBlock();
但我在调试窗口中收到此错误:
Object of type SlimDX.Direct3D9.StateBlock was not disposed. Stack trace of object creation:
我收到了数百万条这样的行。他们都说同样的话。 我应该如何处理这些状态?如何以正确的方式制作它?
I want to set states in SlimDX Direct3d9 device.
I have that code at the beging of frameRender function.
device.BeginStateBlock();
device.SetRenderState(RenderState.ZEnable, false);
device.SetRenderState(RenderState.Lighting, false);
device.SetRenderState(RenderState.CullMode, Cull.None);
device.EndStateBlock();
But I'm getting this error in debug window:
Object of type SlimDX.Direct3D9.StateBlock was not disposed. Stack trace of object creation:
I'm getting millions of those lines. All of them say the same thing.
How should I dispose those states? How to make it in proper way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
根据您的信息,我可以给您的唯一提示是 EndStackeBlock 应该返回一个 StateBlock 对象,该对象是一次性的。我的猜测是,您在 LostDevice 事件后得到这些?在重置设备之前,您需要释放所有这些资源。
当然,创建 StateBlocks 的全部原因是您可以创建它们一次并重用它们,但似乎您每次都重新创建它们并且从不应用它们。因此,过了一段时间,您创建了很多状态块,但没有使用或处置它们中的任何一个。
但也许您可以发布更多代码或提供更多信息。
The only hint i can give you, given your information, is that EndStackeBlock should return a StateBlock object, which is disposable. My guess is, you get these after a LostDevice event? Before you reset the device you need to free all those resources.
And of course, the whole reason to make StateBlocks is so that you create them once and reuse them, but it seems you are recreating them everytime and never applying them. So after a while you created a lot of stateblocks without using or disposing any of them.
But maybe you can post more code or give more informations.