public void LoadGLControl(OpenTK.MyGLControl glControl) { //---------------------- this.glControl = glControl; glControl.SetGLPaintHandler(HandleGLPaint); hh1 = glControl.Handle; //ensure that contrl handler is created glControl.MakeCurrent(); }
public void Close() { _demoBase.CloseDemo(); if (_surfaceViewport != null) { _surfaceViewport.Close(); _surfaceViewport = null; } _rootGfx = null; _glControl = null; }
void SetUpGLSurface(OpenTK.MyGLControl glControl) { if (glControl == null) { return; } //TODO: review here //Temp: _glControl = glControl; _glControl.SetGLPaintHandler(null); // IntPtr hh1 = _glControl.Handle; //ensure that contrl handler is created _glControl.MakeCurrent(); if (_vw.InnerViewportKind == InnerViewportKind.GdiPlusOnGLES) { _bridgeUI = new GdiOnGLESUIElement(glControl.Width, glControl.Height); } else { //pure agg's cpu blit _bridgeUI = new CpuBlitGLESUIElement(glControl.Width, glControl.Height); } //optional*** //_bridgeUI.SetUpdateCpuBlitSurfaceDelegate((p, area) => //{ // _client.DrawToThisCanvas(_bridgeUI.GetDrawBoard(), area); //}); GLPainterContext pcx = _vw.GetGLRenderSurface(); GLPainter glPainter = _vw.GetGLPainter(); RootGraphic rootGfx = _vw.RootGfx; _bridgeUI.CreatePrimaryRenderElement(pcx, glPainter, rootGfx); //***** RenderBoxBase renderE = (RenderBoxBase)_bridgeUI.GetPrimaryRenderElement(rootGfx); rootGfx.AddChild(renderE); rootGfx.SetPrimaryContainerElement(renderE); //*** }
public void BindSurface(LayoutFarm.UI.UISurfaceViewportControl surfaceViewport) { _surfaceViewport = surfaceViewport; _rootGfx = surfaceViewport.RootGfx; //---------------------- _glControl = surfaceViewport.GetOpenTKControl(); _myWidth = _glControl.Width; _myHeight = _glControl.Height; IntPtr hh1 = _glControl.Handle; //ensure that contrl handler is created _glControl.MakeCurrent(); }
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(); } }