zoukankan      html  css  js  c++  java
  • Could not find a Direct3D device that has a Direct3D9level 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;

            
    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



    ------------------------------------------
    除非特别声明,文章均为原创,版权与博客园共有,转载请保留出处
    BUY ME COFFEE
  • 相关阅读:
    多线程之 Final变量 详解
    多线程之 Volatile 变量 详解
    并发安全问题之HashMap
    探索设计模式目录
    MYsql 锁详解 锁 与索引的关系
    JVM GC 相关
    sql 注入 及 in 注入
    00
    03
    02
  • 原文地址:https://www.cnblogs.com/kkun/p/1076533.html
Copyright © 2011-2022 走看看