public override void Init() { formTestBed = new FormTestBed(); this.miniGLControl = formTestBed.InitMiniGLControl(this.Width, this.Height);//1276,720 this.aniTimer = new System.Windows.Forms.Timer(); //this.formTestBed.Load += this.OnInitGLProgram; this.formTestBed.FormClosing += formTestBed_FormClosing; this.formTestBed.Text = this.GetType().Name; miniGLControl.SetGLPaintHandler(this.OnGLRender); formTestBed.Show(); hh1 = miniGLControl.Handle; miniGLControl.MakeCurrent(); this.OnInitGLProgram(null, EventArgs.Empty); formTestBed.WindowState = System.Windows.Forms.FormWindowState.Maximized; //this.aniTimer.Interval = 200;//ms //this.aniTimer.Tick += TimerTick; }
void lstExample_DoubleClick(object sender, EventArgs e) { //load sample form if (!(this.lstExamples.SelectedItem is ExampleAndDesc exAndDesc)) { return; //early exit } // DemoBase demo = InitDemo(exAndDesc); if (demo == null) { return; } FormTestBed formTestBed = new FormTestBed(); formTestBed.WindowState = FormWindowState.Maximized; RenderBackendChoice selItem = (RenderBackendChoice)lstBackEndRenderer.SelectedItem; CpuBlitAppModule cpuBlitContextWinForm = null; switch (selItem) { case RenderBackendChoice.PureAgg: { LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.PureAgg, out LayoutFarm.UI.GraphicsViewRoot surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); formTestBed.Show(); cpuBlitContextWinForm = new CpuBlitAppModule(); cpuBlitContextWinForm.BindSurface(surfaceViewport); cpuBlitContextWinForm.LoadExample(demo); demo.RequestGraphicRefresh += (s, e1) => cpuBlitContextWinForm.InvalidateUI(); formTestBed.FormClosed += (s1, e1) => cpuBlitContextWinForm.Close(); formTestBed.LoadExample(exAndDesc, demo); } break; case RenderBackendChoice.GdiPlus: { LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.GdiPlus, out LayoutFarm.UI.GraphicsViewRoot surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); cpuBlitContextWinForm = new CpuBlitAppModule(); cpuBlitContextWinForm.BindSurface(surfaceViewport); cpuBlitContextWinForm.LoadExample(demo); formTestBed.FormClosed += (s1, e1) => cpuBlitContextWinForm.Close(); formTestBed.LoadExample(exAndDesc, demo); formTestBed.Show(); } break; case RenderBackendChoice.OpenGLES: //gles 2 and 3 { //-------------------------------------------- LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.GLES, out LayoutFarm.UI.GraphicsViewRoot surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); GLESAppModule appModule = new GLESAppModule(); appModule.BindSurface(surfaceViewport); appModule.LoadExample(demo); formTestBed.FormClosing += (s2, e2) => appModule.Close(); formTestBed.LoadExample(exAndDesc, demo); formTestBed.Show(); } break; case RenderBackendChoice.AggOnGLES: case RenderBackendChoice.GdiPlusOnGLES: { LayoutFarm.UI.FormCanvasHelper.CreateCanvasControlOnExistingControl( formTestBed.GetLandingControl(), 0, 0, 800, 600, LayoutFarm.UI.InnerViewportKind.AggOnGLES, out LayoutFarm.UI.GraphicsViewRoot surfaceViewport ); formTestBed.SetUISurfaceViewportControl(surfaceViewport); // CpuBlitOnGLESAppModule appModule = new CpuBlitOnGLESAppModule(); appModule.WithGdiPlusDrawBoard = (selItem == RenderBackendChoice.GdiPlusOnGLES); //** appModule.BindSurface(surfaceViewport); appModule.LoadExample(demo); formTestBed.FormClosing += (s2, e2) => appModule.Close(); formTestBed.LoadExample(exAndDesc, demo); formTestBed.Show(); } break; #if SKIA_ENABLE case RenderBackendChoice.SkiaMemoryBackend: { TestSkia1.FormSkia1 formSkia = new TestSkia1.FormSkia1(); formSkia.SelectBackend(TestSkia1.FormSkia1.SkiaBackend.Memory); formSkia.Show(); formSkia.LoadExample(exAndDesc); } break; case RenderBackendChoice.SkiaGLBackend: { TestSkia1.FormSkia1 formSkia = new TestSkia1.FormSkia1(); formSkia.SelectBackend(TestSkia1.FormSkia1.SkiaBackend.GLES); formSkia.Show(); formSkia.LoadExample(exAndDesc); } break; #endif default: throw new NotSupportedException(); } }
void listBox1_DoubleClick(object sender, EventArgs e) { //load sample form ExampleAndDesc exAndDesc = this.listBox1.SelectedItem as ExampleAndDesc; if (exAndDesc == null) { return; //early exit } // // switch ((RenderBackendChoice)lstBackEndRenderer.SelectedItem) { case RenderBackendChoice.PureAgg: { FormTestBed testBed = new FormTestBed(); testBed.WindowState = FormWindowState.Maximized; testBed.UseGdiPlusOutput = false; testBed.UseGdiAntiAlias = chkGdiAntiAlias.Checked; testBed.Show(); testBed.LoadExample(exAndDesc); } break; case RenderBackendChoice.GdiPlus: { FormTestBed testBed = new FormTestBed(); testBed.WindowState = FormWindowState.Maximized; testBed.UseGdiPlusOutput = true; testBed.UseGdiAntiAlias = chkGdiAntiAlias.Checked; testBed.Show(); testBed.LoadExample(exAndDesc); } break; case RenderBackendChoice.OpenGLES2: { //create demo DemoBase exBase = Activator.CreateInstance(exAndDesc.Type) as DemoBase; if (exBase == null) { return; } //create form FormGLTest formGLTest = new FormGLTest(); formGLTest.Text = exAndDesc.ToString(); formGLTest.Show(); //---------------------- //get target control that used to present the example OpenTK.MyGLControl control = formGLTest.InitMiniGLControl(800, 600); { GLDemoContextWinForm glbaseDemo = new GLDemoContextWinForm(); glbaseDemo.LoadGLControl(control); glbaseDemo.LoadSample(exBase); //---------------------- formGLTest.FormClosing += (s2, e2) => { glbaseDemo.CloseDemo(); }; } //{ // //test another example // DemoBase exBase2 = Activator.CreateInstance(exAndDesc.Type) as DemoBase; // OpenTK.MyGLControl control2 = formGLTest.InitMiniGLControl2(400, 300); // GLDemoContextWinForm glbaseDemo = new GLDemoContextWinForm(); // glbaseDemo.LoadGLControl(control2); // glbaseDemo.LoadSample(exBase2); // //---------------------- // formGLTest.FormClosing += (s2, e2) => // { // glbaseDemo.CloseDemo(); // }; //} formGLTest.WindowState = FormWindowState.Maximized; } break; #if SKIA_ENABLE case RenderBackendChoice.SkiaMemoryBackend: { TestSkia1.FormSkia1 formSkia = new TestSkia1.FormSkia1(); formSkia.SelectBackend(TestSkia1.FormSkia1.SkiaBackend.Memory); formSkia.Show(); formSkia.LoadExample(exAndDesc); } break; case RenderBackendChoice.SkiaGLBackend: { TestSkia1.FormSkia1 formSkia = new TestSkia1.FormSkia1(); formSkia.SelectBackend(TestSkia1.FormSkia1.SkiaBackend.GLES); formSkia.Show(); formSkia.LoadExample(exAndDesc); } break; #endif default: throw new NotSupportedException(); } }