【问题标题】:XNA Reach profile with VMWare - Vertex Buffers not working?使用 VMWare 的 XNA Reach 配置文件 - 顶点缓冲区不起作用?
【发布时间】:2010-12-29 05:48:21
【问题描述】:

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

当我在本地启动到 XP 时,我的代码可以正常工作。该代码正在绘制使用顶点缓冲区设置的立方体

当另一个朋友在 Windows 7 上运行相同的代码时,它也可以正常工作

当我在 VM 中运行我的代码时,它不起作用。我在着色器程序中运行了广告牌精灵,这部分显示正常。我没有崩溃或错误,只是没有出现几何。我尝试了调试和发布。这是非常基本的操作,所以我认为 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);

对于加载内容:

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

【问题讨论】:

    标签: c# xna directx


    【解决方案1】:

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

    【讨论】:

    • 嗯,这是一种受支持的场景。我意识到它增加了一层复杂性/问题根源,但 VMWare 不是无名软件,它正式支持 DX 9.0c 和着色器模型 3,可以玩商业 3d 游戏和许多其他东西。这就是为什么我开始认为是我
    • 只是一个想法...您是否考虑过使用 Parallels 或 VirtualBox?
    • 对,但这种支持将来自 VMWare 及其支持渠道 :-)
    【解决方案2】:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-07-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多