您的位置:首页 > 其它

Could not find a Direct3D device that has a Direct3D9-level driver and supports pixel shader 1.1 or greater.终极解决方法

2008-02-21 15:15 399 查看
今天想试试XNA2.0好玩不好玩,结果上来就遇到难题,从网上DOWN下来XNA STUDIO后安装一切顺利,

之后安装了DX9,一切顺利,新建一个项目,运行,报错!

Could not find a Direct3D device that has a Direct3D9-level driver and supports pixel shader 1.1 or greater.

网上先查一查,结果中文资料好少,从一些网站了解到,是由于显示太老,给出的答案是:换显卡;

后来搜到一篇文章中提到,可以更改渲染方式,指定为软件模拟而不使用硬件,由于以前研究过一段时间DX,

感觉这应该是个解决的办法,当然最终还是依靠这个思路解决的,这篇文章并没有最终解决问题的代码,但是也帮了不少的忙,

先看最初的代码吧,

public class Game1 : Microsoft.Xna.Framework.Game {

static class Program {

public class Game1 : Microsoft.Xna.Framework.Game {

GraphicsDeviceManager graphics;

SpriteBatch spriteBatch;

public Game1() {

graphics = new GraphicsDeviceManager(this);

Content.RootDirectory = "Content";

graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);

}

void graphics_PreparingDeviceSettings(object sender, PreparingDeviceSettingsEventArgs e) {

e.GraphicsDeviceInformation.CreationOptions = CreateOptions.SoftwareVertexProcessing;

e.GraphicsDeviceInformation.DeviceType = DeviceType.Reference;

e.GraphicsDeviceInformation.PresentationParameters.MultiSampleType = MultiSampleType.None;

}
F5执行,直接提示我,

错误 2 当前上下文中不存在名称“CreateOptions” E:"WindowsGame1"WindowsGame1"Game1.cs 27 67 WindowsGame1

又从网上搜索,发现此方法已经被Removed,将其注释掉编译通过,

F5执行,提示

Could not find a Direct3D device that has a Direct3D9-level driver and supports pixel shader 1.1 or greater.

晕,这不又回到原点了么,

后来调试发现,此方法似乎并没有执行,为什么没有执行呢?我也没兴趣研究下去了,现在我只想运行出一个窗口来!

终于在一个国外的网站上发现了一个好东西,

ReferenceGraphicsDeviceManager

这个东西基本可以解决问题了,新建一个类ReferenceGraphicsDeviceManager,然后将GraphicsDeviceManager替换为ReferenceGraphicsDeviceManager,再次编译,报错,这个类的作者在写的时候XNA2.0应该还没出呢,于是这次都是一些版本上的错误,一一修改后,编译通过,F5运行...

通过,将此代码上传,希望对此有研究的高人表笑话,如果此文对您有些许帮助,荣幸之极,

本人在此过程中仅仅充当了一个finder角色,一些东西还停留在学习的阶段,共同进步吧!

/Files/kkun/ReferenceGraphicsDeviceManager.rar
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐