protected override void OnClosing() { //make current before clear GL resource _windowControl.MakeCurrent(); if (_openGLViewport != null) { _openGLViewport.Close(); } if (_windowControl != null) { _windowControl.Dispose(); } }
public override void PaintToOutputWindow() { if (!isInitGLControl) { return; } //var innumber = dbugCount; //dbugCount++; //Console.WriteLine(">" + innumber); #if DEBUG //dbugStopWatch.Reset(); //dbugStopWatch.Start(); #endif windowControl.MakeCurrent(); this.openGLViewport.PaintMe(); windowControl.SwapBuffers(); #if DEBUG //dbugStopWatch.Stop(); //long millisec_per_frame = dbugStopWatch.ElapsedMilliseconds; //int fps = (int)(1000.0f / millisec_per_frame); //System.Diagnostics.Debug.WriteLine(fps); #endif //Console.WriteLine("<" + innumber); }
public override void PaintToOutputWindow() { if (!isInitGLControl) { return; } //var innumber = dbugCount; //dbugCount++; //Console.WriteLine(">" + innumber); windowControl.MakeCurrent(); this.openGLViewport.PaintMe(); windowControl.SwapBuffers(); //Console.WriteLine("<" + innumber); }
public void InitRootGraphics( RootGraphic rootgfx, ITopWindowEventRoot topWinEventRoot, InnerViewportKind innerViewportKind) { //create a proper bridge**** _rootgfx = rootgfx; _topWinEventRoot = topWinEventRoot; _innerViewportKind = innerViewportKind; switch (innerViewportKind) { #if GL_ENABLE case InnerViewportKind.GdiPlusOnGLES: case InnerViewportKind.AggOnGLES: case InnerViewportKind.GLES: { //temp not suppport var bridge = new OpenGL.MyTopWindowBridgeOpenGL(rootgfx, topWinEventRoot); var view = new OpenGL.GpuOpenGLSurfaceView(); view.Width = rootgfx.Width; view.Height = rootgfx.Height; _gpuSurfaceViewUserControl = view; this.Controls.Add(view); //--------------------------------------- view.Bind(bridge); _winBridge = bridge; //--------------------------------------- IntPtr hh1 = view.Handle; //force real window handle creation view.MakeCurrent(); int max = Math.Max(view.Width, view.Height); _pcx = GLPainterContext.Create(max, max, view.Width, view.Height, true); _glPainter = new GLPainter(); _glPainter.BindToPainterContext(_pcx); _glPainter.TextPrinter = new GLBitmapGlyphTextPrinter(_glPainter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService); //canvasPainter.SmoothingMode = PixelFarm.Drawing.SmoothingMode.HighQuality; //---------------------- //1. win gdi based //var printer = new WinGdiFontPrinter(canvas2d, view.Width, view.Height); //canvasPainter.TextPrinter = printer; //---------------------- //2. raw vxs //var printer = new PixelFarm.Drawing.Fonts.VxsTextPrinter(canvasPainter); //canvasPainter.TextPrinter = printer; //---------------------- //3. agg texture based font texture //var printer = new AggTextSpanPrinter(canvasPainter, 400, 50); //printer.HintTechnique = Typography.Rendering.HintTechnique.TrueTypeInstruction_VerticalOnly; //printer.UseSubPixelRendering = true; //canvasPainter.TextPrinter = printer; //3 var myGLCanvas1 = new PixelFarm.Drawing.GLES2.MyGLDrawBoard(_glPainter); //{ //in mixed mode //GDI+ on GLES, Agg on GLES we provide a software rendering layer too PixelFarm.Drawing.DrawBoard cpuDrawBoard = CreateSoftwareDrawBoard(view.Width, view.Height, innerViewportKind); myGLCanvas1.SetCpuBlitDrawBoardCreator(() => cpuDrawBoard); //} bridge.SetCanvas(myGLCanvas1); } break; #endif case InnerViewportKind.PureAgg: { var bridge = new GdiPlus.MyTopWindowBridgeAgg(rootgfx, topWinEventRoot); //bridge to agg var view = new CpuSurfaceView(); view.Dock = DockStyle.Fill; this.Controls.Add(view); //--------------------------------------- view.Bind(bridge); _winBridge = bridge; } break; case InnerViewportKind.GdiPlus: default: { var bridge = new GdiPlus.MyTopWindowBridgeGdiPlus(rootgfx, topWinEventRoot); //bridge with GDI+ var view = new CpuSurfaceView(); view.Size = new System.Drawing.Size(rootgfx.Width, rootgfx.Height); this.Controls.Add(view); //--------------------------------------- view.Bind(bridge); _winBridge = bridge; } break; #if __SKIA__ case InnerViewportKind.Skia: { //skiasharp *** var bridge = new Skia.MyTopWindowBridgeSkia(rootgfx, topWinEventRoot); var view = new CpuSurfaceView(); view.Dock = DockStyle.Fill; this.Controls.Add(view); //--------------------------------------- view.Bind(bridge); _winBridge = bridge; } break; #endif } }
public void InitRootGraphics( RootGraphic rootgfx, ITopWindowEventRoot topWinEventRoot, InnerViewportKind innerViewportKind) { //create a proper bridge**** this.rootgfx = rootgfx; this.topWinEventRoot = topWinEventRoot; this.innerViewportKind = innerViewportKind; switch (innerViewportKind) { case InnerViewportKind.GL: { //temp not suppport //TODO: review here //PixelFarm.Drawing.DrawingGL.CanvasGLPortal.Start(); var bridge = new OpenGL.MyTopWindowBridgeOpenGL(rootgfx, topWinEventRoot); var view = new OpenGL.GpuOpenGLSurfaceView(); view.Width = 800; view.Height = 600; openGLSurfaceView = view; //view.Dock = DockStyle.Fill; this.Controls.Add(view); //--------------------------------------- view.Bind(bridge); this.winBridge = bridge; //--------------------------------------- view.SetGLPaintHandler(HandleGLPaint); hh1 = view.Handle; //force real window handle creation view.MakeCurrent(); //int max = Math.Max(this.Width, this.Height); int max = Math.Max(view.Width, view.Height); canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max); //--------------- //canvas2d.FlipY = true;// //--------------- canvasPainter = new GLCanvasPainter(canvas2d, max, max); //canvasPainter.SmoothingMode = PixelFarm.Drawing.SmoothingMode.HighQuality; //---------------------- //1. win gdi based //var printer = new WinGdiFontPrinter(canvas2d, view.Width, view.Height); //canvasPainter.TextPrinter = printer; //---------------------- //2. raw vxs //var printer = new PixelFarm.Drawing.Fonts.VxsTextPrinter(canvasPainter); //canvasPainter.TextPrinter = printer; //---------------------- //3. agg texture based font texture //var printer = new AggTextSpanPrinter(canvasPainter, 400, 50); //printer.HintTechnique = Typography.Rendering.HintTechnique.TrueTypeInstruction_VerticalOnly; //printer.UseSubPixelRendering = true; //canvasPainter.TextPrinter = printer; var printer = new GLBmpGlyphTextPrinter(canvasPainter, YourImplementation.BootStrapOpenGLES2.myFontLoader); canvasPainter.TextPrinter = printer; // //var myGLCanvas1 = new PixelFarm.Drawing.GLES2.MyGLCanvas(canvasPainter, 0, 0, view.Width, view.Height); var myGLCanvas1 = new PixelFarm.Drawing.GLES2.MyGLCanvas(canvasPainter, 0, 0, view.Width, view.Height); bridge.SetCanvas(myGLCanvas1); } break; #if __SKIA__ case InnerViewportKind.Skia: { //skiasharp *** var bridge = new Skia.MyTopWindowBridgeSkia(rootgfx, topWinEventRoot); var view = new CpuSurfaceView(); view.Dock = DockStyle.Fill; this.Controls.Add(view); //--------------------------------------- view.Bind(bridge); this.winBridge = bridge; } break; #endif case InnerViewportKind.GdiPlus: default: { var bridge = new GdiPlus.MyTopWindowBridgeGdiPlus(rootgfx, topWinEventRoot); var view = new CpuSurfaceView(); view.Dock = DockStyle.Fill; this.Controls.Add(view); //--------------------------------------- view.Bind(bridge); this.winBridge = bridge; } break; } }