I'm working on a graphics engine, and unlike XNA 3.1, 4.0 isn't giving me access to a few variables I need.
Specifically, in 3.1 I could do:
GraphicsDevice.RenderState.CullMode = <CullMode> and GraphicsDevice.RenderState.DepthBufferEnable = bool
But in 4.0 these don't exist, however:
GraphicsDevice.RasterizerState.CullMode = <CullMode> and GraphicsDevice.DepthStencilState.DepthBufferEnable = bool do.
Oddly though, the debugger says this about them:
"InvalidOperationException was unhandled. Cannot change read-only RasterizerState. State objects become read-only the first time they are bound to a GraphicsDevice. To change property values, create a new RasterizerState instance."
Okay, I though, let's try it:
RasterizerState state = new RasterizerState();
state = parent.GraphicsDevice.RasterizerState;
float camToCenter = Vector3.Distance(camera.Position, pos);
if (camToCenter < radius)
//parent.GraphicsDevice.RasterizerState.CullMode = CullMode.CullClockwiseFace;
state.CullMode = CullMode.CullClockwiseFace;
else
//parent.GraphicsDevice.RasterizerState.CullMode = CullMode.CullCounterClockwiseFace;
state.CullMode = CullMode.CullCounterClockwiseFace;
parent.GraphicsDevice.RasterizerState = state;
It gave exactly the same error as above. Somewhere, I could swear I'm going to be missing something.
Could anyone help with this? This is the biggest, and the only, niggle (I smoothed everything else out before testing this class along side the rest of them) left but it stops EVERYTHING else from functioning. If anyone can help it'd be appreciated. It's sleepytime for me now, but as soon as I get off work tomorrow I'll be back trying to find a fix, if anyone suggests anything before then I'll give those a shot too.
Thanks in advance guys!! (happy coding)

New Topic/Question
Reply



MultiQuote



|