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_Surface(string filename)
        {
            mDisplay = Display.Impl as GL_Display;
            mState   = mDisplay.State;

            mFilename = filename;

            Load();
        }
Example #3
0
        public GL_Surface(Stream st)
        {
            mDisplay = Display.Impl as GL_Display;
            mState   = mDisplay.State;

            // Load The Bitmap
            Drawing.Bitmap sourceImage = new Drawing.Bitmap(st);

            LoadFromBitmap(sourceImage);
        }
Example #4
0
        private GL_Surface(int textureID, Rectangle sourceRect, Size textureSize)
        {
            mDisplay = Display.Impl as GL_Display;
            mState   = mDisplay.State;

            AddTextureRef(textureID);

            mSourceRect  = sourceRect;
            mTextureSize = textureSize;

            mTexCoord = GetTextureCoords(mSourceRect);
        }
Example #5
0
        public GL_Surface(Size size)
        {
            mDisplay = Display.Impl as GL_Display;
            mState   = mDisplay.State;

            mSourceRect = new Rectangle(Point.Empty, size);

            mTextureSize = new Size(NextPowerOfTwo(size.Width), NextPowerOfTwo(size.Height));

            //int[] array = new int[1];
            //GL.GenTextures(1, array);
            int textureID;

            GL.GenTextures(1, out textureID);

            AddTextureRef(textureID);

            IntPtr fake = IntPtr.Zero;

            try
            {
                fake = Marshal.AllocHGlobal(mTextureSize.Width * mTextureSize.Height * Marshal.SizeOf(typeof(int)));

                // Typical Texture Generation Using Data From The Bitmap
                GL.BindTexture(TextureTarget.Texture2D, mTextureID);
                GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba,
                              mTextureSize.Width, mTextureSize.Height, 0, OTKPixelFormat.Rgba,
                              PixelType.UnsignedByte, fake);

                mTexCoord = GetTextureCoords(mSourceRect);
            }
            finally
            {
                if (fake != IntPtr.Zero)
                {
                    Marshal.FreeHGlobal(fake);
                }
            }
        }
Example #6
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);
        }