开发者

SlimDX - Set state block

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 Sli开发者_如何学CmDX.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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜