Пример #1
0
        int GetFrame()
        {
            int tex;

            adapter.Rasterize();

            using (Bitmap raster = new Bitmap(adapter.Raster))
            {
                //raster.RotateFlip(RotateFlipType.Rotate180FlipX);

                GL.Hint(HintTarget.PerspectiveCorrectionHint, HintMode.Nicest);

                if (firstFrameRendered)
                {
                    GL.DeleteTexture(1);
                }
                GL.GenTextures(1, out tex);
                GL.BindTexture(TextureTarget.Texture2D, tex);

                BitmapData data = raster.LockBits(new Rectangle(0, 0, raster.Width, raster.Height),
                                                  ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);

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

                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapS, (int)TextureWrapMode.Repeat);
                GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureWrapT, (int)TextureWrapMode.Repeat);
            }

            return(tex);
        }
Пример #2
0
        public void RefreshScreen()
        {
            if (!DesignMode)
            {
                if (adapter != null)
                {
                    adapter.Rasterize();

                    if (Image != null)
                    {
                        Image.Dispose();
                    }
                    Image = new Bitmap(adapter.Raster);

                    GC.Collect();
                }
            }
        }