0

嗨,我试图让我的代码工作,它在 xna 中绘制一个原始立方体。

我不断收到错误

错误 1 ​​方法 'Microsoft.Xna.Framework.Graphics.GraphicsDevice.DrawUserPrimitives(Microsoft.Xna.Framework.Graphics.PrimitiveType, T[], int, int)' 的类型参数无法从用法中推断出来。尝试明确指定类型参数。

public void RenderShape(GraphicsDevice device, Effect effect)
    {
        BuildShape();

        foreach (EffectPass pass in effect.CurrentTechnique.Passes)
        {
            effect.Parameters["xTexture"].SetValue(topTexture);
            pass.Apply();
            device.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, shapeVertices[2], 0, 2);

            effect.Parameters["xTexture"].SetValue(bottomTexture);
            pass.Apply();
            device.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, shapeVertices[3], 0, 2);

            effect.Parameters["xTexture"].SetValue(frontTexture);
            pass.Apply();
            device.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, shapeVertices[0], 0, 2);

            effect.Parameters["xTexture"].SetValue(backTexture);
            pass.Apply();
            device.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, shapeVertices[1], 0, 2);

            effect.Parameters["xTexture"].SetValue(leftTexture);
            pass.Apply();
            device.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, shapeVertices[4], 0, 2);

            effect.Parameters["xTexture"].SetValue(rightTexture);
            pass.Apply();
            device.DrawUserPrimitives<VertexPositionNormalTexture>(PrimitiveType.TriangleList, shapeVertices[5], 0, 2);
        }

    }

我认为添加是明确定义类型....但显然不是。

4

0 回答 0