World space

In this tutorial again there are only a few small changes that are needed to get this running in XNA 4.0

The first one we carry over from the previous tutorial is the VertexDeclaration changes

So where we initialize myVertexDeclaration in your SetUpVertices method instead of creating a new instance like so:

myVertexDeclaration = new VertexDeclaration(device, VertexPositionColor.VertexElements);

we can use the one from VertexPositionColor which looks like this:

myVertexDeclaration = VertexPositionColor.VertexDeclaration;

The next change is to how we set the Cull mode, this is now a RasterizerState (RenderState was broken down into smaller classes) which is now read-only so rather than being able to just assign the variable we have to create a new instance of the RasterizerState, then assign the CullMode, then assign the RasterizerState to the graphics card.

Which means this line:

device.RenderState.CullMode = CullMode.None;


RasterizerState rs = new RasterizerState();
rs.CullMode = CullMode.None
device.RasterizerState = rs;

And it’s as simple as that, next up Rotation – translation!


2 thoughts on “World space

  1. Thanks a lot for these updates on the brilliant tutorials of Riemer. I just started experimenting with XNA, but since I use 4.0 I ran in a few problems which I couldn’t have solved without this blog. Keep up the good work! (please 😉 )

    1. I’m glad they have helped you Mee I’ll be getting back to work on these again in two days time, hopefully I can finish this series over the four days following that.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s