C# 我的XNA应用程序没有';无法正确渲染

C# 我的XNA应用程序没有';无法正确渲染,c#,windows-phone-7,xna,vertex-buffer,C#,Windows Phone 7,Xna,Vertex Buffer,我试图在XNA中使用自定义顶点数据渲染三角形,但输出完全混乱: 我的GPU(Radeon HD7610M)支持DX11 要么我做错了什么,要么是我的GPU驱动程序 这是我的密码: public class MyGame : Microsoft.Xna.Framework.Game { GraphicsDeviceManager graphics; VertexBuffer vertexBuffer; VertexPositionColor[] vertices;

我试图在XNA中使用自定义顶点数据渲染三角形,但输出完全混乱:

我的GPU(Radeon HD7610M)支持DX11

要么我做错了什么,要么是我的GPU驱动程序

这是我的密码:

public class MyGame : Microsoft.Xna.Framework.Game
{
    GraphicsDeviceManager graphics;
    VertexBuffer vertexBuffer;
    VertexPositionColor[] vertices;
    BasicEffect effect;

    public MyGame()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        TargetElapsedTime = TimeSpan.FromTicks(333333);
        InactiveSleepTime = TimeSpan.FromSeconds(1);
    }
    protected override void Initialize()
    {
        base.Initialize();
    }

    protected override void LoadContent()
    {
        effect = new BasicEffect(GraphicsDevice);
        effect.VertexColorEnabled = true;

        vertices = new VertexPositionColor[]
        {
            new VertexPositionColor(new Vector3(-0.8F, -0.8F, 0), Color.Black),
            new VertexPositionColor(new Vector3(-0.8F,  0.8F, 0), Color.Black),
            new VertexPositionColor(new Vector3( 0.8F, -0.8F, 0), Color.Black),
            //new VertexPositionColor(new Vector3( 0.8F,  0.8F, 0), Color.Black),
        };

        vertexBuffer = new VertexBuffer(GraphicsDevice, VertexPositionColor.VertexDeclaration, vertices.Length, BufferUsage.WriteOnly);
        vertexBuffer.SetData<VertexPositionColor>(vertices);
    }

    protected override void UnloadContent() {}

    protected override void Update(GameTime gameTime)
    {
        if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            this.Exit();

        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);
        GraphicsDevice.SetVertexBuffer(vertexBuffer);

        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
        {
            pass.Apply();
            GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 1);
        }

        base.Draw(gameTime);
    }
}
公共类MyGame:Microsoft.Xna.Framework.Game
{
图形管理器图形;
顶点缓冲区顶点缓冲区;
VertexPositionColor[]顶点;
基本效应;
公共游戏
{
graphics=新的GraphicsDeviceManager(此);
Content.RootDirectory=“Content”;
targetExpressedTime=时间跨度(333);
InactiveSleepTime=时间跨度(从秒开始)(1);
}
受保护的覆盖无效初始化()
{
base.Initialize();
}
受保护的覆盖void LoadContent()
{
效果=新的基本效果(图形设备);
effect.VertexColorEnabled=真;
顶点=新顶点曝光颜色[]
{
新的顶点曝光颜色(新矢量3(-0.8F,-0.8F,0),颜色为黑色),
新的顶点曝光颜色(新矢量3(-0.8F,0.8F,0),颜色为黑色),
新的顶点曝光颜色(新矢量3(0.8F,-0.8F,0),颜色为黑色),
//新VertexPositionColor(新矢量3(0.8F,0.8F,0),颜色为黑色),
};
vertexBuffer=新的vertexBuffer(GraphicsDevice、VertexExpositionColor.VertexDeclaration、Vertex.Length、BufferUsage.WriteOnly);
SetData(顶点);
}
受保护的覆盖无效UnloadContent(){}
受保护覆盖无效更新(游戏时间游戏时间)
{
if(GamePad.GetState(PlayerIndex.One).Buttons.Back==ButtonState.Pressed)
这是Exit();
更新(游戏时间);
}
受保护覆盖无效绘制(游戏时间游戏时间)
{
图形设备。清晰(颜色:矢车菊蓝);
GraphicsDevice.SetVertexBuffer(vertexBuffer);
foreach(EffectPass-in-effect.currentTechnology.passs)
{
pass.Apply();
GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList,0,1);
}
基础。抽签(游戏时间);
}
}
我对XNA是相当陌生的。我做错什么了吗?

修复了它

我必须将GDM设置为全屏:

graphics.IsFullScreen = true;
或者显式设置后缓冲区的尺寸:

graphics.PreferredBackBufferWidth = width;
graphics.PreferredBackBufferWidth = height;