private void CaptureForm_Load(object sender, EventArgs e) { // Get Target Procces List<Process> ps = Process.GetProcesses().ToList(); Process target = ps.Find(p => p.ProcessName == "mpc-hc64"); if (target == null) throw new Exception("ターゲットプロセスが見つかりません"); targetWindowHnadle = target.MainWindowHandle; targetWindowSize = CaptureHelper.GetWindowSize(targetWindowHnadle); frameBuf = Data.Create(targetWindowSize); // Init OpenGL glcScreen.MakeCurrent(); GL.Enable(EnableCap.DepthTest); GL.Enable(EnableCap.CullFace); GL.FrontFace(FrontFaceDirection.Cw); GL.CullFace(CullFaceMode.Back); // load textures SetupViewport(); sampleTex = MyTexture.Create(frameBuf.Bitmap.Width, frameBuf.Bitmap.Height); MyTexture.Init(glcScreen); //sampleTex = MyTexture.Load("../../texture/tex.jpg"); // backTex = MyTexture.Load("../../texture/back.png"); }
private void btnBeginRecode_Click(object sender, EventArgs e) { frameBuf = Data.Create(targetWindowSize); sampleTex = MyTexture.Create(frameBuf.Bitmap.Width, frameBuf.Bitmap.Height); }
public static MyTexture Create(int width, int height) { MyTexture tmpTex = new MyTexture(); tmpTex.ShaderName = "sepia"; int tmp; GL.GenTextures(1, out tmp); tmpTex.Handle = tmp; GL.BindTexture(TextureTarget.Texture2D, tmpTex.Handle); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear); GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear); using (Bitmap bitmap = new Bitmap(width, height)) { BitmapData data = bitmap.LockBits(new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb); GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, data.Width, data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0); bitmap.UnlockBits(data); tmpTex.Width = data.Width; tmpTex.Height = data.Height; } return tmpTex; }