/// <summary>
        /// 
        /// </summary>
        /// <param name="name"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="colorDepth"></param>
        /// <param name="isFullScreen"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="depthBuffer"></param>height
        /// <param name="miscParams"></param>
        public override void Create(string name, int width, int height, bool isFullScreen, params object[] miscParams)
        {
            Control parentWindow = null;
            Control externalWindow = null;
             		    fsaaType = MultiSampleType.None;
            fsaaQuality = 0;
            isVSync = false;
            string title = name;
            int colorDepth = 32;
            int left = -1;
            int top = -1;
            bool depthBuffer = true;
            // Parameters that would have been set in the params list, but are not used
            // border, outerSize
            useNVPerfHUD = false;
            multiThreaded = false;

            Debug.Assert(miscParams.Length % 2 == 0);
            int index = 0;
            while (index < miscParams.Length) {
                string key = (string)miscParams[index++];
                object value = miscParams[index++];
                switch (key) {
                    case "left":
                        left = (int)value;
                        break;
                    case "top":
                        top = (int)value;
                        break;
                    case "title":
                        title = (string)value;
                        break;
                    case "parentWindow":
                        parentWindow = (Control)value;
                        break;
                    case "externalWindow":
                        externalWindow = (Control)value;
                        break;
                    case "vsync":
                        isVSync = (bool)value;
                        break;
                    case "displayFrequency":
                        displayFrequency = (int)value;
                        break;
                    case "colorDepth":
                    case "colourDepth":
                        colorDepth = (int)value;
                        break;
                    case "depthBuffer":
                        depthBuffer = (bool)value;
                        break;
                    case "FSAA":
                        fsaaType = (MultiSampleType)value;
                        break;
                    case "FSAAQuality":
                        fsaaQuality = (int)value;
                        break;
                    case "useNVPerfHUD":
                        useNVPerfHUD = (bool)value;
                        break;
                    case "multiThreaded":
                        multiThreaded = (bool)value;
                        break;
                    case "initialLoadBitmap":
                        initialLoadBitmap = (string)value;
                        break;
                    case "border":
                    case "outerDimensions":
                    default:
                        log.Warn("Option not yet implemented");
                        break;
                }
            }

            if (windowHandle != null)
                Destroy();

            if (externalWindow == null) {
                this.width = width;
                this.height = height;
                this.top = top;
                this.left = left;
                FormBorderStyle borderStyle = FormBorderStyle.None;
                FormWindowState windowState = FormWindowState.Normal;
                if (!isFullScreen) {
                    // If RenderSystem.AllowResize is true, put a
                    // resize border on the window.
                    borderStyle = (Root.Instance.RenderSystem.AllowResize ? FormBorderStyle.Sizable : FormBorderStyle.FixedSingle);
                    windowState = FormWindowState.Normal;
                } else {
                    borderStyle = FormBorderStyle.None;
                    windowState = FormWindowState.Maximized;
                    this.top = 0;
                    this.left = 0;
                }
                isExternal = false;
                form = new DefaultForm(!isFullScreen, initialLoadBitmap);
                // Set these two to false, or else windows get created
                // with different dimensions that requesting in Width
                // and Height!
                log.InfoFormat("Initial form settings: AutoSize: {0}; AutoScale: {1}", form.AutoSize, form.AutoScaleMode);
                form.AutoSize = false;
                form.AutoScaleMode = AutoScaleMode.None;
                form.ClientSize = new System.Drawing.Size(width, height);
                // TODO: I should support the maximize box once I get resize working
                // form.MaximizeBox = true;
                form.MaximizeBox = false;
                form.MinimizeBox = true;
                form.Top = this.top;
                form.Left = this.left;
                form.FormBorderStyle = borderStyle;
                form.WindowState = windowState;
                form.Text = title;
                form.StartPosition = FormStartPosition.CenterScreen;
                form.BringToFront();
                if (isFullScreen) {
                    form.TopMost = true;
                    form.TopLevel = true;
                    form.Width = width;
                    form.Height = height;
                }
                // form.Target.Visible = false;
                form.Show();
                // set the default form's renderwindow so it can access it internally
                form.RenderWindow = this;
                form.Activate();
                windowHandle = form.Target;
            } else {
                windowHandle = externalWindow;
                isExternal = true;

                this.top = windowHandle.Top;
                this.left = windowHandle.Left;
                System.Drawing.Rectangle rect = windowHandle.ClientRectangle;
                this.width = rect.Width;
                this.height = rect.Height;
            }
            windowHandle.Resize += this.OnExternalWindowEvent;
            windowHandle.Move += this.OnExternalWindowEvent;

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

            CreateD3DResources();
            isActive = true;

            // FIXME: These lines were not in Ogre, but are in Axiom.
            //D3D.Device device = driver.Device;
            // device.DeviceReset += new EventHandler(OnResetDevice);
            //this.OnResetDevice(device, null);
        }
Beispiel #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="width"></param>
        /// <param name="height"></param>
        /// <param name="colorDepth"></param>
        /// <param name="isFullScreen"></param>
        /// <param name="left"></param>
        /// <param name="top"></param>
        /// <param name="depthBuffer"></param>height
        /// <param name="miscParams"></param>
        public override void Create(string name, int width, int height, bool isFullScreen, params object[] miscParams)
        {
            Control parentWindow   = null;
            Control externalWindow = null;

            fsaaType    = MultiSampleType.None;
            fsaaQuality = 0;
            isVSync     = false;
            string title       = name;
            int    colorDepth  = 32;
            int    left        = -1;
            int    top         = -1;
            bool   depthBuffer = true;

            // Parameters that would have been set in the params list, but are not used
            // border, outerSize
            useNVPerfHUD  = false;
            multiThreaded = false;

            Debug.Assert(miscParams.Length % 2 == 0);
            int index = 0;

            while (index < miscParams.Length)
            {
                string key   = (string)miscParams[index++];
                object value = miscParams[index++];
                switch (key)
                {
                case "left":
                    left = (int)value;
                    break;

                case "top":
                    top = (int)value;
                    break;

                case "title":
                    title = (string)value;
                    break;

                case "parentWindow":
                    parentWindow = (Control)value;
                    break;

                case "externalWindow":
                    externalWindow = (Control)value;
                    break;

                case "vsync":
                    isVSync = (bool)value;
                    break;

                case "displayFrequency":
                    displayFrequency = (int)value;
                    break;

                case "colorDepth":
                case "colourDepth":
                    colorDepth = (int)value;
                    break;

                case "depthBuffer":
                    depthBuffer = (bool)value;
                    break;

                case "FSAA":
                    fsaaType = (MultiSampleType)value;
                    break;

                case "FSAAQuality":
                    fsaaQuality = (int)value;
                    break;

                case "useNVPerfHUD":
                    useNVPerfHUD = (bool)value;
                    break;

                case "multiThreaded":
                    multiThreaded = (bool)value;
                    break;

                case "initialLoadBitmap":
                    initialLoadBitmap = (string)value;
                    break;

                case "border":
                case "outerDimensions":
                default:
                    log.Warn("Option not yet implemented");
                    break;
                }
            }


            if (windowHandle != null)
            {
                Destroy();
            }

            if (externalWindow == null)
            {
                this.width  = width;
                this.height = height;
                this.top    = top;
                this.left   = left;
                FormBorderStyle borderStyle = FormBorderStyle.None;
                FormWindowState windowState = FormWindowState.Normal;
                if (!isFullScreen)
                {
                    // If RenderSystem.AllowResize is true, put a
                    // resize border on the window.
                    borderStyle = (Root.Instance.RenderSystem.AllowResize ? FormBorderStyle.Sizable : FormBorderStyle.FixedSingle);
                    windowState = FormWindowState.Normal;
                }
                else
                {
                    borderStyle = FormBorderStyle.None;
                    windowState = FormWindowState.Maximized;
                    this.top    = 0;
                    this.left   = 0;
                }
                isExternal = false;
                form       = new DefaultForm(!isFullScreen, initialLoadBitmap);
                // Set these two to false, or else windows get created
                // with different dimensions that requesting in Width
                // and Height!
                log.InfoFormat("Initial form settings: AutoSize: {0}; AutoScale: {1}", form.AutoSize, form.AutoScaleMode);
                form.AutoSize      = false;
                form.AutoScaleMode = AutoScaleMode.None;
                form.ClientSize    = new System.Drawing.Size(width, height);
                // TODO: I should support the maximize box once I get resize working
                // form.MaximizeBox = true;
                form.MaximizeBox     = false;
                form.MinimizeBox     = true;
                form.Top             = this.top;
                form.Left            = this.left;
                form.FormBorderStyle = borderStyle;
                form.WindowState     = windowState;
                form.Text            = title;
                form.StartPosition   = FormStartPosition.CenterScreen;
                form.BringToFront();
                if (isFullScreen)
                {
                    form.TopMost  = true;
                    form.TopLevel = true;
                    form.Width    = width;
                    form.Height   = height;
                }
                // form.Target.Visible = false;
                form.Show();
                // set the default form's renderwindow so it can access it internally
                form.RenderWindow = this;
                form.Activate();
                windowHandle = form.Target;
            }
            else
            {
                windowHandle = externalWindow;
                isExternal   = true;

                this.top  = windowHandle.Top;
                this.left = windowHandle.Left;
                System.Drawing.Rectangle rect = windowHandle.ClientRectangle;
                this.width  = rect.Width;
                this.height = rect.Height;
            }
            windowHandle.Resize += this.OnExternalWindowEvent;
            windowHandle.Move   += this.OnExternalWindowEvent;

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

            CreateD3DResources();
            isActive = true;

            // FIXME: These lines were not in Ogre, but are in Axiom.
            //D3D.Device device = driver.Device;
            // device.DeviceReset += new EventHandler(OnResetDevice);
            //this.OnResetDevice(device, null);
        }