【发布时间】: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
};
【问题讨论】: