Sharplike.Frontend.Rendering.TKWindow.TKWindow C# (CSharp) Méthode

TKWindow() public méthode

public TKWindow ( Size displayDimensions, GlyphPalette palette, Control context ) : System
displayDimensions System.Drawing.Size
palette Sharplike.Core.Rendering.GlyphPalette
context System.Windows.Forms.Control
Résultat System
        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);
        }