I will post some code from my old XNA project there. Wait.
It won't work because you need to end cullface rendering.
I mean something like this
cullmode state set to show
your code ----
cull mode state set to hidden
The problem could be in SpriteBatch also.
EDIT:
Found it at old my old HDD
First:
Code:
public static RasterizerState gRasterizerState;
public static BlendState gBlendState;
public static DepthStencilState gDepthStencilState;
Then initialize it:
Code:
gRasterizerState = new RasterizerState();
gBlendState = new BlendState();
gDepthStencilState = new DepthStencilState();
Render:
Code:
public static void RenderLevel(Vector3 cameraPosition, Matrix viewMatrix, Matrix projMatrix, uint gameTime, GraphicsDevice graphics)
{
// -------------
// reset and set the rasterizer states
gRasterizerState = new RasterizerState();
gRasterizerState.CullMode = CullMode.CullCounterClockwiseFace;
gRasterizerState.FillMode = FillMode.Solid;
Renderer.Device.RasterizerState = gRasterizerState;
// reset the blend and depth states
Renderer.Device.BlendState = BlendState.Opaque;
// reset and set the depthstencil states
gDepthStencilState = new DepthStencilState();
gDepthStencilState.DepthBufferEnable = true;
Renderer.Device.DepthStencilState = gDepthStencilState;
// -------------
YOUR CODE THERE
// -------------
gRasterizerState = new RasterizerState();
gRasterizerState.FillMode = FillMode.Solid;
Renderer.Device.RasterizerState = gRasterizerState;
// -------------
}
Also if it won't work, check it - there's good blog with useful stuff.
http://blogs.msdn.com/b/shawnhar/archive...o-4-0.aspx
Edit 3:
Oh yeah, as i see, in your code spritebatch.begin is before scene render... it can f*ck up your scene. Do something like this:
Code:
renderscene();
spritebatch.begin();
drawtext;
spritebatch.end();