【发布时间】:2011-10-30 01:12:22
【问题描述】:
我希望使用 XNA 框架开发一些简单的 2D 游戏。我特别希望能够使用我的上网本在旅途中开发和调试这些游戏的一部分。不幸的是,我上网本的 GPU 不支持 XNA 所需的 Shader Model 2.0。
沮丧,我去谷歌寻找替代品。我从“Riemers XNA Tutorial”中发现了一种替代方法。下面的代码应该强制 XNA 严格通过计算机的 CPU 运行,从而允许我的上网本运行非常慢的 XNA 版本。
if (GraphicsAdapter.DefaultAdapter.GetCapabilities(DeviceType.Hardware).MaxPixelShaderProfile < ShaderProfile.PS_2_0)
graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs> (SetToReference);
}
void SetToReference(object sender, PreparingDeviceSettingsEventArgs eventargs)
{
eventargs.GraphicsDeviceInformation.CreationOptions = CreateOptions.SoftwareVertexProcessing;
eventargs.GraphicsDeviceInformation.DeviceType = DeviceType.Reference;
eventargs.GraphicsDeviceInformation.PresentationParameters.MultiSampleType = MultiSampleType.None;
}
上面的代码应该放在默认 XNA 项目的 Game1 方法中。
问题是当我尝试运行这个新项目时,我收到以下两个错误:
Error 1 'XNAReferenceDevice.Game1.LoadGraphicsContent(bool)': no suitable method found to override c:\users\richard\documents\visual studio 2010\Projects\WindowsGame1\WindowsGame1\WindowsGame1\Game1.cs 39 33 WindowsGame1
Error 2 'XNAReferenceDevice.Game1.UnloadGraphicsContent(bool)': no suitable method found to override c:\users\richard\documents\visual studio 2010\Projects\WindowsGame1\WindowsGame1\WindowsGame1\Game1.cs 46 33 WindowsGame1
这两个错误还会导致蓝色“波浪”线出现在 LoadGraphicsContent 和 UnloadGraphicsContent 方法下方。
如果有人可以帮助我解决这个问题或为我指明不同的方向,那就太好了。
提前致谢!
【问题讨论】: