Example #1
0
        public GL_GameWindow(CreateWindowParams windowParams)
        {
            mCreatePosition = windowParams.WindowPosition;

            if (string.IsNullOrEmpty(windowParams.IconFile) == false)
            {
                mIcon = new System.Drawing.Icon(windowParams.IconFile);
            }
            else
            {
                mIcon = AgateLib.WinForms.FormUtil.AgateLibIcon;
            }

            mTitle       = windowParams.Title;
            mWidth       = windowParams.Width;
            mHeight      = windowParams.Height;
            mAllowResize = windowParams.IsResizable;
            mHasFrame    = windowParams.HasFrame;

            if (windowParams.IsFullScreen)
            {
                CreateFullScreenDisplay();
            }
            else
            {
                CreateWindowedDisplay();
            }

            mDisplay = Display.Impl as GL_Display;
            mDisplay.InitializeGL();

            mDisplay.ProcessEventsEvent += new EventHandler(mDisplay_ProcessEventsEvent);
        }
Example #2
0
        public GL_DisplayControl(CreateWindowParams windowParams)
        {
            mChoosePosition = windowParams.WindowPosition;

            if (windowParams.RenderToControl)
            {
                if (typeof(Control).IsAssignableFrom(windowParams.RenderTarget.GetType()) == false)
                {
                    throw new AgateException(string.Format("The specified render target is of type {0}, " +
                                                           "which does not derive from System.Windows.Forms.Control.", windowParams.RenderTarget.GetType().Name));
                }

                mRenderTarget = (Control)windowParams.RenderTarget;

                if (mRenderTarget.TopLevelControl == null)
                {
                    throw new ArgumentException("The specified render target has not been added to a Form yet.  " +
                                                "Check to make sure that you are creating the DisplayWindow after all controls are added " +
                                                "to the Form.  Do not create a DisplayWindow in a constructor for a UserControl, for example.");
                }

                mChooseFullscreen = false;
                mChooseWidth      = mRenderTarget.ClientSize.Width;
                mChooseHeight     = mRenderTarget.ClientSize.Height;

                mDisplay = Display.Impl as GL_Display;

                CreateContext();

                mDisplay.InitializeGL();

                AttachEvents();
            }
            else
            {
                if (string.IsNullOrEmpty(windowParams.IconFile) == false)
                {
                    mIcon = new Drawing.Icon(windowParams.IconFile);
                }

                mTitle            = windowParams.Title;
                mChooseFullscreen = windowParams.IsFullScreen;
                mChooseWidth      = windowParams.Width;
                mChooseHeight     = windowParams.Height;
                mChooseResize     = windowParams.IsResizable;
                mHasFrame         = windowParams.HasFrame;

                if (mChooseFullscreen)
                {
                    CreateFullScreenDisplay();
                }
                else
                {
                    CreateWindowedDisplay();
                }

                mDisplay = Display.Impl as GL_Display;
                mDisplay.InitializeGL();
            }

            mDisplay.ProcessEventsEvent += new EventHandler(mDisplay_ProcessEventsEvent);
        }