Summary description for D3DTextureManager.
Inheritance: Axiom.Core.TextureManager
        public override RenderWindow CreateRenderWindow(string name, int width, int height, bool isFullscreen, params object[] miscParams)
        {
            // Check we're not creating a secondary window when the primary
            // was fullscreen
            if (primaryWindow != null && primaryWindow.IsFullScreen) {
                throw new Exception("Cannot create secondary windows when the primary is full screen");
            } else if (primaryWindow != null && isFullscreen) {
                throw new Exception("Cannot create full screen secondary windows");
            }

            // Make sure we don't already have a render target of the
            // same name as the one supplied
            foreach (RenderTarget x in renderTargets) {
                if (x.Name == name)
                    throw new Exception("A render target of the same name '" + name +
                                        "' already exists.  You cannot create a new window with this name.");
            }

            RenderWindow win = new D3DRenderWindow(activeD3DDriver, primaryWindow != null);
            // create the window
            win.Create(name, width, height, isFullscreen, miscParams);
            // add the new render target
            AttachRenderTarget(win);

            // If this is the first window, get the D3D device and create the texture manager
            if (primaryWindow == null) {
                primaryWindow = (D3DRenderWindow)win;
                device = (Device)win.GetCustomAttribute("D3DDEVICE");

                // by creating our texture manager, singleton TextureManager will hold our implementation
                textureManager = new D3DTextureManager(device);

                // by creating our Gpu program manager, singleton GpuProgramManager will hold our implementation
                gpuProgramMgr = new D3DGpuProgramManager(device);

                // intializes the HardwareBufferManager singleton
                hardwareBufferManager = new D3DHardwareBufferManager(device);

                // Initialise the capabilities structures
                InitCapabilities();

                CreateAndApplyCache();
            } else {
                secondaryWindows.Add(win);
            }
            return win;
        }
        public override RenderWindow Initialize(bool autoCreateWindow, string windowTitle)
        {
            LogManager.Instance.Write("[D3D9] : Subsystem Initializing");

            // Axiom specific
            WindowEventMonitor.Instance.MessagePump = Win32MessageHandling.MessagePump;

            // Init using current settings
            _activeD3DDriver = D3DHelper.GetDriverInfo(_pD3D)[ConfigOptions["Rendering Device"].Value];
            if (_activeD3DDriver == null)
                throw new ArgumentException("Problems finding requested Direct3D driver!");


            driverVersion.Major = _activeD3DDriver.AdapterIdentifier.DriverVersion.Major;
            driverVersion.Minor = _activeD3DDriver.AdapterIdentifier.DriverVersion.Minor;
            driverVersion.Release = _activeD3DDriver.AdapterIdentifier.DriverVersion.MajorRevision;
            driverVersion.Build = _activeD3DDriver.AdapterIdentifier.DriverVersion.MinorRevision;

            // Create the device manager.
            _deviceManager = new D3D9DeviceManager();

            // Create the texture manager for use by others        
            textureManager = new D3DTextureManager();

            // Also create hardware buffer manager
            _hardwareBufferManager = new D3DHardwareBufferManager();

            // Create the GPU program manager    
            _gpuProgramManager = new D3DGpuProgramManager();

            _hlslProgramFactory = new HLSLProgramFactory();

            RenderWindow renderWindow = null;

            if (autoCreateWindow)
            {
                var fullScreen = (ConfigOptions["Full Screen"].Value == "Yes");

                var optVm = ConfigOptions["Video Mode"];
                var vm = optVm.Value;
                var width = int.Parse(vm.Substring(0, vm.IndexOf("x")));
                var height = int.Parse(vm.Substring(vm.IndexOf("x") + 1, vm.IndexOf("@") - (vm.IndexOf("x") + 1)));
                var bpp = int.Parse(vm.Substring(vm.IndexOf("@") + 1, vm.IndexOf("-") - (vm.IndexOf("@") + 1)));

                // sRGB window option
                ConfigOption opt;
                var hwGamma = ConfigOptions.TryGetValue("sRGB Gamma Conversion", out opt) && (opt.Value == "Yes");

                var miscParams = new NamedParameterList();
                miscParams.Add("title", windowTitle); // Axiom only?
                miscParams.Add("colorDepth", bpp);
                miscParams.Add("FSAA", _fsaaSamples);
                miscParams.Add("FSAAHint", _fsaaHint);
                miscParams.Add("vsync", vSync);
                miscParams.Add("vsyncInterval", vSyncInterval);
                miscParams.Add("useNVPerfHUD", _useNVPerfHUD);
                miscParams.Add("gamma", hwGamma);
                miscParams.Add("monitorIndex", _activeD3DDriver.AdapterNumber);

                // create the render window
                renderWindow = CreateRenderWindow("Main Window", width, height, fullScreen, miscParams);

                // If we have 16bit depth buffer enable w-buffering.
                Debug.Assert(renderWindow != null);
                wBuffer = (renderWindow.ColorDepth == 16);
            }

            LogManager.Instance.Write("***************************************");
            LogManager.Instance.Write("*** D3D9 : Subsystem Initialized OK ***");
            LogManager.Instance.Write("***************************************");

            // call superclass method
            base.Initialize( autoCreateWindow, windowTitle );

            // Configure SlimDX
            SlimDX.Configuration.ThrowOnError = true;
            SlimDX.Configuration.AddResultWatch(ResultCode.DeviceLost, ResultWatchFlags.AlwaysIgnore);
            SlimDX.Configuration.AddResultWatch(ResultCode.WasStillDrawing, ResultWatchFlags.AlwaysIgnore);

#if DEBUG
            SlimDX.Configuration.DetectDoubleDispose = false;
            SlimDX.Configuration.EnableObjectTracking = true;
#else
            SlimDX.Configuration.DetectDoubleDispose = false;
            SlimDX.Configuration.EnableObjectTracking = false;
#endif

            return renderWindow;
        }
        private D3D.Device InitDevice(bool isFullscreen, bool depthBuffer, int width, int height, int colorDepth, Control target)
        {
            if(device != null) {
                return device;
            }

            // we don't care about event handlers
            Device.IsUsingEventHandlers = false;

            D3D.Device newDevice;

            PresentParameters presentParams = CreatePresentationParams(isFullscreen, depthBuffer, width, height, colorDepth);

            // create the D3D Device, trying for the best vertex support first, and settling for less if necessary
            try {
                // hardware vertex processing
                int adapterNum = 0;
                DeviceType type = DeviceType.Hardware;
            #if DEBUG
                for ( int i = 0; i < Manager.Adapters.Count; i++ ) {
                    if (Manager.Adapters[i].Information.Description == "NVIDIA NVPerfHUD")
                    {
                        adapterNum = i;
                        type = DeviceType.Reference;
                    }
                }
            #endif
                // use this with NVPerfHUD
                newDevice = new D3D.Device(adapterNum, type, target, CreateFlags.HardwareVertexProcessing, presentParams);
                // newDevice = new D3D.Device(0, DeviceType.Hardware, target, CreateFlags.HardwareVertexProcessing, presentParams);
            }
            catch(Exception) {
                try {
                    // doh, how bout mixed vertex processing
                    newDevice = new D3D.Device(0, DeviceType.Hardware, target, CreateFlags.MixedVertexProcessing, presentParams);
                }
                catch(Exception) {
                    // what the...ok, how bout software vertex procssing.  if this fails, then I don't even know how they are seeing
                    // anything at all since they obviously don't have a video card installed
                    newDevice = new D3D.Device(0, DeviceType.Hardware, target, CreateFlags.SoftwareVertexProcessing, presentParams);
                }
            }

            // CMH - end

            // save the device capabilites
            d3dCaps = newDevice.DeviceCaps;

            // by creating our texture manager, singleton TextureManager will hold our implementation
            textureMgr = new D3DTextureManager(newDevice);

            // by creating our Gpu program manager, singleton GpuProgramManager will hold our implementation
            gpuProgramMgr = new D3DGpuProgramManager(newDevice);

            // intializes the HardwareBufferManager singleton
            hardwareBufferManager = new D3DHardwareBufferManager(newDevice);

            return newDevice;
        }