XNA使用VMWare实现配置文件 - 顶点缓冲区不起作用?

时间:2010-12-29 05:48:22

标签: c# xna directx

使用Reach配置文件在VMWare Fusion主机操作系统Mac OSX中运行XNA应用程序,VM是Windows XP SP 3(我的双启动操作系统)。在带有NVidia 320M显卡的MacBook Pro上运行

当我本地启动到XP时,我的代码可以工作。代码是绘制使用顶点缓冲区

设置的立方体

当另一位朋友在Windows 7上运行相同的代码时,它对他来说也很合适

当我在VM中运行我的代码时,它不起作用。我有一个在着色器程序中运行的广告牌sprite,这部分显示正常。我没有崩溃或错误,几何图形不会出现。我试过Debug和Release。这是非常基本的操作,所以我认为VMWare不是问题,但它是我的代码....

另外,如果我将DrawIndexedPrimitives切换为DrawUserIndexPrimitives(使用内存对象而不是顶点缓冲区),一切正常......一个可接受的解决方案是知道如何查询硬件以确定这是否有效这样我的代码就可以有条件地使用内存对象或顶点缓冲区。

我的初始代码:

  var vertexArray = verts.ToArray();
  var indexArray = indices.ToArray();

  indexBuffer = new IndexBuffer(GraphicsDevice, typeof(Int16), indexArray.Length, BufferUsage.WriteOnly);
  indexBuffer.SetData(indexArray);

  vertexBuffer = new VertexBuffer(GraphicsDevice, typeof(VertexPositionColor), vertexArray.Length,
    BufferUsage.WriteOnly);
  vertexBuffer.SetData(vertexArray);

我的抽奖代码:

 // problem isn't here, tried no cull
  GraphicsDevice.RasterizerState = RasterizerState.CullClockwise;
  GraphicsDevice.BlendState = BlendState.AlphaBlend;
  GraphicsDevice.DepthStencilState = new DepthStencilState() { DepthBufferEnable = true };
// Update View and Projection
  TileEffect.View = ((Game1)Game).Camera.View;
  TileEffect.Projection = ((Game1)Game).Camera.Projection;

  TileEffect.CurrentTechnique.Passes[0].Apply();

  GraphicsDevice.SetVertexBuffer(vertexBuffer);
  GraphicsDevice.Indices = indexBuffer;

  GraphicsDevice.DrawIndexedPrimitives(PrimitiveType.TriangleList, 0, 0, indices.Count, 0, indices.Count / 3);

对于LoadContent:

 TileEffect = new BasicEffect(GraphicsDevice)
  {
    World = Matrix.Identity,
    View = ((Game1)Game).Camera.View,
    Projection = ((Game1)Game).Camera.Projection,
    VertexColorEnabled = true
  };

2 个答案:

答案 0 :(得分:0)

你必须意识到在MAC上托管的VM中运行它不是完全支持的方案。我想可能会有一些状态,你需要设置一些状态才能使它与vmware一起工作,但对我来说并不是很明显......你是对的,这是一个相当基本的操作: - /

答案 1 :(得分:0)

从指标切换解决了这个问题,虽然我仍然不知道为什么会这样......