Could not find a Direct3D device that has a Direct3D9-level driver and supports pixel shader 1.1 or greater.终极解决方法
今天想试试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 {
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
![](/Images/OutliningIndicators/InBlock.gif)
public Game1() {
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
}
这里只贴出了部分代码,就是构造一个Game1,然后执行
static class Program {
/// <summary>
/// The main entry point for the application.
/// </summary>
static void Main(string[] args) {
using (Game1 game = new Game1()) {
game.Run();
}
}
然后就报错了,如题目描述;
为了使用软件渲染,将代码修改如下
public class Game1 : Microsoft.Xna.Framework.Game {
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
![](/Images/OutliningIndicators/InBlock.gif)
public Game1() {
graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "Content";
graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);
}
![](/Images/OutliningIndicators/InBlock.gif)
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.
晕,这不又回到原点了么,
后来调试发现,此方法似乎并没有执行,为什么没有执行呢?我也没兴趣研究下去了,现在我只想运行出一个窗口来!
终于在一个国外的网站上发现了一个好东西,
通过,将此代码上传,希望对此有研究的高人表笑话,如果此文对您有些许帮助,荣幸之极,
本人在此过程中仅仅充当了一个finder角色,一些东西还停留在学习的阶段,共同进步吧!
/Files/kkun/ReferenceGraphicsDeviceManager.rar
之后安装了DX9,一切顺利,新建一个项目,运行,报错!
Could not find a Direct3D device that has a Direct3D9-level driver and supports pixel shader 1.1 or greater.
网上先查一查,结果中文资料好少,从一些网站了解到,是由于显示太老,给出的答案是:换显卡;
后来搜到一篇文章中提到,可以更改渲染方式,指定为软件模拟而不使用硬件,由于以前研究过一段时间DX,
感觉这应该是个解决的办法,当然最终还是依靠这个思路解决的,这篇文章并没有最终解决问题的代码,但是也帮了不少的忙,
先看最初的代码吧,
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
这里只贴出了部分代码,就是构造一个Game1,然后执行
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
为了使用软件渲染,将代码修改如下
![](/Images/OutliningIndicators/ExpandedBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockEnd.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/InBlock.gif)
![](/Images/OutliningIndicators/ExpandedBlockEnd.gif)
错误 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
------------------------------------------
除非特别声明,文章均为原创,版权与博客园共有,转载请保留出处
BUY ME COFFEE
![](https://images.cnblogs.com/cnblogs_com/kkun/212569/o_200616035329WechatIMG237.png)
![](https://images.cnblogs.com/cnblogs_com/kkun/212569/o_200616035334WechatIMG238.jpeg)