Xen-XNA state dirtying interop

Apr 16, 2011 at 10:38 AM


I realize that Xen isn't truly meant to be used side-by-side with regular XNA draw calls, although it does provide some facilities to make this easier like allowing the user to add a DrawableComponent into a draw target etc.

My question is two fold.

I'm seeing that other than the Xen code call "DirtyInternalRenderState" internally when it thinks is necessary, the user of the library cannot call this externally. I've looked around, but didn't see a good way to force Xen to "resyncronize" it's state after a series of XNA native draw calls are executed. Is there one?

For the time being, I exposed the call "DirtyInternalRenderState" as public so I can invoke it when necessary. So far so good. The only problem I saw was that, when I render an XNA Model (not a Xen Model), and then call DirtyInternalRenderState afterwards, things seem to almost work fine when I start to render Xen native objects again. The only problem is the index buffer which is stored internall in the DrawState which doesn't get dirtied alongside the render of the renderstate. So I simply changed the function DirtyInternalRenderState to do this:

public void DirtyInternalRenderState(StateFlag dirtyState)
    this.IndexBuffer = null;

I was hoping to find some piece of code in Xen that keeps me from hacking it so I figured I'd ask it here.

Last but not least, I'd like to thank you for creating a robust system with all the facilities one needs to make a full fledged game. My hope is to see a good composition of this library with Nuclex (that also happens to be on CodePlex) as each project happens to have some really nice features that all XNA developers would love to use. :)