示例#1
0
        protected void InitNativeCreatedWindow(NamedParameterList miscParams)
        {
            LogManager.Instance.Write("\tInitNativeCreateWindow called");

            if (miscParams != null)
            {
                if (miscParams.ContainsKey("externalWindowInfo"))
                {
                    this.windowInfo = (IWindowInfo)miscParams["externalWindowInfo"];
                }
                if (miscParams.ContainsKey("externalGLContext"))
                {
                    var value = miscParams["externalGLContext"];
                    if (value is IGraphicsContext)
                    {
                        this.context = new AndroidContext(this.glSupport, (value as IGraphicsContext), this.windowInfo);
                    }
                    else
                    {
                        var ex = new InvalidCastException();
                        throw new AxiomException("externalGLContext must be of type IGraphicsContext", ex);
                    }
                }
            }
        }
示例#2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sceneMgr"></param>
        private void SetupBody(SceneManager sceneMgr)
        {
            // create main model
            this.bodyNode = sceneMgr.RootSceneNode.CreateChildSceneNode(Vector3.UnitY * CharHeight);
            this.bodyEnt  = sceneMgr.CreateEntity("SinbadBody", "Sinbad.mesh");
            this.bodyNode.AttachObject(this.bodyEnt);

            // create swords and attach to sheath
            this.sword1 = sceneMgr.CreateEntity("SinbadSword1", "Sword.mesh");
            this.sword2 = sceneMgr.CreateEntity("SinbadSword2", "Sword.mesh");
            this.bodyEnt.AttachObjectToBone("Sheath.L", this.sword1);
            this.bodyEnt.AttachObjectToBone("Sheath.R", this.sword2);

            // create a couple of ribbon trails for the swords, just for fun
            var paras = new NamedParameterList();

            paras["numberOfChains"]      = "2";
            paras["maxElements"]         = "80";
            this.swordTrail              = (RibbonTrail)sceneMgr.CreateMovableObject("SinbadRibbon", "RibbonTrail", paras);
            this.swordTrail.MaterialName = "Examples/LightRibbonTrail";
            this.swordTrail.TrailLength  = 20;
            this.swordTrail.IsVisible    = false;
            sceneMgr.RootSceneNode.AttachObject(this.swordTrail);

            for (int i = 0; i < 2; i++)
            {
                this.swordTrail.SetInitialColor(i, new ColorEx(1, 0.8f, 0));
                this.swordTrail.SetColorChange(i, new ColorEx(0.75f, 0.25f, 0.25f, 0.25f));
                this.swordTrail.SetWidthChange(i, 1);
                this.swordTrail.SetInitialWidth(i, 0.5f);
            }

            this.keyDirection     = Vector3.Zero;
            this.verticalVelocity = 0;
        }
示例#3
0
        protected override MovableObject _createInstance(string name, NamedParameterList param)
        {
            // must have mesh parameter
            string caption  = null;
            string fontName = null;

            if (param != null)
            {
                if (param.ContainsKey("caption"))
                {
                    caption = (string)param["caption"];
                }
                if (param.ContainsKey("fontName"))
                {
                    fontName = (string)param["fontName"];
                }
            }
            if (caption == null)
            {
                throw new AxiomException("'caption' parameter required when constructing MovableText.");
            }
            if (fontName == null)
            {
                throw new AxiomException("'fontName' parameter required when constructing MovableText.");
            }

            var text = new MovableText(name, caption, fontName);

            text.MovableType = Type;
            return(text);
        }
示例#4
0
        public void InitializeSystem()
        {
            configManager              = new Config.DefaultConfigurationManager();
            root                       = new Root(configManager.LogFilename);
            root.FrameRenderingQueued += RootFrameRenderingQueued;

            // Load Config.
            configManager.RestoreConfiguration(root);

            // Render System.
            if (root.RenderSystem == null)
            {
                renderSystem = root.RenderSystem = root.RenderSystems.First().Value;
            }
            else
            {
                renderSystem = root.RenderSystem;
            }

            // Render Window.
            Root.Instance.Initialize(false);
            var parameterList = new NamedParameterList
            {
                { "vsync", "true" },
                { "Anti aliasing", "Level 2" },
                { "FSAA", 1 },
                { "colorDepth", 32 },
                { "border", "fixed" }
            };

            window = Root.Instance.CreateRenderWindow("EvolutionWarWindow", Constants.Width, Constants.Height, false, parameterList);
            WindowEventMonitor.Instance.RegisterListener(window, this);

            // Content.
            Constants.Load();
            ResourceGroupManager.Instance.AddResourceLocation("Meshes", "Folder", true);
            ResourceGroupManager.Instance.AddResourceLocation("Fonts", "Folder", true);
            ResourceGroupManager.Instance.InitializeAllResourceGroups();

            // Fonts.
            var font = FontManager.Instance.Create("Candara", ResourceGroupManager.DefaultResourceGroupName) as Font;

            if (font != null)
            {
                font.Type               = FontType.TrueType;
                font.Source             = "Candarab.ttf";
                font.TrueTypeSize       = 36;
                font.TrueTypeResolution = 96;
                font.AntialiasColor     = false;
                font.Load();
            }

            // Scene Manager.
            sceneManager = root.CreateSceneManager("DefaultSceneManager", "GameSMInstance");
            sceneManager.ClearScene();
        }
示例#5
0
        /// <summary>
        ///     Create a new instance of the object.
        /// </summary>
        /// <param name="name">
        ///     The name of the new object
        /// </param>
        /// <param name="manager">
        ///     The SceneManager instance that will be holding the instance once created.
        /// </param>
        /// <param name="param">
        ///     Name/value pair list of additional parameters required to construct the object
        ///     (defined per subtype).
        /// </param>
        /// <returns>A new MovableObject</returns>
        public MovableObject CreateInstance(string name, SceneManager manager, NamedParameterList param)
        {
            var m = _createInstance(name, param);

            m.Creator     = this;
            m.Manager     = manager;
            m.MovableType = Type;
            m.TypeFlags   = TypeFlag;
            return(m);
        }
		protected override void CreateWindow()
		{
			Root.Initialize( false, "Axiom Sample Browser" );
			var miscParams = new NamedParameterList();
			var width = 800;
			var height = 600;
			miscParams.Add( "externalWindowInfo", this.GlWindowInfo );
			miscParams.Add( "externalGLContext", GLGraphicsContext );
			this.RenderWindow = Root.CreateRenderWindow( "AndroidMainWindow", width, height, true, miscParams );
		}
示例#7
0
        protected override void CreateWindow()
        {
            Root.Initialize(false, "Axiom Sample Browser");
            var miscParams = new NamedParameterList();
            var width      = 800;
            var height     = 600;

            miscParams.Add("externalWindowInfo", this.GlWindowInfo);
            miscParams.Add("externalGLContext", GLGraphicsContext);
            this.RenderWindow = Root.CreateRenderWindow("AndroidMainWindow", width, height, true, miscParams);
        }
示例#8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="autoCreateWindow"></param>
        /// <param name="renderSystem"></param>
        /// <param name="windowTitle"></param>
        /// <returns></returns>
        public override RenderWindow CreateWindow(bool autoCreateWindow, GLRenderSystem renderSystem, string windowTitle)
        {
            RenderWindow autoWindow = null;

            if (autoCreateWindow)
            {
                int  width      = 800;
                int  height     = 600;
                int  bpp        = 32;
                bool fullScreen = false;

                ConfigOption optVM = ConfigOptions["Video Mode"];
                string       vm    = optVM.Value;
                int          pos   = vm.IndexOf('x');
                if (pos == -1)
                {
                    throw new Exception("Invalid Video Mode provided");
                }
                width  = int.Parse(vm.Substring(0, vm.IndexOf("x")));
                height = int.Parse(vm.Substring(vm.IndexOf("x") + 1));

                fullScreen = (ConfigOptions["Full Screen"].Value == "Yes");

                var          miscParams = new NamedParameterList();
                ConfigOption opt;

                opt = ConfigOptions["Color Depth"];
                if (opt != null && opt.Value != null && opt.Value.Length > 0)
                {
                    miscParams.Add("colorDepth", opt.Value);
                }

                opt = ConfigOptions["VSync"];
                if (opt != null && opt.Value != null && opt.Value.Length > 0)
                {
                    miscParams.Add("vsync", opt.Value);
                    //TODO : renderSystem.WaitForVerticalBlank = (bool)opt.Value;
                }

                opt = ConfigOptions["FSAA"];
                if (opt != null && opt.Value != null && opt.Value.Length > 0)
                {
                    miscParams.Add("fsaa", opt.Value);
                }

                miscParams.Add("title", windowTitle);

                // create the window with the default form as the target
                autoWindow = renderSystem.CreateRenderWindow(windowTitle, width, height, fullScreen, miscParams);
            }

            return(autoWindow);
        }
示例#9
0
		public bool Setup( IGraphicsContext glContext, int width, int height )
		{
			// instantiate the Root singleton
			engine = Root.Instance;

			// add event handlers for frame events
			engine.FrameStarted += OnFrameStarted;
			engine.FrameRenderingQueued += OnFrameRenderingQueued;
			engine.FrameEnded += OnFrameEnded;

			Root.Instance.Initialize( false, "Axiom Engine Demo Window" );

			NamedParameterList miscParams = new NamedParameterList();
			miscParams.Add( "externalWindowInfo", glContext );
			miscParams.Add( "externalWindow", true );
			window = Root.Instance.CreateRenderWindow( "Droid.Demo", width, height, true, miscParams );

			TechDemoListener rwl = new TechDemoListener( window );
			WindowEventMonitor.Instance.RegisterListener( window, rwl );

			SetupResources();

			ChooseSceneManager();
			CreateCamera();
			CreateViewports();

			this.viewport.BackgroundColor = ColorEx.SteelBlue;

			// set default mipmap level
			TextureManager.Instance.DefaultMipmapCount = 5;

			// Create any resource listeners (for loading screens)
			this.CreateResourceListener();
			// Load resources
			this.LoadResources();

			ShowDebugOverlay( true );

			//CreateGUI();


			//input = SetupInput();

			// call the overridden CreateScene method
			CreateScene();
			return true;
		}
示例#10
0
        protected virtual bool Setup()
        {
            // instantiate the Root singleton
            //engine = new Root( "EngineConfig.xml", "AxiomEngine.log" );
            engine = Root.Instance;

            // add event handlers for frame events
            engine.FrameStarted += new FrameEvent(OnFrameStarted);
            engine.FrameEnded   += new FrameEvent(OnFrameEnded);

            window = Root.Instance.Initialize(false, "Game Window");

            NamedParameterList windowParams = new NamedParameterList();

            windowParams.Add("externalWindowHandle", windowHandle);
            window = engine.CreateRenderWindow("Game Window", 1024, 768, false, windowParams);

            OnCreateWindow();

            GameWindowListener gwl = new GameWindowListener(window);

            WindowEventMonitor.Instance.RegisterListener(window, gwl);

            ResourceGroupManager.Instance.InitializeAllResourceGroups();

            ShowDebugOverlay(showDebugOverlay);

            ChooseSceneManager();
            CreateCamera();
            CreateViewports();

            // set default mipmap level
            TextureManager.Instance.DefaultMipmapCount = 5;

            // call the overridden CreateScene method
            CreateScene();

            // retreive and initialize the input system
            input = PlatformManager.Instance.CreateInputReader();
            input.Initialize(window, true, true, false, false);

            return(true);
        }
示例#11
0
		public override RenderWindow CreateWindow( bool autoCreateWindow, GLES2RenderSystem renderSystem, string windowTitle )
		{
			LogManager.Instance.Write( "\tGLSupport CreateWindow called" );

			RenderWindow window = null;
			if ( autoCreateWindow )
			{
				var miscParams = new NamedParameterList();
				bool fullscreen = true;
				int w = 800, h = 600;

				if ( Options.ContainsKey( "Display Frequency" ) )
				{
					miscParams.Add( "displayFrequency", Options[ "Display Frequency" ] );
				}
				window = renderSystem.CreateRenderWindow( windowTitle, w, h, fullscreen, miscParams );
			}

			return window;
		}
示例#12
0
        public override RenderWindow CreateWindow(bool autoCreateWindow, GLES2RenderSystem renderSystem, string windowTitle)
        {
            LogManager.Instance.Write("\tGLSupport CreateWindow called");

            RenderWindow window = null;

            if (autoCreateWindow)
            {
                var  miscParams = new NamedParameterList();
                bool fullscreen = true;
                int  w = 800, h = 600;

                if (Options.ContainsKey("Display Frequency"))
                {
                    miscParams.Add("displayFrequency", Options["Display Frequency"]);
                }
                window = renderSystem.CreateRenderWindow(windowTitle, w, h, fullscreen, miscParams);
            }

            return(window);
        }
示例#13
0
        protected override MovableObject _createInstance(string name, NamedParameterList param)
        {
            var maxElements      = 20;
            var numberOfChains   = 1;
            var useTextureCoords = true;
            var useVertexColors  = true;
            var isDynamic        = true;

            // optional parameters
            if (param != null)
            {
                if (param.ContainsKey("maxElements"))
                {
                    maxElements = Convert.ToInt32(param["maxElements"]);
                }
                if (param.ContainsKey("numberOfChains"))
                {
                    numberOfChains = Convert.ToInt32(param["numberOfChains"]);
                }
                if (param.ContainsKey("useTextureCoords"))
                {
                    useTextureCoords = Convert.ToBoolean(param["useTextureCoords"]);
                }
                if (param.ContainsKey("useVertexColours"))
                {
                    useVertexColors = Convert.ToBoolean(param["useVertexColours"]);
                }
                else if (param.ContainsKey("useVertexColors"))
                {
                    useVertexColors = Convert.ToBoolean(param["useVertexColors"]);
                }
                if (param.ContainsKey("isDynamic"))
                {
                    isDynamic = Convert.ToBoolean(param["isDynamic"]);
                }
            }

            return(new RibbonTrail(name, maxElements, numberOfChains, useTextureCoords, useVertexColors, isDynamic));
        }
示例#14
0
        /// <summary>
        /// </summary>
        /// <param name="autoCreateWindow"> </param>
        /// <param name="renderSystem"> </param>
        /// <param name="windowTitle"> </param>
        /// <returns> </returns>
        public override RenderWindow CreateWindow(bool autoCreateWindow, GLESRenderSystem renderSystem, string windowTitle)
        {
            RenderWindow window = null;

            if (autoCreateWindow)
            {
                var  miscParams = new NamedParameterList();
                bool fullScreen = false;
                int  width      = 640;
                int  height     = 480;
                if (_options["Full Screen"] != null)
                {
                    fullScreen = _options["Full Screen"].Value == "Yes";
                }
                if (_options["Display Frequency"] != null)
                {
                    miscParams["displayFrequency"] = _options["Display Frequency"].Value;
                }
                if (_options["Video Mode"] != null)
                {
                    string val    = _options["Video Mode"].Value;
                    int    xIndex = val.IndexOf("x");

                    if (xIndex != -1)
                    {
                        width  = int.Parse(val.Substring(0, xIndex));
                        height = int.Parse(val.Substring(xIndex + 1));
                    }
                }
                if (_options["FSAA"] != null)
                {
                    miscParams["FSAA"] = _options["FSAA"].Value;
                }

                window = renderSystem.CreateRenderWindow(windowTitle, width, height, fullScreen, miscParams);
            }
            return(window);
        }
示例#15
0
        /// <summary>
        ///		Creates &amp; displays the new window.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="width">The width of the window in pixels.</param>
        /// <param name="height">The height of the window in pixels.</param>
        /// <param name="fullScreen">If true, the window fills the screen, with no title bar or border.</param>
        /// <param name="miscParams">A variable number of platform-specific arguments.
        /// The actual requirements must be defined by the implementing subclasses.</param>
        public override void Create(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            string title            = name;
            bool   vsync            = false;
            int    depthBuffer      = GraphicsMode.Default.Depth;
            float  displayFrequency = 60f;
            string border           = "resizable";

            this.name          = name;
            this.width         = width;
            this.height        = height;
            colorDepth         = 32;
            this.fullScreen    = fullScreen;
            this.displayDevice = DisplayDevice.Default;

            #region Parameter Handling

            if (miscParams != null)
            {
                foreach (var entry in miscParams)
                {
                    switch (entry.Key)
                    {
                    case "title":
                        title = entry.Value.ToString();
                        break;

                    case "left":
                        left = Int32.Parse(entry.Value.ToString());
                        break;

                    case "top":
                        top = Int32.Parse(entry.Value.ToString());
                        break;

                    case "fsaa":
                        fsaa = Int32.Parse(entry.Value.ToString());
                        break;

                    case "colourDepth":
                    case "colorDepth":
                        colorDepth = Int32.Parse(entry.Value.ToString());
                        break;

                    case "vsync":
                        vsync = entry.Value.ToString() == "No" ? false : true;
                        break;

                    case "displayFrequency":
                        displayFrequency = Int32.Parse(entry.Value.ToString());
                        break;

                    case "depthBuffer":
                        depthBuffer = Int32.Parse(entry.Value.ToString());
                        break;

                    case "border":
                        border = entry.Value.ToString().ToLower();
                        break;

                    case "externalWindowInfo":
                        this.glContext = new OpenTKGLContext((OpenTK.Platform.IWindowInfo)entry.Value);
                        break;

                    case "externalWindowHandle":
                        object handle = entry.Value;
                        IntPtr ptr    = IntPtr.Zero;
                        if (handle.GetType() == typeof(IntPtr))
                        {
                            ptr = (IntPtr)handle;
                        }
                        else if (handle.GetType() == typeof(System.Int32))
                        {
                            ptr = new IntPtr((int)handle);
                        }
                        //glContext = new OpenTKGLContext(Control.FromHandle(ptr), Control.FromHandle(ptr).Parent);

                        WindowEventMonitor.Instance.RegisterWindow(this);
                        fullScreen = false;
                        IsActive   = true;
                        break;

                    case "externalWindow":
                        //glContext = new OpenTKGLContext((Control)entry.Value, ((Control)entry.Value).Parent);
                        WindowEventMonitor.Instance.RegisterWindow(this);
                        fullScreen = false;
                        IsActive   = true;
                        break;

                    default:
                        break;
                    }
                }
            }

            #endregion Parameter Handling

            if (this.glContext == null)
            {
                // create window
                var graphicsMode = new GraphicsMode(new ColorFormat(this.ColorDepth), depthBuffer, this.ColorDepth - depthBuffer > 0 ? this.ColorDepth - depthBuffer : 0, FSAA);
                this._window   = new NativeWindow(width, height, title, GameWindowFlags.Default, graphicsMode, this.displayDevice);
                this.glContext = new OpenTKGLContext(this._window.WindowInfo);

                FileSystem.FileInfoList ico = ResourceGroupManager.Instance.FindResourceFileInfo(ResourceGroupManager.DefaultResourceGroupName, "AxiomIcon.ico");
                if (ico.Count != 0)
                {
                    this._window.Icon = System.Drawing.Icon.ExtractAssociatedIcon(ico[0].Filename);
                }

                if (fullScreen)
                {
                    this.displayDevice.ChangeResolution(width, height, ColorDepth, displayFrequency);
                    this._window.WindowState = WindowState.Fullscreen;
                    IsFullScreen             = true;
                }
                else
                {
                    this._window.WindowState = WindowState.Normal;

                    if (border == "fixed")
                    {
                        this._window.WindowBorder = WindowBorder.Fixed;
                    }
                    else if (border == "resizable")
                    {
                        this._window.WindowBorder = WindowBorder.Resizable;
                    }
                    else if (border == "none")
                    {
                        this._window.WindowBorder = WindowBorder.Hidden;
                    }
                }

                this._window.Title = title;

                WindowEventMonitor.Instance.RegisterWindow(this);

                // lets get active!
                IsActive             = true;
                this.glContext.VSync = vsync;
                this._window.Visible = true;
            }
        }
示例#16
0
		protected override MovableObject _createInstance( string name, NamedParameterList para )
		{
			return new PCZLight( name );
		}
示例#17
0
        public override RenderWindow CreateWindow(bool autoCreateWindow, GLRenderSystem renderSystem, string windowTitle)
        {
            RenderWindow autoWindow = null;

            if (autoCreateWindow)
            {
                int width = 640;
                int height = 480;
                int bpp = 32;
                bool fullscreen = false;

                ConfigOption optVM = ConfigOptions["Video Mode"];
                string vm = optVM.Value;
                int pos = vm.IndexOf('x');
                if (pos == -1)
                    throw new Exception("Invalid Video Mode provided");
                width = int.Parse(vm.Substring(0, vm.IndexOf("x")));
                height = int.Parse(vm.Substring(vm.IndexOf("x") + 1));

                fullscreen = (ConfigOptions["Full Screen"].Value == "Yes");

                NamedParameterList miscParams = new NamedParameterList();
                ConfigOption opt;

                opt = ConfigOptions["Color Depth"];
                if (opt != null)
                    miscParams.Add("colorDepth", opt.Value);

                opt = ConfigOptions["VSync"];
                if (opt != null)
                {
                    miscParams.Add("vsync", opt.Value);
                    if (Wgl.IsExtensionSupported("wglSwapIntervalEXT"))
                        Wgl.wglSwapIntervalEXT(StringConverter.ParseBool(opt.Value) ? 1 : 0);
                }

                opt = ConfigOptions["FSAA"];
                if (opt != null)
                    miscParams.Add("fsaa", opt.Value);

                // create a default form to use for a rendering target
                //DefaultForm form = CreateDefaultForm( windowTitle, 0, 0, width, height, fullscreen );

                // create the window with the default form as the target
                autoWindow = renderSystem.CreateRenderWindow(windowTitle, width, height, fullscreen, miscParams);

                // set the default form's renderwindow so it can access it internally
                //form.RenderWindow = autoWindow;

                // show the window
                //form.Show();
            }

            return autoWindow;
        }
        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;
        }
		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
			this._activeD3DDriver = this._driverList[ ConfigOptions[ "Rendering Device" ].Value ];
			if ( this._activeD3DDriver == null )
			{
				throw new ArgumentException( "Problems finding requested Direct3D driver!" );
			}

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

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

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

			// Also create hardware buffer manager
			this._hardwareBufferManager = new D3D9HardwareBufferManager();

			// Create the GPU program manager    
			this._gpuProgramManager = new D3D9GpuProgramManager();

			// Create & register HLSL factory
			this._hlslProgramFactory = new D3D9HLSLProgramFactory();

			RenderWindow autoWindow = null;

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

				D3D9VideoMode videoMode = null;

				var vm = ConfigOptions[ "Video Mode" ].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 ) ) );

				foreach ( var currVideoMode in this._activeD3DDriver.VideoModeList )
				{
					var temp = currVideoMode.Description;
					var colorDepth =
						int.Parse( temp.Substring( temp.IndexOf( "@" ) + 1, temp.IndexOf( "-" ) - ( temp.IndexOf( "@" ) + 1 ) ) );

					// In full screen we only want to allow supported resolutions, so temp and opt->second.currentValue need to 
					// match exactly, but in windowed mode we can allow for arbitrary window sized, so we only need
					// to match the colour values
					if ( fullScreen && ( temp == vm ) || !fullScreen && ( colorDepth == bpp ) )
					{
						videoMode = currVideoMode;
						break;
					}
				}

				if ( videoMode == null )
				{
					throw new AxiomException( "Can't find requested video mode." );
				}

				// sRGB window option
				ConfigOption opt;
				if ( !ConfigOptions.TryGetValue( "sRGB Gamma Conversion", out opt ) )
				{
					throw new AxiomException( "Can't find sRGB option!" );
				}

				var hwGamma = opt.Value == "Yes";

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

				// create the render window
				autoWindow = CreateRenderWindow( windowTitle, width, height, fullScreen, miscParams );

				// If we have 16bit depth buffer enable w-buffering.
				Contract.Requires( autoWindow != null );
				wBuffer = ( autoWindow.ColorDepth == 16 );
			}

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

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

			// Configure SharpDX
			DX.Configuration.ThrowOnShaderCompileError = true;

#if DEBUG
			DX.Configuration.EnableObjectTracking = true;
#endif
			return autoWindow;
		}
示例#20
0
        public override void Create(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            SWF.Control parentHWnd   = null;
            SWF.Control externalHWnd = null;
            this._fsaaType    = D3D9.MultisampleType.None;
            this._fsaaQuality = 0;
            fsaa                = 0;
            this._vSync         = false;
            this._vSyncInterval = 1;
            var title             = name;
            var colorDepth        = 32;
            var left              = int.MaxValue; // Defaults to screen center
            var top               = int.MaxValue; // Defaults to screen center
            var depthBuffer       = true;
            var border            = "";
            var outerSize         = false;
            var enableDoubleClick = false;

            this._useNVPerfHUD = false;
            //var fsaaSamples = 0; //Not used, even in Ogre
            var fsaaHint     = string.Empty;
            var monitorIndex = -1;

            if (miscParams != null)
            {
                object opt;

                // left (x)
                if (miscParams.TryGetValue("left", out opt))
                {
                    left = Int32.Parse(opt.ToString());
                }

                // top (y)
                if (miscParams.TryGetValue("top", out opt))
                {
                    top = Int32.Parse(opt.ToString());
                }

                // Window title
                if (miscParams.TryGetValue("title", out opt))
                {
                    title = (string)opt;
                }

                // parentWindowHandle		-> parentHWnd
                if (miscParams.TryGetValue("parentWindowHandle", out opt))
                {
                    // This is Axiom specific
                    var handle = opt;
                    var ptr    = IntPtr.Zero;
                    if (handle.GetType() == typeof(IntPtr))
                    {
                        ptr = (IntPtr)handle;
                    }
                    else if (handle.GetType() == typeof(Int32))
                    {
                        ptr = new IntPtr((int)handle);
                    }
                    else
                    {
                        throw new AxiomException("unhandled parentWindowHandle type");
                    }

                    parentHWnd = SWF.Control.FromHandle(ptr);
                }

                // externalWindowHandle		-> externalHWnd
                if (miscParams.TryGetValue("externalWindowHandle", out opt))
                {
                    // This is Axiom specific
                    var handle = opt;
                    var ptr    = IntPtr.Zero;
                    if (handle.GetType() == typeof(IntPtr))
                    {
                        ptr = (IntPtr)handle;
                    }
                    else if (handle.GetType() == typeof(Int32))
                    {
                        ptr = new IntPtr((int)handle);
                    }
                    else
                    {
                        throw new AxiomException("unhandled externalWindowHandle type");
                    }

                    externalHWnd = SWF.Control.FromHandle(ptr);
                }

                // vsync	[parseBool]
                if (miscParams.TryGetValue("vsync", out opt))
                {
                    this._vSync = bool.Parse(opt.ToString());
                }

                // vsyncInterval	[parseUnsignedInt]
                if (miscParams.TryGetValue("vsyncInterval", out opt))
                {
                    this._vSyncInterval = Int32.Parse(opt.ToString());
                }

                // displayFrequency
                if (miscParams.TryGetValue("displayFrequency", out opt))
                {
                    this._displayFrequency = Int32.Parse(opt.ToString());
                }

                // colorDepth
                if (miscParams.TryGetValue("colorDepth", out opt))
                {
                    colorDepth = Int32.Parse(opt.ToString());
                }

                // depthBuffer [parseBool]
                if (miscParams.TryGetValue("depthBuffer", out opt))
                {
                    depthBuffer = bool.Parse(opt.ToString());
                }

                //FSAA settings

                // FSAA type
                if (miscParams.TryGetValue("FSAA", out opt))
                {
                    this._fsaaType = (D3D9.MultisampleType)opt;
                }

                if (miscParams.TryGetValue("FSAAHint", out opt))
                {
                    fsaaHint = (string)opt;
                }

                // window border style
                if (miscParams.TryGetValue("border", out opt))
                {
                    border = ((string)opt).ToLower();
                }

                // set outer dimensions?
                if (miscParams.TryGetValue("outerDimensions", out opt))
                {
                    outerSize = bool.Parse(opt.ToString());
                }

                // NV perf HUD?
                if (miscParams.TryGetValue("useNVPerfHUD", out opt))
                {
                    this._useNVPerfHUD = bool.Parse(opt.ToString());
                }

                // sRGB?
                if (miscParams.TryGetValue("gamma", out opt))
                {
                    hwGamma = bool.Parse(opt.ToString());
                }

                // monitor index
                if (miscParams.TryGetValue("monitorIndex", out opt))
                {
                    monitorIndex = Int32.Parse(opt.ToString());
                }

                // enable double click messages
                if (miscParams.TryGetValue("enableDoubleClick", out opt))
                {
                    enableDoubleClick = bool.Parse(opt.ToString());
                }
            }

            // Destroy current window if any
            if (this._windowHandle != null)
            {
                Destroy();
            }

            if (externalHWnd == null)
            {
                var  dwStyle       = WindowStyles.WS_VISIBLE | WindowStyles.WS_CLIPCHILDREN;
                var  dwStyleEx     = (WindowsExtendedStyle)0;
                var  monitorHandle = IntPtr.Zero;
                RECT rc;

                // If we specified which adapter we want to use - find it's monitor.
                if (monitorIndex != -1)
                {
                    var direct3D9 = D3D9RenderSystem.Direct3D9;

                    for (var i = 0; i < direct3D9.AdapterCount; ++i)
                    {
                        if (i != monitorIndex)
                        {
                            continue;
                        }

                        monitorHandle = direct3D9.GetAdapterMonitor(i);
                        break;
                    }
                }

                // If we didn't specified the adapter index, or if it didn't find it
                if (monitorHandle == IntPtr.Zero)
                {
                    // Fill in anchor point.
                    var windowAnchorPoint = new Point(left, top);

                    // Get the nearest monitor to this window.
                    monitorHandle = ScreenHelper.GetHandle(windowAnchorPoint);
                }

                // Get the target monitor info
                var monitorInfo = ScreenHelper.FromHandle(monitorHandle);

                var winWidth  = width;
                var winHeight = height;

                // No specified top left -> Center the window in the middle of the monitor
                if (left == int.MaxValue || top == int.MaxValue)
                {
                    var screenw = monitorInfo.WorkingArea.Right - monitorInfo.WorkingArea.Left;
                    var screenh = monitorInfo.WorkingArea.Bottom - monitorInfo.WorkingArea.Top;

                    // clamp window dimensions to screen size
                    var outerw = (winWidth < screenw) ? winWidth : screenw;
                    var outerh = (winHeight < screenh) ? winHeight : screenh;

                    if (left == int.MaxValue)
                    {
                        left = monitorInfo.WorkingArea.Left + (screenw - outerw) / 2;
                    }
                    else if (monitorIndex != -1)
                    {
                        left += monitorInfo.WorkingArea.Left;
                    }

                    if (top == int.MaxValue)
                    {
                        top = monitorInfo.WorkingArea.Top + (screenh - outerh) / 2;
                    }
                    else if (monitorIndex != -1)
                    {
                        top += monitorInfo.WorkingArea.Top;
                    }
                }
                else if (monitorIndex != -1)
                {
                    left += monitorInfo.WorkingArea.Left;
                    top  += monitorInfo.WorkingArea.Top;
                }

                this.width  = this._desiredWidth = width;
                this.height = this._desiredHeight = height;
                this.top    = top;
                this.left   = left;

                if (fullScreen)
                {
                    dwStyleEx |= WindowsExtendedStyle.WS_EX_TOPMOST;
                    dwStyle   |= WindowStyles.WS_POPUP;
                    this.top   = monitorInfo.Bounds.Top;
                    this.left  = monitorInfo.Bounds.Left;
                }
                else
                {
                    if (parentHWnd != null)
                    {
                        dwStyle |= WindowStyles.WS_CHILD;
                    }
                    else
                    {
                        if (border == "none")
                        {
                            dwStyle |= WindowStyles.WS_POPUP;
                        }
                        else if (border == "fixed")
                        {
                            dwStyle |= WindowStyles.WS_OVERLAPPED | WindowStyles.WS_BORDER | WindowStyles.WS_CAPTION |
                                       WindowStyles.WS_SYSMENU | WindowStyles.WS_MINIMIZEBOX;
                        }
                        else
                        {
                            dwStyle |= WindowStyles.WS_OVERLAPPEDWINDOW;
                        }
                    }

                    AdjustWindow(width, height, dwStyle, out winWidth, out winHeight);

                    if (!outerSize)
                    {
                        // Calculate window dimensions required
                        // to get the requested client area
                        rc = new RECT(0, 0, this.width, this.height);
                        AdjustWindowRect(ref rc, dwStyle, false);
                        this.width  = rc.Right - rc.Left;
                        this.height = rc.Bottom - rc.Top;

                        // Clamp window rect to the nearest display monitor.
                        if (this.left < monitorInfo.WorkingArea.Left)
                        {
                            this.left = monitorInfo.WorkingArea.Left;
                        }

                        if (this.top < monitorInfo.WorkingArea.Top)
                        {
                            this.top = monitorInfo.WorkingArea.Top;
                        }

                        if (winWidth > monitorInfo.WorkingArea.Right - this.left)
                        {
                            winWidth = monitorInfo.WorkingArea.Right - this.left;
                        }

                        if (winHeight > monitorInfo.WorkingArea.Bottom - this.top)
                        {
                            winHeight = monitorInfo.WorkingArea.Bottom - this.top;
                        }
                    }
                }

                WindowClassStyle classStyle = 0;
                if (enableDoubleClick)
                {
                    classStyle |= WindowClassStyle.CS_DBLCLKS;
                }

                // Create our main window
                this._isExternal = false;
                var wnd = new DefaultForm(classStyle, dwStyleEx, title, dwStyle, this.left, this.top, winWidth, winHeight,
                                          parentHWnd);
                wnd.RenderWindow   = this;
                this._windowHandle = wnd;
                this._style        = dwStyle;
                WindowEventMonitor.Instance.RegisterWindow(this);
            }
            else
            {
                this._windowHandle = externalHWnd;
                this._isExternal   = true;
            }

            // top and left represent outer window coordinates
            var rc2 = new System.Drawing.Rectangle(this._windowHandle.Location, this._windowHandle.Size);

            this.top  = rc2.Top;
            this.left = rc2.Left;

            // width and height represent interior drawable area
            rc2 = this._windowHandle.ClientRectangle;

            this.width  = rc2.Right;
            this.height = rc2.Bottom;

            this.name       = name;
            isDepthBuffered = depthBuffer;
            isFullScreen    = fullScreen;
            this.colorDepth = colorDepth;

            LogManager.Instance.Write("D3D9 : Created D3D9 Rendering Window '{0}' : {1}x{2}, {3}bpp", this.name, this.width,
                                      this.height, ColorDepth);

            active         = true;
            this._isClosed = false;
        }
示例#21
0
 public NamedParameterList(CParameters parent, NamedParameterList src)
     : this(parent, src.count)
 {
     Array.Copy(src.items, items, src.count);
     count = src.count;
 }
示例#22
0
		/// <summary>
		/// Creates a new render window.
		/// </summary>
		/// <remarks>
		/// This method creates a new rendering window as specified
		/// by the paramteters. The rendering system could be
		/// responible for only a single window (e.g. in the case
		/// of a game), or could be in charge of multiple ones (in the
		/// case of a level editor). The option to create the window
		/// as a child of another is therefore given.
		/// This method will create an appropriate subclass of
		/// RenderWindow depending on the API and platform implementation.
		/// </remarks>
		/// <param name="name"></param>
		/// <param name="width"></param>
		/// <param name="height"></param>
		/// <param name="isFullScreen"></param>
		/// <param name="miscParams">
		/// A collection of addition rendersystem specific options.
		/// </param>
		public override RenderWindow CreateRenderWindow(string name, int width, int height, bool isFullScreen, NamedParameterList 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.");

			if (_primaryWindow != null && isFullScreen)
				throw new ArgumentException("Cannot create full screen secondary windows.");

			// Log a message
			var strParams = new StringBuilder();
			if (miscParams != null)
			{
				foreach (var entry in miscParams)
				{
					strParams.AppendFormat("{0} = {1}; ", entry.Key, entry.Value);
				}
			}
			LogManager.Instance.Write("[XNA] : Creating RenderWindow \"{0}\", {1}x{2} {3} miscParams: {4}",
									   name, width, height, isFullScreen ? "fullscreen" : "windowed",
									   strParams.ToString());

			// Make sure we don't already have a render target of the 
			// same name as the one supplied
			if (renderTargets.ContainsKey(name))
			{
				throw new Exception(String.Format("A render target of the same name '{0}' already exists." +
													"You cannot create a new window with this name.", name));
			}

			RenderWindow window = new XnaRenderWindow(_activeDriver, _primaryWindow != null ? _device : null);

			// create the window
			window.Create(name, width, height, isFullScreen, miscParams);

			// add the new render target
			AttachRenderTarget(window);
			// If this is the first window, get the D3D device and create the texture manager
			if (_primaryWindow == null)
			{
				_primaryWindow = (XnaRenderWindow)window;
				_device = (GraphicsDevice)window["XNADEVICE"];

				basicEffect = new BasicEffect(_device);
				skinnedEffect = new SkinnedEffect(_device);
				// Create the texture manager for use by others
				textureManager = new XnaTextureManager(_device);
				// Also create hardware buffer manager
				_hardwareBufferManager = new XnaHardwareBufferManager( _device );

				// Create the GPU program manager
				gpuProgramMgr = new XnaGpuProgramManager(_device);
				// create & register HLSL factory
				//gpuProgramMgr.PushSyntaxCode("hlsl"));

				realCapabilities = new RenderSystemCapabilities();
				// use real capabilities if custom capabilities are not available
				if (!useCustomCapabilities)
				{
					currentCapabilities = realCapabilities;
				}

				FireEvent("RenderSystemCapabilitiesCreated");

				InitializeFromRenderSystemCapabilities(currentCapabilities, window);

				// Initialize the capabilities structures
				_checkHardwareCapabilities( _primaryWindow );
			}
			else
			{
				_secondaryWindows.Add((XnaRenderWindow)window);
			}

#if !SILVERLIGHT // Can only work on _device inside the Draw callback
			StateManager.ResetState( _device );
#endif
			return window;
		}
示例#23
0
        /// <summary>
        /// Initializes a RenderWindow Instance
        /// </summary>
        /// <param name="name"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="fullScreen"></param>
        /// <param name="miscParams"></param>
        public override void Create(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            var parentHWnd   = IntPtr.Zero;
            var externalHWnd = IntPtr.Zero;
            var title        = name;
            var colourDepth  = 32;
            var left         = -1;    // Defaults to screen center
            var top          = -1;    // Defaults to screen center
            var depthBuffer  = true;
            var border       = "";
            var outerSize    = false;

            _useNVPerfHUD = false;
            _fsaaQuality  = 0;
            _vSync        = false;

            if (miscParams != null)
            {
                // left (x)
                if (miscParams.ContainsKey("left"))
                {
                    left = Int32.Parse(miscParams["left"].ToString());
                }

                // top (y)
                if (miscParams.ContainsKey("top"))
                {
                    top = Int32.Parse(miscParams["top"].ToString());
                }

                // Window title
                if (miscParams.ContainsKey("title"))
                {
                    title = (string)miscParams["title"];
                }

                if (miscParams.ContainsKey("xnaGraphicsDevice"))
                {
                    var graphics = miscParams["xnaGraphicsDevice"] as GraphicsDevice;
                    this.Driver.XnaDevice = graphics;
                }

#if !(XBOX || XBOX360)
                // parentWindowHandle		-> parentHWnd
                if (miscParams.ContainsKey("parentWindowHandle"))
                {
                    var handle = miscParams["parentWindowHandle"];
                    if (handle.GetType() == typeof(IntPtr))
                    {
                        parentHWnd = (IntPtr)handle;
                    }
                    else if (handle.GetType() == typeof(Int32))
                    {
                        parentHWnd = new IntPtr((int)handle);
                    }
                }

                // externalWindowHandle		-> externalHWnd
                if (miscParams.ContainsKey("externalWindowHandle"))
                {
                    var handle = miscParams["externalWindowHandle"];
                    if (handle.GetType() == typeof(IntPtr))
                    {
                        externalHWnd = (IntPtr)handle;
                    }
                    else if (handle.GetType() == typeof(Int32))
                    {
                        externalHWnd = new IntPtr((int)handle);
                    }
                }
#endif
                // vsync	[parseBool]
                if (miscParams.ContainsKey("vsync"))
                {
                    _vSync = bool.Parse(miscParams["vsync"].ToString());
                }

                // displayFrequency
                if (miscParams.ContainsKey("displayFrequency"))
                {
                    _displayFrequency = Int32.Parse(miscParams["displayFrequency"].ToString());
                }

                // colourDepth
                if (miscParams.ContainsKey("colorDepth"))
                {
                    colourDepth = Int32.Parse(miscParams["colorDepth"].ToString());
                }

                // depthBuffer [parseBool]
                if (miscParams.ContainsKey("depthBuffer"))
                {
                    depthBuffer = bool.Parse(miscParams["depthBuffer"].ToString());
                }

                //FSAA type should hold a bool value, because anti-aliasing is either enabled, or it isn't.
                //// FSAA type
                //if ( miscParams.ContainsKey( "FSAA" ) )
                //{
                //    //_fsaaType = (MultiSampleType)miscParams[ "FSAA" ];
                //}

                // FSAA quality
                if (miscParams.ContainsKey("FSAAQuality"))
                {
                    _fsaaQuality = Int32.Parse(miscParams["FSAAQuality"].ToString());
                }

                // window border style
                if (miscParams.ContainsKey("border"))
                {
                    border = ((string)miscParams["border"]).ToLower();
                }

                // set outer dimensions?
                if (miscParams.ContainsKey("outerDimensions"))
                {
                    outerSize = bool.Parse(miscParams["outerDimensions"].ToString());
                }

                // NV perf HUD?
                if (miscParams.ContainsKey("useNVPerfHUD"))
                {
                    _useNVPerfHUD = bool.Parse(miscParams["useNVPerfHUD"].ToString());
                }
            }
#if !(XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE)
            if (_windowHandle != IntPtr.Zero)
            {
                Dispose();
            }

            if (externalHWnd == IntPtr.Zero)
            {
                this.width  = width;
                this.height = height;
                this.top    = top;
                this.left   = left;

                _isExternal = false;
                var newWin = new DefaultForm();
                newWin.Text = title;

                /* If we're in fullscreen, we can use the device's back and stencil buffers.
                 * If we're in windowed mode, we'll want our own.
                 * get references to the render target and depth stencil surface
                 */
                if (!fullScreen)
                {
                    newWin.StartPosition = FormStartPosition.CenterScreen;
                    if (parentHWnd != IntPtr.Zero)
                    {
                        newWin.Parent = Control.FromHandle(parentHWnd);
                    }
                    else
                    {
                        if (border == "none")
                        {
                            newWin.FormBorderStyle = FormBorderStyle.None;
                        }
                        else if (border == "fixed")
                        {
                            newWin.FormBorderStyle = FormBorderStyle.FixedSingle;
                            newWin.MaximizeBox     = false;
                        }
                    }

                    if (!outerSize)
                    {
                        newWin.ClientSize = new Size(Width, Height);
                    }
                    else
                    {
                        newWin.Width  = Width;
                        newWin.Height = Height;
                    }

                    if (top < 0)
                    {
                        top = (Screen.PrimaryScreen.Bounds.Height - Height) / 2;
                    }
                    if (left < 0)
                    {
                        left = (Screen.PrimaryScreen.Bounds.Width - Width) / 2;
                    }
                }
                else
                {
                    //dwStyle |= WS_POPUP;
                    top = left = 0;
                }

                // Create our main window
                newWin.Top  = top;
                newWin.Left = left;

                newWin.RenderWindow = this;
                _windowHandle       = newWin.Handle;

                WindowEventMonitor.Instance.RegisterWindow(this);
            }
            else
            {
                _windowHandle = externalHWnd;
                _isExternal   = true;
            }
#endif

            // set the params of the window
            this.name       = name;
            colorDepth      = colourDepth;
            this.width      = width;
            this.height     = height;
            IsFullScreen    = fullScreen;
            isDepthBuffered = depthBuffer;
            this.top        = top;
            this.left       = left;


            if (Driver.XnaDevice == null)
            {
                CreateXnaResources();
            }

#if !(XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE)
            (Control.FromHandle(_windowHandle)).Show();
#endif

            IsActive  = true;
            _isClosed = false;

            LogManager.Instance.Write("[XNA] : Created D3D9 Rendering Window '{0}' : {1}x{2}, {3}bpp", Name, Width, Height, ColorDepth);
        }
示例#24
0
		/// <summary>
		///		A collection of addition render system specific options.
		///	</summary>
		public RenderWindow CreateRenderWindow( string name, int width, int height, bool isFullscreen,
		                                        NamedParameterList miscParams )
		{
			Debug.Assert( this.activeRenderSystem != null, "Cannot create a RenderWindow without an active RenderSystem." );

			// create a new render window via the current render system
			var window = this.activeRenderSystem.CreateRenderWindow( name, width, height, isFullscreen, miscParams );

			// do any required initialization
			if ( this.firstTimePostWindowInit )
			{
				OneTimePostWindowInit();
				// window.Primary = true;
			}

			return window;
		}
示例#25
0
		protected override MovableObject _createInstance( string name, NamedParameterList param )
		{
			// must have mesh parameter
			string caption = null;
			string fontName = null;

			if ( param != null )
			{
				if ( param.ContainsKey( "caption" ) )
				{
					caption = (string)param[ "caption" ];
				}
				if ( param.ContainsKey( "fontName" ) )
				{
					fontName = (string)param[ "fontName" ];
				}
			}
			if ( caption == null )
			{
				throw new AxiomException( "'caption' parameter required when constructing MovableText." );
			}
			if ( fontName == null )
			{
				throw new AxiomException( "'fontName' parameter required when constructing MovableText." );
			}

			MovableText text = new MovableText( name, caption, fontName );
			text.MovableType = this.Type;
			return text;
		}
示例#26
0
 /// <summary>
 ///		Creates &amp; displays the new window.
 /// </summary>
 /// <param name="name"></param>
 /// <param name="width">The width of the window in pixels.</param>
 /// <param name="height">The height of the window in pixels.</param>
 /// <param name="fullScreen">If true, the window fills the screen, with no title bar or border.</param>
 /// <param name="miscParams">A variable number of platform-specific arguments.
 /// The actual requirements must be defined by the implementing subclasses.</param>
 public abstract void Create(string name, int width, int height, bool fullScreen, NamedParameterList miscParams);
示例#27
0
		public virtual RenderWindow NewWindow( string name, int width, int height, bool fullScreen, NamedParameterList miscParams )
		{
			//Meant to be overridden
			throw new NotImplementedException();
		}
		/// <summary>
		/// 
		/// </summary>
		/// <param name="sceneMgr"></param>
		private void SetupBody( SceneManager sceneMgr )
		{
			// create main model
			bodyNode = sceneMgr.RootSceneNode.CreateChildSceneNode( Vector3.UnitY * CharHeight );
			bodyEnt = sceneMgr.CreateEntity( "SinbadBody", "Sinbad.mesh" );
			bodyNode.AttachObject( bodyEnt );

			// create swords and attach to sheath
			sword1 = sceneMgr.CreateEntity( "SinbadSword1", "Sword.mesh" );
			sword2 = sceneMgr.CreateEntity( "SinbadSword2", "Sword.mesh" );
			bodyEnt.AttachObjectToBone( "Sheath.L", sword1 );
			bodyEnt.AttachObjectToBone( "Sheath.R", sword2 );

			// create a couple of ribbon trails for the swords, just for fun
			NamedParameterList paras = new NamedParameterList();
			paras[ "numberOfChains" ] = "2";
			paras[ "maxElements" ] = "80";
			swordTrail = (RibbonTrail)sceneMgr.CreateMovableObject( "SinbadRibbon", "RibbonTrail", paras );
			swordTrail.MaterialName = "Examples/LightRibbonTrail";
			swordTrail.TrailLength = 20;
			swordTrail.IsVisible = false;
			sceneMgr.RootSceneNode.AttachObject( swordTrail );

			for ( int i = 0; i < 2; i++ )
			{
				swordTrail.SetInitialColor( i, new ColorEx( 1, 0.8f, 0 ) );
				swordTrail.SetColorChange( i, new ColorEx( 0.75f, 0.25f, 0.25f, 0.25f ) );
				swordTrail.SetWidthChange( i, 1 );
				swordTrail.SetInitialWidth( i, 0.5f );
			}

			keyDirection = Vector3.Zero;
			verticalVelocity = 0;

		}
示例#29
0
 /// <summary>
 /// </summary>
 /// <param name="name"> </param>
 /// <param name="width"> </param>
 /// <param name="height"> </param>
 /// <param name="fullScreen"> </param>
 /// <param name="miscParams"> </param>
 /// <returns> </returns>
 public abstract RenderWindow NewWindow(string name, int width, int height, bool fullScreen, NamedParameterList miscParams = null);
示例#30
0
		/// <summary>
		/// Initialize the rendering engine.
		/// </summary>
		/// <param name="autoCreateWindow">If true, a default window is created to serve as a rendering target.</param>
		/// <param name="windowTitle">Text to display on the window caption if not fullscreen.</param>
		/// <returns>A RenderWindow implementation specific to this RenderSystem.</returns>
		/// <remarks>All subclasses should call this method from within thier own intialize methods.</remarks>
		public override RenderWindow Initialize(bool autoCreateWindow, string windowTitle)
		{
			LogManager.Instance.Write("[XNA] : Subsystem Initializing");

#if !( XBOX || XBOX360 || SILVERLIGHT || WINDOWS_PHONE )
			WindowEventMonitor.Instance.MessagePump = Win32MessageHandling.MessagePump;
#endif
			_activeDriver = XnaHelper.GetDriverInfo()[ConfigOptions["Rendering Device"].Value];
			if (_activeDriver == null)
			{
				throw new ArgumentException("Problems finding requested Xna driver!");
			}

			RenderWindow renderWindow = null;

			// register the HLSL program manager
			//HighLevelGpuProgramManager.Instance.AddFactory(new HLSLProgramFactory());

			StateManager = new StateManagement();
			if (autoCreateWindow)
			{
#if SILVERLIGHT
				var width = (int)XnaRenderWindow.DrawingSurface.ActualWidth;
				var height = (int)XnaRenderWindow.DrawingSurface.ActualHeight;
#else
				var width = 800;
				var height = 600;
#endif
				var bpp = 32;
				var fullScreen = false;

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

#if !(XBOX || XBOX360)
				fullScreen = (ConfigOptions["Full Screen"].Value == "Yes");
#endif

				var miscParams = new NamedParameterList();
				miscParams.Add("title", windowTitle);
				miscParams.Add("colorDepth", bpp);
				//miscParams.Add( "FSAA", this._fsaaType );
				miscParams.Add("FSAAQuality", _fsaaQuality);
				miscParams.Add("vsync", _vSync);
				miscParams.Add("useNVPerfHUD", _useNVPerfHUD);

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

			new XnaMaterialManager();

			LogManager.Instance.Write("[XNA] : Subsystem Initialized successfully.");
			return renderWindow;
		}
示例#31
0
        public override RenderWindow NewWindow(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            Win32Window window = new Win32Window(this);

            window.Create(name, width, height, fullScreen, miscParams);

            return(window);
        }
示例#32
0
		/// <summary>
		///
		/// </summary>
		/// <param name="autoCreateWindow"></param>
		/// <param name="renderSystem"></param>
		/// <param name="windowTitle"></param>
		/// <returns></returns>
		public override RenderWindow CreateWindow( bool autoCreateWindow, GLRenderSystem renderSystem, string windowTitle )
		{
			RenderWindow autoWindow = null;

			if ( autoCreateWindow )
			{
				int width = 800;
				int height = 600;
				int bpp = 32;
				bool fullScreen = false;

				ConfigOption optVM = ConfigOptions[ "Video Mode" ];
				string vm = optVM.Value;
				int pos = vm.IndexOf( 'x' );
				if ( pos == -1 )
				{
					throw new Exception( "Invalid Video Mode provided" );
				}
				width = int.Parse( vm.Substring( 0, vm.IndexOf( "x" ) ) );
				height = int.Parse( vm.Substring( vm.IndexOf( "x" ) + 1 ) );

				fullScreen = ( ConfigOptions[ "Full Screen" ].Value == "Yes" );

				var miscParams = new NamedParameterList();
				ConfigOption opt;

				opt = ConfigOptions[ "Color Depth" ];
				if ( opt != null && opt.Value != null && opt.Value.Length > 0 )
				{
					miscParams.Add( "colorDepth", opt.Value );
				}

				opt = ConfigOptions[ "VSync" ];
				if ( opt != null && opt.Value != null && opt.Value.Length > 0 )
				{
					miscParams.Add( "vsync", opt.Value );
					//TODO : renderSystem.WaitForVerticalBlank = (bool)opt.Value;
				}

				opt = ConfigOptions[ "FSAA" ];
				if ( opt != null && opt.Value != null && opt.Value.Length > 0 )
				{
					miscParams.Add( "fsaa", opt.Value );
				}

				miscParams.Add( "title", windowTitle );

				// create the window with the default form as the target
				autoWindow = renderSystem.CreateRenderWindow( windowTitle, width, height, fullScreen, miscParams );
			}

			return autoWindow;
		}
示例#33
0
        public override RenderWindow CreateRenderWindow( string name, int width, int height, bool isFullScreen, NamedParameterList miscParams )
        {
            LogManager.Instance.Write("D3D9RenderSystem::createRenderWindow \"{0}\", {1}x{2} {3} ",
                                       name, width, height, isFullScreen ? "fullscreen" : "windowed");

            LogManager.Instance.Write( "miscParams: {0}",
                                       miscParams.Aggregate( new StringBuilder(),
                                                             ( s, kv ) =>
                                                             s.AppendFormat( "{0} = {1};", kv.Key, kv.Value ).AppendLine()
                                           ).ToString()
                );

            // Make sure we don't already have a render target of the
            // same name as the one supplied
            if (renderTargets.ContainsKey(name))
            {
                throw new Exception(String.Format("A render target of the same name '{0}' already exists." +
                                     "You cannot create a new window with this name.", name));
            }

            var window = new D3DRenderWindow(_activeD3DDriver, null);

            window.Create(name, width, height, isFullScreen, miscParams);

            _resourceManager.LockDeviceAccess();

            _deviceManager.LinkRenderWindow( window );

            _resourceManager.UnlockDeviceAccess();

            _renderWindows.Add( window );

            UpdateRenderSystemCapabilities( window );

            AttachRenderTarget( window );

            return window;
        }
        public override RenderWindow CreateRenderWindow(string name, int width, int height, bool isFullscreen,
                                                        NamedParameterList miscParams)
        {
            if (renderTargets.ContainsKey(name))
            {
                throw new Exception(String.Format("Window with the name '{0}' already exists.", name));
            }

            // Log a message
            var msg = new StringBuilder();

            msg.AppendFormat("GLRenderSystem.CreateRenderWindow \"{0}\", {1}x{2} {3} ", name, width, height,
                             isFullscreen ? "fullscreen" : "windowed");
            if (miscParams != null)
            {
                msg.Append("miscParams: ");
                foreach (var param in miscParams)
                {
                    msg.AppendFormat(" {0} = {1} ", param.Key, param.Value);
                }
                LogManager.Instance.Write(msg.ToString());
            }

            // create the window
            var window = this._glSupport.NewWindow(name, width, height, isFullscreen, miscParams);

            // add the new render target
            AttachRenderTarget(window);

            if (!this._glInitialised)
            {
                InitializeContext(window);

                var _glSupportVersion = this._glSupport.Version.Split(new[]
                {
                    ' '
                })[0];
                var tokens = _glSupportVersion.Split(new[]
                {
                    '.'
                });

                if (tokens.Length != 0)
                {
                    driverVersion.Major = Int32.Parse(tokens[0]);
                    if (tokens.Length > 1)
                    {
                        driverVersion.Minor = Int32.Parse(tokens[1]);
                    }
                    if (tokens.Length > 2)
                    {
                        driverVersion.Release = Int32.Parse(tokens[2]);
                    }
                }
                driverVersion.Build = 0;

                // Initialise GL after the first window has been created
                // TODO: fire this from emulation options, and don't duplicate Real and Current capabilities
                realCapabilities = CreateRenderSystemCapabilities();

                // use real capabilities if custom capabilities are not available
                if (!useCustomCapabilities)
                {
                    currentCapabilities = realCapabilities;
                }

                FireEvent("RenderSystemCapabilitiesCreated");


                InitializeFromRenderSystemCapabilities(currentCapabilities, window);

                // Initialise the main context
                OneTimeContextInitialization();
                if (this._currentContext != null)
                {
                    this._currentContext.Initialized = true;
                }
            }

            if (window.DepthBufferPool != PoolId.NoDepth)
            {
                //Unlike D3D9, OGL doesn't allow sharing the main depth buffer, so keep them separate.
                //Only Copy does, but Copy means only one depth buffer...
                var windowContext = (GLContext)window["GLCONTEXT"];

                var depthBuffer = new GLDepthBuffer(PoolId.Default, this, windowContext, null, null, window.Width, window.Height,
                                                    window.FSAA, 0, true);

                depthBufferPool[depthBuffer.PoolId].Add(depthBuffer);

                window.AttachDepthBuffer(depthBuffer);
            }
            return(window);
        }
        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
            this._activeD3DDriver = this._driverList[ConfigOptions["Rendering Device"].Value];
            if (this._activeD3DDriver == null)
            {
                throw new ArgumentException("Problems finding requested Direct3D driver!");
            }

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

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

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

            // Also create hardware buffer manager
            this._hardwareBufferManager = new D3D9HardwareBufferManager();

            // Create the GPU program manager
            this._gpuProgramManager = new D3D9GpuProgramManager();

            // Create & register HLSL factory
            this._hlslProgramFactory = new D3D9HLSLProgramFactory();

            RenderWindow autoWindow = null;

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

                D3D9VideoMode videoMode = null;

                var vm     = ConfigOptions["Video Mode"].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)));

                foreach (var currVideoMode in this._activeD3DDriver.VideoModeList)
                {
                    var temp       = currVideoMode.Description;
                    var colorDepth =
                        int.Parse(temp.Substring(temp.IndexOf("@") + 1, temp.IndexOf("-") - (temp.IndexOf("@") + 1)));

                    // In full screen we only want to allow supported resolutions, so temp and opt->second.currentValue need to
                    // match exactly, but in windowed mode we can allow for arbitrary window sized, so we only need
                    // to match the colour values
                    if (fullScreen && (temp == vm) || !fullScreen && (colorDepth == bpp))
                    {
                        videoMode = currVideoMode;
                        break;
                    }
                }

                if (videoMode == null)
                {
                    throw new AxiomException("Can't find requested video mode.");
                }

                // sRGB window option
                ConfigOption opt;
                if (!ConfigOptions.TryGetValue("sRGB Gamma Conversion", out opt))
                {
                    throw new AxiomException("Can't find sRGB option!");
                }

                var hwGamma = opt.Value == "Yes";

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

                // create the render window
                autoWindow = CreateRenderWindow(windowTitle, width, height, fullScreen, miscParams);

                // If we have 16bit depth buffer enable w-buffering.
                Contract.Requires(autoWindow != null);
                wBuffer = (autoWindow.ColorDepth == 16);
            }

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

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

            // Configure SharpDX
            DX.Configuration.ThrowOnShaderCompileError = true;

#if DEBUG
            DX.Configuration.EnableObjectTracking = true;
#endif
            return(autoWindow);
        }
示例#36
0
 public CParameters()
 {
     namedParams   = new NamedParameterList(this);
     unnamedParams = new ParameterList(this);
 }
示例#37
0
        public override void Create(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            LogManager.Instance.Write("\tCreate called");
            this.InitNativeCreatedWindow(miscParams);

            this.name   = name;
            this.width  = width;
            this.height = height;
            left        = 0;
            top         = 0;
            active      = true;

            this.closed = false;
        }
示例#38
0
		/// <summary>
		///		Create an Entity (instance of a discrete mesh).
		/// </summary>
		/// <param name="name">The name to be given to the entity (must be unique).</param>
		/// <param name="mesh">The mesh to use.</param>
		/// <returns></returns>
		public virtual Entity CreateEntity( string name, Mesh mesh )
		{
			var param = new NamedParameterList();
			param.Add( "mesh", mesh );
			return (Entity)CreateMovableObject( name, EntityFactory.TypeName, param );
		}
		public override RenderWindow CreateRenderWindow( string name, int width, int height, bool isFullscreen,
														 NamedParameterList miscParams )
		{
			if ( renderTargets.ContainsKey( name ) )
			{
				throw new Exception( String.Format( "Window with the name '{0}' already exists.", name ) );
			}

			// Log a message
			var msg = new StringBuilder();
			msg.AppendFormat( "GLRenderSystem.CreateRenderWindow \"{0}\", {1}x{2} {3} ", name, width, height,
							  isFullscreen ? "fullscreen" : "windowed" );
			if ( miscParams != null )
			{
				msg.Append( "miscParams: " );
				foreach ( var param in miscParams )
				{
					msg.AppendFormat( " {0} = {1} ", param.Key, param.Value );
				}
				LogManager.Instance.Write( msg.ToString() );
			}

			// create the window
			var window = this._glSupport.NewWindow( name, width, height, isFullscreen, miscParams );

			// add the new render target
			AttachRenderTarget( window );

			if ( !this._glInitialised )
			{
				InitializeContext( window );

				var _glSupportVersion = this._glSupport.Version.Split( new[]
																	   {
																		' '
																	   } )[ 0 ];
				var tokens = _glSupportVersion.Split( new[]
													  {
														'.'
													  } );

				if ( tokens.Length != 0 )
				{
					driverVersion.Major = Int32.Parse( tokens[ 0 ] );
					if ( tokens.Length > 1 )
					{
						driverVersion.Minor = Int32.Parse( tokens[ 1 ] );
					}
					if ( tokens.Length > 2 )
					{
						driverVersion.Release = Int32.Parse( tokens[ 2 ] );
					}
				}
				driverVersion.Build = 0;

				// Initialise GL after the first window has been created
				// TODO: fire this from emulation options, and don't duplicate Real and Current capabilities
				realCapabilities = CreateRenderSystemCapabilities();

				// use real capabilities if custom capabilities are not available
				if ( !useCustomCapabilities )
				{
					currentCapabilities = realCapabilities;
				}

				FireEvent( "RenderSystemCapabilitiesCreated" );


				InitializeFromRenderSystemCapabilities( currentCapabilities, window );

				// Initialise the main context
				OneTimeContextInitialization();
				if ( this._currentContext != null )
				{
					this._currentContext.Initialized = true;
				}
			}

			if ( window.DepthBufferPool != PoolId.NoDepth )
			{
				//Unlike D3D9, OGL doesn't allow sharing the main depth buffer, so keep them separate.
				//Only Copy does, but Copy means only one depth buffer...
				var windowContext = (GLContext)window[ "GLCONTEXT" ];

				var depthBuffer = new GLDepthBuffer( PoolId.Default, this, windowContext, null, null, window.Width, window.Height,
													 window.FSAA, 0, true );

				depthBufferPool[ depthBuffer.PoolId ].Add( depthBuffer );

				window.AttachDepthBuffer( depthBuffer );
			}
			return window;
		}
示例#40
0
		public virtual MovableObject CreateMovableObject( string typeName, NamedParameterList para )
		{
			string name = this.movableNameGenerator.GetNextUniqueName();
			return CreateMovableObject( name, typeName, para );
		}
示例#41
0
		protected override MovableObject _createInstance( string name, NamedParameterList param )
		{
			int maxElements = 20;
			int numberOfChains = 1;
			bool useTextureCoords = true;
			bool useVertexColors = true;
			bool isDynamic = true;

			// optional parameters
			if ( param != null )
			{
				if ( param.ContainsKey( "maxElements" ) )
				{
					maxElements = Convert.ToInt32( param[ "maxElements" ] );
				}
				if ( param.ContainsKey( "numberOfChains" ) )
				{
					numberOfChains = Convert.ToInt32( param[ "numberOfChains" ] );
				}
				if ( param.ContainsKey( "useTextureCoords" ) )
				{
					useTextureCoords = Convert.ToBoolean( param[ "useTextureCoords" ] );
				}
				if ( param.ContainsKey( "useVertexColours" ) )
				{
					useVertexColors = Convert.ToBoolean( param[ "useVertexColours" ] );
				}
				else if ( param.ContainsKey( "useVertexColors" ) )
				{
					useVertexColors = Convert.ToBoolean( param[ "useVertexColors" ] );
				}
				if ( param.ContainsKey( "isDynamic" ) )
				{
					isDynamic = Convert.ToBoolean( param[ "isDynamic" ] );
				}
			}

			return new BillboardChain( name, maxElements, numberOfChains, useTextureCoords, useVertexColors, isDynamic );
		}
示例#42
0
        public override RenderWindow NewWindow(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            LogManager.Instance.Write("\tGLSupport NewWindow called");

            var window = new AndroidWindow(this);

            window.Create(name, width, height, fullScreen, miscParams);

            return(window);
        }
示例#43
0
        public override RenderWindow NewWindow(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
        {
            Win32Window window = new Win32Window(this);

            window.Create(name, width, height, fullScreen, miscParams);

            return window;
        }
示例#44
0
		/// <summary>
		///		Creates a specific instance of a render window.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="width"></param>
		/// <param name="height"></param>
		/// <param name="colorDepth"></param>
		/// <param name="fullScreen"></param>
		/// <param name="left"></param>
		/// <param name="top"></param>
		/// <param name="depthBuffer"></param>
		/// <param name="parent"></param>
		/// <param name="vsync"></param>
		/// <returns></returns>
		public abstract RenderWindow NewWindow( string name, int width, int height, bool fullScreen, NamedParameterList miscParams );
示例#45
0
 public virtual RenderWindow NewWindow(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
 {
     //Meant to be overridden
     throw new NotImplementedException();
 }
示例#46
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="autoCreateWindow"></param>
		/// <param name="renderSystem"></param>
		/// <param name="windowTitle"></param>
		/// <returns></returns>
		public override RenderWindow CreateWindow( bool autoCreateWindow, GLESRenderSystem renderSystem, string windowTitle )
		{
			RenderWindow window = null;
			if ( autoCreateWindow )
			{
				NamedParameterList miscParams = new NamedParameterList();
				bool fullScreen = false;
				int width = 640;
				int height = 480;
				if ( _options[ "Full Screen" ] != null )
				{
					fullScreen = _options[ "Full Screen" ].Value == "Yes";
				}
				if ( _options[ "Display Frequency" ] != null )
				{
					miscParams[ "displayFrequency" ] = _options[ "Display Frequency" ].Value;
				}
				if ( _options[ "Video Mode" ] != null )
				{
					string val = _options[ "Video Mode" ].Value;
					int xIndex = val.IndexOf( "x" );

					if ( xIndex != -1 )
					{
						width = int.Parse( val.Substring( 0, xIndex ) );
						height = int.Parse( val.Substring( xIndex + 1 ) );
					}
				}
				if ( _options[ "FSAA" ] != null )
				{
					miscParams[ "FSAA" ] = _options[ "FSAA" ].Value;
				}

				window = renderSystem.CreateRenderWindow( windowTitle, width, height, fullScreen, miscParams );
			}
			return window;
		}
示例#47
0
		public override RenderWindow NewWindow( string name, int width, int height, bool fullScreen, NamedParameterList miscParams )
		{
			throw new Exception( "The method or operation is not implemented." );
		}
示例#48
0
 public override RenderWindow NewWindow(string name, int width, int height, bool fullScreen, NamedParameterList miscParams)
 {
     throw new Exception("The method or operation is not implemented.");
 }
示例#49
0
		protected override MovableObject _createInstance( string name, NamedParameterList param )
		{
			Light light = new Light( name );

			if ( param != null )
			{
				// Setting the light type first before any property specific to a certain light type
				if ( param.ContainsKey( "type" ) )
				{
					switch ( param[ "type" ].ToString() )
					{
						case "point":
							light.Type = LightType.Point;
							break;
						case "directional":
							light.Type = LightType.Directional;
							break;
						case "spot":
						case "spotlight":
							light.Type = LightType.Spotlight;
							break;
						default:
							throw new AxiomException( "Invalid light type '" + param[ "type" ] + "'." );
					}
				}

				// Common properties
				if ( param.ContainsKey( "position" ) )
				{
					light.Position = Vector3.Parse( param[ "position" ].ToString() );
				}

				if ( param.ContainsKey( "direction" ) )
				{
					light.Direction = Vector3.Parse( param[ "direction" ].ToString() );
				}

				if ( param.ContainsKey( "diffuseColour" ) )
				{
					light.Diffuse = ColorEx.Parse_0_255_String( param[ "diffuseColour" ].ToString() );
				}

				if ( param.ContainsKey( "specularColour" ) )
				{
					light.Specular = ColorEx.Parse_0_255_String( param[ "specularColour" ].ToString() );
				}

				if ( param.ContainsKey( "attenuation" ) )
				{
					Vector4 attenuation = Vector4.Parse( param[ "attenuation" ].ToString() );
					light.SetAttenuation( attenuation.x, attenuation.y, attenuation.z, attenuation.w );
				}

				if ( param.ContainsKey( "castShadows" ) )
				{
					light.CastShadows = Convert.ToBoolean( param[ "castShadows" ].ToString() );
				}

				if ( param.ContainsKey( "visible" ) )
				{
					light.CastShadows = Convert.ToBoolean( param[ "visible" ].ToString() );
				}
				// TODO: Add PowerScale Property to Light
				if ( param.ContainsKey( "powerScale" ) )
				{
					light.PowerScale = (float)Convert.ToDouble( param[ "powerScale" ].ToString() );
				}
				// TODO: Add ShadowFarDistance to Light
				if ( param.ContainsKey( "shadowFarDistance" ) )
				{
					light.ShadowFarDistance = (float)Convert.ToDouble( param[ "shadowFarDistance" ].ToString() );
				}

				// Spotlight properties
				if ( param.ContainsKey( "spotlightInner" ) )
				{
					light.SpotlightInnerAngle = (float)Convert.ToDouble( param[ "spotlightInner" ].ToString() );
				}

				if ( param.ContainsKey( "spotlightOuter" ) )
				{
					light.SpotlightOuterAngle = (float)Convert.ToDouble( param[ "spotlightOuter" ].ToString() );
				}

				if ( param.ContainsKey( "spotlightFalloff" ) )
				{
					light.SpotlightFalloff = (float)Convert.ToDouble( param[ "spotlightFalloff" ].ToString() );
				}
			}

			return light;
		}
示例#50
0
 public CParameters(CParameters @params)
 {
     parent        = @params.parent;
     unnamedParams = new ParameterList(this, @params.unnamedParams);
     namedParams   = new NamedParameterList(this, @params.namedParams);
 }
示例#51
0
		protected override MovableObject _createInstance( string name, NamedParameterList param )
		{
			// may have parameters
			bool externalData = false;
			int poolSize = 0;

			if ( param != null )
			{
				if ( param.ContainsKey( "poolSize" ) )
				{
					poolSize = Convert.ToInt32( param[ "poolSize" ] );
				}

				if ( param.ContainsKey( "externalData" ) )
				{
					externalData = Convert.ToBoolean( param[ "externalData" ] );
				}
			}

			BillboardSet bSet;

			if ( poolSize > 0 )
			{
				bSet = new BillboardSet( name, poolSize, externalData );
			}
			else
			{
				bSet = new BillboardSet( name, 0 );
			}

			bSet.MovableType = TypeName;

			return bSet;
		}
示例#52
0
		/// <summary>
		///		Creates a billboard set which can be uses for particles, sprites, etc.
		/// </summary>
		/// <param name="name"></param>
		/// <param name="poolSize"></param>
		/// <returns></returns>
		public virtual BillboardSet CreateBillboardSet( string name, int poolSize )
		{
			NamedParameterList param = new NamedParameterList();
			param.Add( "poolSize", poolSize.ToString() );
			return (BillboardSet)this.CreateMovableObject( name, BillboardSetFactory.TypeName, param );
		}
示例#53
0
		protected override MovableObject _createInstance( string name, NamedParameterList param )
		{
			// must have mesh parameter
			Mesh pMesh = null;
			if ( param != null )
			{
				if ( param.ContainsKey( "mesh" ) )
				{
					if ( param[ "mesh" ] is Mesh )
					{
						pMesh = (Mesh)param[ "mesh" ];
					}
					else
					{
						pMesh = MeshManager.Instance.Load( param[ "mesh" ].ToString(), ResourceGroupManager.AutoDetectResourceGroupName );
					}
				}
			}
			if ( pMesh == null )
			{
				throw new AxiomException( "'mesh' parameter required when constructing an Entity." );
			}
			var ent = new Entity( name, pMesh );
			ent.MovableType = Type;
			return ent;
		}
示例#54
0
        public override void Create(string name, int width, int height, bool isFullScreen, NamedParameterList miscParams)
        {
            if (_hWindow != IntPtr.Zero)
            {
                dispose(true);
            }

            _hWindow          = IntPtr.Zero;
            this.name         = name;
            this.IsFullScreen = isFullScreen;
            this._isClosed    = false;

            // load window defaults
            this.left              = this.top = -1; // centered
            this.width             = width;
            this.height            = height;
            this._displayFrequency = 0;
            this.isDepthBuffered   = true;
            this.colorDepth        = IsFullScreen ? 32 : 16;

            IntPtr parentHwnd = IntPtr.Zero;
            string title      = name;
            bool   vsync      = false;
            int    fsaa       = 0;
            string border     = "";
            bool   outerSize  = false;

            #region Parameter Handling
            if (miscParams != null)
            {
                foreach (KeyValuePair <string, object> entry in miscParams)
                {
                    switch (entry.Key)
                    {
                    case "title":
                        title = entry.Value.ToString();
                        break;

                    case "left":
                        left = Int32.Parse(entry.Value.ToString());
                        break;

                    case "top":
                        top = Int32.Parse(entry.Value.ToString());
                        break;

                    case "depthBuffer":
                        isDepthBuffered = bool.Parse(entry.Value.ToString());
                        break;

                    case "vsync":
                        vsync = entry.Value.ToString() == "Yes" ? true : false;
                        break;

                    case "fsaa":
                        fsaa = Int32.Parse(entry.Value.ToString());
                        break;

                    case "externalWindowHandle":
                        _hWindow = (IntPtr)entry.Value;
                        if (_hWindow != IntPtr.Zero)
                        {
                            _isExternal  = true;
                            IsFullScreen = false;
                        }
                        break;

                    case "externalGLControl":
                        break;

                    case "border":
                        border = ((string)miscParams["border"]).ToLower();
                        break;

                    case "outerDimensions":
                        break;

                    case "displayFrequency":
                        if (IsFullScreen)
                        {
                            _displayFrequency = Int32.Parse(entry.Value.ToString());
                        }
                        break;

                    case "colorDepth":
                        if (IsFullScreen)
                        {
                            colorDepth = Int32.Parse(entry.Value.ToString());
                        }
                        break;

                    case "parentWindowHandle":
                        if (!IsFullScreen)
                        {
                            parentHwnd = (IntPtr)entry.Value;
                        }
                        break;

                    default:
                        break;
                    }
                }
            }
            #endregion Parameter Handling

            if (!_isExternal)
            {
                DefaultForm form = new DefaultForm();

                form.ClientSize    = new System.Drawing.Size(width, height);
                form.MaximizeBox   = false;
                form.MinimizeBox   = false;
                form.StartPosition = SWF.FormStartPosition.CenterScreen;

                if (IsFullScreen)
                {
                    // Set the display to the desired resolution
                    Gdi.DEVMODE screenSettings = new Gdi.DEVMODE();
                    screenSettings.dmSize       = (short)Marshal.SizeOf(screenSettings);
                    screenSettings.dmPelsWidth  = width;                                            // Selected Screen Width
                    screenSettings.dmPelsHeight = height;                                           // Selected Screen Height
                    screenSettings.dmBitsPerPel = ColorDepth;                                       // Selected Bits Per Pixel
                    screenSettings.dmFields     = Gdi.DM_BITSPERPEL | Gdi.DM_PELSWIDTH | Gdi.DM_PELSHEIGHT;

                    // Try To Set Selected Mode And Get Results.  NOTE: CDS_FULLSCREEN Gets Rid Of Start Bar.
                    int result = User.ChangeDisplaySettings(ref screenSettings, User.CDS_FULLSCREEN);

                    if (result != User.DISP_CHANGE_SUCCESSFUL)
                    {
                        throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Unable to change user display settings.");
                    }

                    // Adjust form to size the screen
                    form.Top             = 0;
                    form.Left            = 0;
                    form.FormBorderStyle = SWF.FormBorderStyle.None;
                    form.WindowState     = SWF.FormWindowState.Maximized;
#if !DEBUG
                    form.TopMost  = true;
                    form.TopLevel = true;
#endif
                }
                else
                {
                    if (parentHwnd != IntPtr.Zero)
                    {
                        form.Owner = (SWF.Form)SWF.Control.FromHandle(parentHwnd);
                    }
                    else
                    {
                        if (border == "none")
                        {
                            form.FormBorderStyle = SWF.FormBorderStyle.None;
                        }
                        else if (border == "fixed")
                        {
                            form.FormBorderStyle = SWF.FormBorderStyle.FixedSingle;
                            form.MaximizeBox     = false;
                        }
                    }

                    form.Top  = top;
                    form.Left = left;
                    //form.FormBorderStyle = SWF.FormBorderStyle.FixedSingle;
                    form.WindowState = SWF.FormWindowState.Normal;
                    form.Text        = title;
                }

                WindowEventMonitor.Instance.RegisterWindow(this);

                form.RenderWindow = this;
                _hWindow          = form.Handle;
                form.Show();
            }

            IntPtr old_hdc     = Wgl.wglGetCurrentDC();
            IntPtr old_context = Wgl.wglGetCurrentContext();

            SWF.Control ctrl = SWF.Form.FromHandle(_hWindow);
            //Form frm = (Form)ctrl.TopLevelControl;
            this.top    = ctrl.Top;
            this.left   = ctrl.Left;
            this.width  = ctrl.ClientRectangle.Width;
            this.height = ctrl.ClientRectangle.Height;

            _hDeviceContext = User.GetDC(_hWindow);

            // Do not change vsync if the external window has the OpenGL control
            if (!_isExternalGLControl)
            {
                if (!_glSupport.SelectPixelFormat(_hDeviceContext, ColorDepth, fsaa))
                {
                    if (fsaa == 0)
                    {
                        throw new Exception("selectPixelFormat failed");
                    }

                    LogManager.Instance.Write("FSAA level not supported, falling back");
                    if (!_glSupport.SelectPixelFormat(_hDeviceContext, ColorDepth, 0))
                    {
                        throw new Exception("selectPixelFormat failed");
                    }
                }
            }

            // attempt to get the rendering context
            _hRenderingContext = Wgl.wglCreateContext(_hDeviceContext);

            if (_hRenderingContext == IntPtr.Zero)
            {
                throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Unable to create a GL rendering context.");
            }

            if (!Wgl.wglMakeCurrent(_hDeviceContext, _hRenderingContext))
            {
                throw new System.ComponentModel.Win32Exception(Marshal.GetLastWin32Error(), "Unable to activate the GL rendering context.");
            }

            // Do not change vsync if the external window has the OpenGL control
            if (!_isExternalGLControl)
            {
                // Don't use wglew as if this is the first window, we won't have initialised yet
                //IntPtr wglSwapIntervalEXT = Wgl.wglGetProcAddress( "wglSwapIntervalEXT" );
                //if ( wglSwapIntervalEXT != IntPtr.Zero )
                //Wgl.wglSwapIntervalEXT( wglSwapIntervalEXT, vsync );
                if (Wgl.IsExtensionSupported("wglSwapIntervalEXT"))
                {
                    Wgl.wglSwapIntervalEXT(vsync ? 1 : 0);                       // Tao 2.0
                }
            }

            if (old_context != IntPtr.Zero)
            {
                // Restore old context
                if (!Wgl.wglMakeCurrent(old_hdc, old_context))
                {
                    throw new Exception("wglMakeCurrent() failed");
                }

                // Share lists with old context
                if (!Wgl.wglShareLists(old_context, _hRenderingContext))
                {
                    throw new Exception("wglShareLists() failed");
                }
            }

            // Create RenderSystem context
            _glContext = new Win32Context(_hDeviceContext, _hRenderingContext);

            // make this window active
            this.IsActive = true;
        }
示例#55
0
		public MovableObject CreateMovableObject( string name, string typeName, NamedParameterList para )
		{
			// Nasty hack to make generalized Camera functions work without breaking add-on SMs
			if ( typeName == "Camera" )
			{
				return this.CreateCamera( name );
			}

			// Check for duplicate names

			MovableObjectCollection objectMap = this.GetMovableObjectCollection( typeName );

			if ( objectMap.ContainsKey( name ) )
			{
				throw new AxiomException( "An object with the name " + name + " already exists in the list." );
			}

			MovableObjectFactory factory = Root.Instance.GetMovableObjectFactory( typeName );

			MovableObject newObj = factory.CreateInstance( name, this, para );
			objectMap.Add( name, newObj );
			return newObj;
		}
示例#56
0
		public override void Create( string name, int width, int height, bool fullScreen, NamedParameterList miscParams )
		{
			SWF.Control parentHWnd = null;
			SWF.Control externalHWnd = null;
			this._fsaaType = D3D9.MultisampleType.None;
			this._fsaaQuality = 0;
			fsaa = 0;
			this._vSync = false;
			this._vSyncInterval = 1;
			var title = name;
			var colorDepth = 32;
			var left = int.MaxValue; // Defaults to screen center
			var top = int.MaxValue; // Defaults to screen center
			var depthBuffer = true;
			var border = "";
			var outerSize = false;
			var enableDoubleClick = false;
			this._useNVPerfHUD = false;
			//var fsaaSamples = 0; //Not used, even in Ogre
			var fsaaHint = string.Empty;
			var monitorIndex = -1;

			if ( miscParams != null )
			{
				object opt;

				// left (x)
				if ( miscParams.TryGetValue( "left", out opt ) )
				{
					left = Int32.Parse( opt.ToString() );
				}

				// top (y)
				if ( miscParams.TryGetValue( "top", out opt ) )
				{
					top = Int32.Parse( opt.ToString() );
				}

				// Window title
				if ( miscParams.TryGetValue( "title", out opt ) )
				{
					title = (string)opt;
				}

				// parentWindowHandle		-> parentHWnd
				if ( miscParams.TryGetValue( "parentWindowHandle", out opt ) )
				{
					parentHWnd = GetControlFromParameter( opt );
				}

				// externalWindowHandle		-> externalHWnd
				if ( miscParams.TryGetValue( "externalWindowHandle", out opt ) )
				{
					externalHWnd = GetControlFromParameter(opt);
				}

				// vsync	[parseBool]
				if ( miscParams.TryGetValue( "vsync", out opt ) )
				{
					this._vSync = bool.Parse( opt.ToString() );
				}

				// vsyncInterval	[parseUnsignedInt]
				if ( miscParams.TryGetValue( "vsyncInterval", out opt ) )
				{
					this._vSyncInterval = Int32.Parse( opt.ToString() );
				}

				// displayFrequency
				if ( miscParams.TryGetValue( "displayFrequency", out opt ) )
				{
					this._displayFrequency = Int32.Parse( opt.ToString() );
				}

				// colorDepth
				if ( miscParams.TryGetValue( "colorDepth", out opt ) )
				{
					colorDepth = Int32.Parse( opt.ToString() );
				}

				// depthBuffer [parseBool]
				if ( miscParams.TryGetValue( "depthBuffer", out opt ) )
				{
					depthBuffer = bool.Parse( opt.ToString() );
				}

				//FSAA settings

				// FSAA type
				if ( miscParams.TryGetValue( "FSAA", out opt ) )
				{
					this._fsaaType = (D3D9.MultisampleType)opt;
				}

				if ( miscParams.TryGetValue( "FSAAHint", out opt ) )
				{
					fsaaHint = (string)opt;
				}

				// window border style
				if ( miscParams.TryGetValue( "border", out opt ) )
				{
					border = ( (string)opt ).ToLower();
				}

				// set outer dimensions?
				if ( miscParams.TryGetValue( "outerDimensions", out opt ) )
				{
					outerSize = bool.Parse( opt.ToString() );
				}

				// NV perf HUD?
				if ( miscParams.TryGetValue( "useNVPerfHUD", out opt ) )
				{
					this._useNVPerfHUD = bool.Parse( opt.ToString() );
				}

				// sRGB?
				if ( miscParams.TryGetValue( "gamma", out opt ) )
				{
					hwGamma = bool.Parse( opt.ToString() );
				}

				// monitor index
				if ( miscParams.TryGetValue( "monitorIndex", out opt ) )
				{
					monitorIndex = Int32.Parse( opt.ToString() );
				}

				// enable double click messages
				if ( miscParams.TryGetValue( "enableDoubleClick", out opt ) )
				{
					enableDoubleClick = bool.Parse( opt.ToString() );
				}
			}

			// Destroy current window if any
			if ( this._windowHandle != null )
			{
				Destroy();
			}

			if ( externalHWnd == null )
			{
				var dwStyle = WindowStyles.Visible | WindowStyles.ClipChildren;
				var dwStyleEx = (WindowsExtendedStyle)0;
				var monitorHandle = IntPtr.Zero;

				// If we specified which adapter we want to use - find it's monitor.
				if ( monitorIndex != -1 )
				{
					var direct3D9 = D3D9RenderSystem.Direct3D9;

					for ( var i = 0; i < direct3D9.AdapterCount; ++i )
					{
						if ( i != monitorIndex )
						{
							continue;
						}

						monitorHandle = direct3D9.GetAdapterMonitor( i );
						break;
					}
				}

				// If we didn't specified the adapter index, or if it didn't find it
				if ( monitorHandle == IntPtr.Zero )
				{
					// Fill in anchor point.
					var windowAnchorPoint = new Point( left, top );

					// Get the nearest monitor to this window.
					monitorHandle = ScreenHelper.GetHandle( windowAnchorPoint );
				}

				// Get the target monitor info
				var monitorInfo = ScreenHelper.FromHandle( monitorHandle );

				var winWidth = width;
				var winHeight = height;

				// No specified top left -> Center the window in the middle of the monitor
				if ( left == int.MaxValue || top == int.MaxValue )
				{
					var screenw = monitorInfo.WorkingArea.Right - monitorInfo.WorkingArea.Left;
					var screenh = monitorInfo.WorkingArea.Bottom - monitorInfo.WorkingArea.Top;

					// clamp window dimensions to screen size
					var outerw = ( winWidth < screenw ) ? winWidth : screenw;
					var outerh = ( winHeight < screenh ) ? winHeight : screenh;

					if ( left == int.MaxValue )
					{
						left = monitorInfo.WorkingArea.Left + ( screenw - outerw )/2;
					}
					else if ( monitorIndex != -1 )
					{
						left += monitorInfo.WorkingArea.Left;
					}

					if ( top == int.MaxValue )
					{
						top = monitorInfo.WorkingArea.Top + ( screenh - outerh )/2;
					}
					else if ( monitorIndex != -1 )
					{
						top += monitorInfo.WorkingArea.Top;
					}
				}
				else if ( monitorIndex != -1 )
				{
					left += monitorInfo.WorkingArea.Left;
					top += monitorInfo.WorkingArea.Top;
				}

				this.width = this._desiredWidth = width;
				this.height = this._desiredHeight = height;
				this.top = top;
				this.left = left;

				if ( fullScreen )
				{
					dwStyleEx |= WindowsExtendedStyle.TopMost;
					dwStyle |= WindowStyles.Popup;
					this.top = monitorInfo.Bounds.Top;
					this.left = monitorInfo.Bounds.Left;
				}
				else
				{
					if ( parentHWnd != null )
					{
						dwStyle |= WindowStyles.Child;
					}
					else
					{
						if ( border == "none" )
						{
							dwStyle |= WindowStyles.Popup;
						}
						else if ( border == "fixed" )
						{
							dwStyle |= WindowStyles.Overlapped | WindowStyles.Border | WindowStyles.Caption |
									   WindowStyles.SystemMenu | WindowStyles.MinimizeBox;
						}
						else
						{
							dwStyle |= WindowStyles.OverlappedWindow;
						}
					}

					AdjustWindow( width, height, dwStyle, out winWidth, out winHeight );

					if ( !outerSize )
					{
						// Calculate window dimensions required
						// to get the requested client area
						var rc = new RECT( 0, 0, this.width, this.height );
						AdjustWindowRect( ref rc, dwStyle, false );
						this.width = rc.Right - rc.Left;
						this.height = rc.Bottom - rc.Top;

						// Clamp window rect to the nearest display monitor.
						if ( this.left < monitorInfo.WorkingArea.Left )
						{
							this.left = monitorInfo.WorkingArea.Left;
						}

						if ( this.top < monitorInfo.WorkingArea.Top )
						{
							this.top = monitorInfo.WorkingArea.Top;
						}

						if ( winWidth > monitorInfo.WorkingArea.Right - this.left )
						{
							winWidth = monitorInfo.WorkingArea.Right - this.left;
						}

						if ( winHeight > monitorInfo.WorkingArea.Bottom - this.top )
						{
							winHeight = monitorInfo.WorkingArea.Bottom - this.top;
						}
					}
				}

				WindowClassStyle classStyle = 0;
				if ( enableDoubleClick )
				{
					classStyle |= WindowClassStyle.DoubleClicks;
				}

				// Create our main window
				this._isExternal = false;
				this._windowHandle = new DefaultForm( classStyle, dwStyleEx, title, dwStyle, this.left, this.top, winWidth, winHeight, parentHWnd )
									 {
										 RenderWindow = this
									 };
				this._style = dwStyle;
				WindowEventMonitor.Instance.RegisterWindow( this );
			}
			else
			{
				this._windowHandle = externalHWnd;
				this._isExternal = true;
			}

			// top and left represent outer window coordinates
			var rc2 = new System.Drawing.Rectangle( this._windowHandle.Location, this._windowHandle.Size );

			this.top = rc2.Top;
			this.left = rc2.Left;

			// width and height represent interior drawable area
			rc2 = this._windowHandle.ClientRectangle;

			this.width = rc2.Right;
			this.height = rc2.Bottom;

			this.name = name;
			isDepthBuffered = depthBuffer;
			isFullScreen = fullScreen;
			this.colorDepth = colorDepth;

			LogManager.Instance.Write( "D3D9 : Created D3D9 Rendering Window '{0}' : {1}x{2}, {3}bpp", this.name, this.width, this.height, ColorDepth );

			active = true;
			this._isClosed = false;
		}
示例#57
0
		/// <summary>
		///		Create an Entity (instance of a discrete mesh).
		/// </summary>
		/// <param name="name">The name to be given to the entity (must be unique).</param>
		/// <param name="meshName">The name of the mesh to load.  Will be loaded if not already.</param>
		/// <returns></returns>
		public virtual Entity CreateEntity( string name, string meshName )
		{
			NamedParameterList param = new NamedParameterList();
			param.Add( "mesh", meshName );
			return (Entity)this.CreateMovableObject( name, EntityFactory.TypeName, param );
		}
示例#58
0
        public override RenderWindow CreateWindow(bool autoCreateWindow, GLRenderSystem renderSystem, string windowTitle)
        {
            RenderWindow autoWindow = null;

            if (autoCreateWindow)
            {
                int  width      = 640;
                int  height     = 480;
                int  bpp        = 32;
                bool fullscreen = false;

                ConfigOption optVM = ConfigOptions["Video Mode"];
                string       vm    = optVM.Value;
                int          pos   = vm.IndexOf('x');
                if (pos == -1)
                {
                    throw new Exception("Invalid Video Mode provided");
                }
                width  = int.Parse(vm.Substring(0, vm.IndexOf("x")));
                height = int.Parse(vm.Substring(vm.IndexOf("x") + 1));

                fullscreen = (ConfigOptions["Full Screen"].Value == "Yes");

                NamedParameterList miscParams = new NamedParameterList();
                ConfigOption       opt;

                opt = ConfigOptions["Color Depth"];
                if (opt != null)
                {
                    miscParams.Add("colorDepth", opt.Value);
                }

                opt = ConfigOptions["VSync"];
                if (opt != null)
                {
                    miscParams.Add("vsync", opt.Value);
                    if (Wgl.IsExtensionSupported("wglSwapIntervalEXT"))
                    {
                        Wgl.wglSwapIntervalEXT(StringConverter.ParseBool(opt.Value) ? 1 : 0);
                    }
                }

                opt = ConfigOptions["FSAA"];
                if (opt != null)
                {
                    miscParams.Add("fsaa", opt.Value);
                }

                // create a default form to use for a rendering target
                //DefaultForm form = CreateDefaultForm( windowTitle, 0, 0, width, height, fullscreen );

                // create the window with the default form as the target
                autoWindow = renderSystem.CreateRenderWindow(windowTitle, width, height, fullscreen, miscParams);

                // set the default form's renderwindow so it can access it internally
                //form.RenderWindow = autoWindow;

                // show the window
                //form.Show();
            }

            return(autoWindow);
        }
示例#59
0
 protected override MovableObject _createInstance(string name, NamedParameterList para)
 {
     return(new PCZLight(name));
 }
示例#60
0
 protected abstract MovableObject _createInstance(string name, NamedParameterList param);