public CommonDeviceInterface(int adapter, OutputRequirements baseReq, OutputRequirements minReq,
                                     string base_path)
        {
            this.adapter = adapter;
            this.outCaps = OutputCaps.GetAdapterCaps(adapter, baseReq.DeviceType, baseReq.DeviceFormat);
            this.minSettings = OutputSettings.CreateFromRequirements(baseReq, outCaps, minReq);
            rzManager = new NuGenSVisualLib.Resources.ResourceManager();
            rzManager.AddSet(new NuGenSVisualLib.Resources.ResourceSet(GlobalResources));

            log = new DirectFileLog(base_path + "general.log");

            rzLoader = new RzLoader();
            rzLoader.RegisterContentLoader(new ImageContentLoader());
        }
Пример #2
0
        protected virtual void InitializeEnvironment(CommonDeviceInterface cdi)
        {
            // Get device settings
            if (outCaps == null)
            {
                outCaps = OutputCaps.GetDefaultAdapterCaps(outReqs);
            }
            outSettings = OutputSettings.CreateFromRequirements(outReqs, outCaps, outMinReqs);

            // Set up the presentation parameters
            presentParams.Windowed               = outReqs.Windowed;
            presentParams.SwapEffect             = SwapEffect.Discard;
            presentParams.AutoDepthStencilFormat = outSettings.DepthFormat;
            presentParams.EnableAutoDepthStencil = (outSettings.DepthFormat != DepthFormat.Unknown);

            CreateDevice();

            devIf = new DeviceInterface(device, cdi);
        }
Пример #3
0
        public MoleculeSchemeDlg(HashTableSettings settings, OutputCaps outCaps, Device device, CompleteOutputDescription coDesc)
        {
            InitializeComponent();

            currentEffects = new List <Effect>();

            this.settings = settings;

            LoadLocalResources();

            this.refDevice = device;
            this.outCaps   = outCaps;
            this.refcoDesc = coDesc;
            this.coDesc    = new CompleteOutputDescription(coDesc);

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenSVisualLib.LightingPresets.config"))
            {
                LoadLightingPresets(stream);
            }

            SetupLightingPreview();
            SetupEffectPreview();

            schemePreviewControl.OnNewPreview += new EventHandler(schemePreviewControl_OnNewPreview);
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenSVisualLib.MoleculeSchemes.config"))
            {
                if (stream != null)
                {
                    XmlDocument xml = new XmlDocument();
                    xml.Load(stream);

                    LoadSchemes(xml);
                    LoadEffects(xml);
                    LoadMaterials(xml);
                }
            }

            previewReady = true;

            updateThread = new Thread(this.UpdatePreviewsProcess);
            updateThread.Start();
        }
Пример #4
0
        public RenderingContext3DDX9(Control targetRenderArea, OutputRequirements oRequirements,
                                     OutputRequirements oMinReqs, CommonDeviceInterface cdi)
        {
            isDeviceLost = false;
            isActive     = false;
            hasFocus     = false;

            this.targetRenderArea = targetRenderArea;
            outReqs    = oRequirements;
            outMinReqs = oMinReqs;
            log        = cdi.GeneralLog;

            presentParams = new PresentParameters();
            outCaps       = cdi.DeviceCaps;

            layers = new LayerStack();

            InitializeEnvironment(cdi);

            view3D = new RenderingView3DPer(Matrix.Identity, Matrix.Identity);
        }
        public RenderingContext3DDX9(Control targetRenderArea, OutputRequirements oRequirements,
                                     OutputRequirements oMinReqs, CommonDeviceInterface cdi)
        {
            isDeviceLost = false;
            isActive = false;
            hasFocus = false;

            this.targetRenderArea = targetRenderArea;
            outReqs = oRequirements;
            outMinReqs = oMinReqs;
            log = cdi.GeneralLog;

            presentParams = new PresentParameters();
            outCaps = cdi.DeviceCaps;

            layers = new LayerStack();

            InitializeEnvironment(cdi);

            view3D = new RenderingView3DPer(Matrix.Identity, Matrix.Identity);
        }
Пример #6
0
        public static OutputSettings CreateFromRequirements(OutputRequirements requirements, OutputCaps caps,
                                                            OutputRequirements fallbacks)
        {
            if (caps == null)
                caps = OutputCaps.GetDefaultAdapterCaps(requirements);

            OutputSettings settings = new OutputSettings();
            settings.adapter = caps.Adapter;

            Type type = typeof(OutputSettings);

            OutputCaps.OutputCapsCompatibility reqComp = caps.CheckCompatibility(requirements);
            OutputCaps.OutputCapsCompatibility fallbackComp = caps.CheckCompatibility(fallbacks);

            // check reqs against caps
            if (reqComp.SupportDeviceType)
                settings.devType = requirements.DeviceType;
            else if (fallbackComp.SupportDeviceType)
                settings.devType = fallbacks.DeviceType;
            else
                throw new OutputSettingsException(type.GetProperty("DeviceType"),
                                                  requirements.DeviceType, null);

            if (reqComp.SupportDeviceFormat)
                settings.devFormat = requirements.DeviceFormat;
            else if (fallbackComp.SupportDeviceFormat)
                settings.devFormat = fallbacks.DeviceFormat;
            else
                throw new OutputSettingsException(type.GetProperty("DeviceFormat"),
                                                  requirements.DeviceFormat, null);

            if (reqComp.SupportDepthFormat)
                settings.depthFormat = requirements.DepthFormat;
            else if (fallbackComp.SupportDepthFormat)
                settings.depthFormat = fallbacks.DepthFormat;
            else
                throw new OutputSettingsException(type.GetProperty("DepthFormat"),
                                                  requirements.DepthFormat, null);

            if (caps.HardwareTnL && requirements.HardwareTnL)
                settings.createFlags = CreateFlags.HardwareVertexProcessing;
            else if (!requirements.HardwareTnL)
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            else if (!fallbacks.HardwareTnL)
                settings.createFlags = CreateFlags.SoftwareVertexProcessing;
            else
                throw new OutputSettingsException(type.GetProperty("CreateFlags"),
                                                  requirements.HardwareTnL, null);

            if (requirements.AntiAliasing <= caps.AntiAliasing.MaxSupported)
                settings.antiAliasing = requirements.AntiAliasing;
            else if (fallbacks.AntiAliasing <= caps.AntiAliasing.MaxSupported)
                settings.antiAliasing = fallbacks.AntiAliasing;
            else
                throw new OutputSettingsException(type.GetProperty("AntiAliasing"),
                                                  requirements.AntiAliasing, caps.AntiAliasing.MaxSupported);

            return settings;
        }
Пример #7
0
        public MoleculeSchemeDlg(HashTableSettings settings, OutputCaps outCaps, Device device, CompleteOutputDescription coDesc)
        {
            InitializeComponent();

            currentEffects = new List<Effect>();

            this.settings = settings;

            LoadLocalResources();

            this.refDevice = device;
            this.outCaps = outCaps;
            this.refcoDesc = coDesc;
            this.coDesc = new CompleteOutputDescription(coDesc);

            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenSVisualLib.LightingPresets.config"))
            {
                LoadLightingPresets(stream);
            }
            
            SetupLightingPreview();
            SetupEffectPreview();

            schemePreviewControl.OnNewPreview += new EventHandler(schemePreviewControl_OnNewPreview);
            using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("NuGenSVisualLib.MoleculeSchemes.config"))
            {
                if (stream != null)
                {
                    XmlDocument xml = new XmlDocument();
                    xml.Load(stream);

                    LoadSchemes(xml);
                    LoadEffects(xml);
                    LoadMaterials(xml);
                }
            }

            previewReady = true;

            updateThread = new Thread(this.UpdatePreviewsProcess);
            updateThread.Start();
        }
        protected virtual void InitializeEnvironment(CommonDeviceInterface cdi)
        {
            // Get device settings
            if (outCaps == null)
                outCaps = OutputCaps.GetDefaultAdapterCaps(outReqs);
            outSettings = OutputSettings.CreateFromRequirements(outReqs, outCaps, outMinReqs);

            // Set up the presentation parameters
            presentParams.Windowed = outReqs.Windowed;
            presentParams.SwapEffect = SwapEffect.Discard;
            presentParams.AutoDepthStencilFormat = outSettings.DepthFormat;
            presentParams.EnableAutoDepthStencil = (outSettings.DepthFormat != DepthFormat.Unknown);

            CreateDevice();

            devIf = new DeviceInterface(device, cdi);
        }