Hi Chad,On page 77 you are missing the following line of code from the new Draw method:
graphics.GraphicsDevice.VertexDeclaration = _vertexDeclaration; Otherwise you get an exception System.InvalidOperationException was unhandled Message="A valid vertex declaration must be set on the device before any draw operations can be performed." Source="Microsoft.Xna.Framework"
graphics.GraphicsDevice.VertexDeclaration = _vertexDeclaration;
Otherwise you get an exception
System.InvalidOperationException was unhandled Message="A valid vertex declaration must be set on the device before any draw operations can be performed." Source="Microsoft.Xna.Framework"
::Twitter::8WeekGame::Blog::
The code is in place at the top of page 74.
----------------------------------------------------------
Finally, we can change the original statement inside of Draw to set graphics device vertexdeclaration to the variable we just initialized:
graphics.GraphicsDevice.VertexDeclaration = vertexDeclaration;
Now we are only creating the vertex declaration once and setting it once instead of everyframe. This is encouraging because we are now at about 3,230 fps on the Xbox 360 andthe performance is still the same on Machine A at about 207 fps. So just with a little bit ofeffort we optimized our code from running at a mere 114 fps on the Xbox 360 to a morereasonable 3,230 fps.
--------------------------------------------
Hope this helps,
Chad