3

Let me post the images first...

Solid shot where tearing occurs enter image description here

And wireframe shot of that place enter image description here

I am mostly using mostly using Riemers tutorial while the render code is..

Main render

    public void Render()
    {
        device.Clear(Color.CornflowerBlue);
        RasterizerState rs = new RasterizerState();
        rs.CullMode = cullmode;
        rs.FillMode = fillmode;
        device.RasterizerState = rs;

        effect.Parameters["xView"].SetValue(camera.ViewMatrix);
        effect.Parameters["xProjection"].SetValue(camera.ProjectionMatrix);
        effect.Parameters["xWorld"].SetValue(Matrix.Identity);
        effect.Parameters["xEnableLighting"].SetValue(true);
        effect.Parameters["xLightDirection"].SetValue(lightDirection);
        effect.Parameters["xAmbient"].SetValue(0.5f);

        globals.game.terrain.Render();

        globals.game.spriteBatch.Begin();
        globals.console.Render();
        globals.game.spriteBatch.End();
    }

Terrain.Render()

    public void Render()
    {
        globals.game.graphics.effect.CurrentTechnique = globals.game.graphics.effect.Techniques["Colored"];

        globals.game.graphics.effect.Parameters["xWorld"].SetValue(worldMatrix);
        foreach (EffectPass pass in  globals.game.graphics.effect.CurrentTechnique.Passes)
        {
            pass.Apply();

            globals.game.graphics.device.Indices = indexBuffer;
            globals.game.graphics.device.SetVertexBuffer(vertexBuffer);
            globals.game.graphics.device.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, vertices.Length, 0, indices.Length / 3);          

        }
    }

I was stuck with this problem for pretty long now (not knowing if it is caused by my coding skills, xna or some g-card configuration...) so i wonder if someone have some ideas what might cause it?

4

1 回答 1

2

暂时注释掉 spritebatch 的开始、绘制和结束代码,看看是否有区别。它可能取决于缓冲区中的顶点顺序,也可能不取决于。

如果确实有帮助,可以在这里找到您的解决方案:http: //blogs.msdn.com/b/shawnhar/archive/2010/06/18/spritebatch-and-renderstates-in-xna-game-studio-4- 0.aspx

于 2013-05-20T21:47:04.033 回答