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

原文地址:http://www.cnblogs.com/kkun/archive/2008/02/21/1076533.html

今天想试试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;

        
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;

        
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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值