The form on which TKWindow shall render.
Наследование: System.Windows.Forms.Form
Пример #1
0
        public TKWindow(Size displayDimensions, GlyphPalette palette, Control context)
            : base(displayDimensions, palette)
        {
            if (context == null)
            {
                form              = new TKForm();
                form.ClientSize   = displayDimensions;
                form.FormClosing += new FormClosingEventHandler(Form_FormClosing);
                form.Show();

                context = form;
            }

            context.SuspendLayout();
            Control.Dock      = DockStyle.Fill;
            Control.BackColor = Color.Blue;
            Control.VSync     = false;
            Control.Resize   += new EventHandler(Control_Resize);
            Control.Paint    += new PaintEventHandler(Control_Paint);

            Control.Location = new Point(0, 0);
            Control.Size     = context.ClientSize;

            context.Controls.Add(Control);
            context.ResumeLayout(false);

            paletteId = GL.GenTexture();
            Bitmap bmp = palette.SourceBitmap;

            GL.BindTexture(TextureTarget.Texture2D, paletteId);
            BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0,
                          OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);

            bmp.UnlockBits(bmp_data);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

            base.Resize    += new EmptyDelegate(TKWindow_Resize);
            this.WindowSize = Control.Size;

            GL.ClearColor(0.1f, 0.2f, 0.5f, 0.0f);
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);
            GL.Enable(EnableCap.Texture2D);

            GL.BindTexture(TextureTarget.Texture2D, paletteId);
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
        }
Пример #2
0
        public TKWindow(Size displayDimensions, GlyphPalette palette, Control context)
            : base(displayDimensions, palette)
        {
            if (context == null)
            {
                form = new TKForm();
                form.ClientSize = displayDimensions;
                form.FormClosing += new FormClosingEventHandler(Form_FormClosing);
                form.Show();

                context = form;
            }

            context.SuspendLayout();
            Control.Dock = DockStyle.Fill;
            Control.BackColor = Color.Blue;
            Control.VSync = false;
            Control.Resize += new EventHandler(Control_Resize);
            Control.Paint += new PaintEventHandler(Control_Paint);

            Control.Location = new Point(0, 0);
            Control.Size = context.ClientSize;

            context.Controls.Add(Control);
            context.ResumeLayout(false);

            paletteId = GL.GenTexture();
            Bitmap bmp = palette.SourceBitmap;
            GL.BindTexture(TextureTarget.Texture2D, paletteId);
            BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0,
                OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);

            bmp.UnlockBits(bmp_data);

            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);

            base.Resize += new EmptyDelegate(TKWindow_Resize);
            this.WindowSize = Control.Size;

            GL.ClearColor(0.1f, 0.2f, 0.5f, 0.0f);
            GL.Disable(EnableCap.DepthTest);
            GL.Disable(EnableCap.CullFace);
        }