在低端显卡上运行 XNA
我希望使用 XNA 框架来开发一些简单的 2D 游戏。我特别希望能够在旅途中使用我的上网本开发和调试这些游戏的部分内容。不幸的是,我的上网本的 GPU 不支持 XNA 所需的 Shader Model 2.0。
沮丧之余,我去谷歌寻找替代方案。我从“Riemers XNA 教程”中发现了一种替代方案。以下代码应该强制 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 方法下方出现蓝色“波浪线”。
如果有人可以帮助我解决这个问题或为我指明不同的方向,那就太好了。
提前致谢!
I am looking to work with the XNA framework to develop some simple 2D games. I especially would like to be able to develop and debug portions of these games while on-the-go with my netbook. Unfortunately, my netbook's GPU does not support the Shader Model 2.0 that is required by XNA.
Frustrated, I went to Google looking for alternatives. I came across one alternative from "Riemers XNA Tutorial". The following code is supposed to force XNA to run strictly through a computer's CPU, thus allowing my netbook to run an incredibly slow version of 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;
}
The above code is supposed to be placed in the Game1 method of a default XNA project.
The problem is that when I try to run this new project I receive the following two errors:
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
These two errors also cause blue 'squiggly' lines to appear beneath the LoadGraphicsContent and UnloadGraphicsContent methods.
If anyone could help me solve this problem or point me in a different direction, that would be great.
Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
新版本的 XNA 失去了与过去的一些兼容性。
您可能正在使用比 Riemers 教程更新版本的框架和 XNA。
但是,请考虑新的 XNA 4.0 支持最低像素着色器 2.0!这意味着您无法在仅具有像素着色器 1.1 或速度太慢的像素着色器 2.0 的低端计算机上运行它。
以前的版本 XNA 3.1 支持最低像素着色器 1.1,您可以尝试使用 Visual Studio 2008 Express 切换回该版本。
抱歉,由于 XNA 需要好的机器,我认为您应该找到一台更好的机器,也可以用于制作 2D 图形。
然而,编译器错误与像素着色器无关,但可能与 XNA 和 C# 版本有关。
New versions of XNA lost some compatibility with the past.
Probably you are using a newer version of the framework and of XNA than Riemers tutorials.
However, consider that new XNA 4.0 supports minimum pixel shader 2.0! It means you cannot run it on low end machines with only pixel shader 1.1 or with a too slow pixel shader 2.0.
Previous version, XNA 3.1, supports minimum pixel shader 1.1, you can try to switch back to that using visual studio 2008 express.
Sorry but since XNA requires good machines I think you should find a better machine, also for doing 2D graphics.
The compiler error however is not related to pixel shader but is related probably to XNA and C# versions.