VMWare 的 XNA Reach 配置文件 - 顶点缓冲区不起作用?

发布于 2024-10-09 09:32:10 字数 1857 浏览 0 评论 0原文

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

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

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

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

Running XNA app, using Reach profile, in VMWare Fusion host OS Mac OSX, VM is Windows XP SP 3 (my dual-boot OS). Running on MacBook Pro w/NVidia 320M graphics card

When I am booted in to XP natively, my code works. The code is drawing cubes that are set up using vertex buffers

When another friend runs this same code on Windows 7, it also works for him just fine

When I am running my code in the VM, it doesn't work. I have billboarding sprites running in a shader program and this part displays fine. I get no crashing or errors, the geometry just doesn't appear. I tried Debug and Release. This is very basic operation so I'm thinking VMWare isn't the problem, but it's my code....

Also, if I switch my DrawIndexedPrimitives to DrawUserIndexPrimitives (using memory objects instead of vertex buffers) everything works fine... An acceptable solution would be to know how I can query the hardware to figure out if this will work or not work so that my code can conditionally use either memory objects or vertex buffers.

My init code:

  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);

My Draw code:

 // 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);

For LoadContent:

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

°如果伤别离去 2024-10-16 09:32:10

您必须意识到,在 MAC 上托管的虚拟机中运行此程序并不是完全受支持的方案。我想你必须设置一些状态才能使其与 vmware 一起工作,但它对我来说并不是立即显而易见的......你是对的,这是一个相当基本的操作:-/

you have to realize that running this in a VM hosted on MAC is not a fully supported scenario. I suppose there might be some quirk with some state that you have to set in order for it to work with vmware, but it's not immediately apparent to me ... you're right, it is a fairly basic operation :-/

殤城〤 2024-10-16 09:32:10

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

Switching from indicies resolved the issue although I still don't know why it would..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文