public void LoadDemo(Mini.DemoBase demo) { _demo = demo; demo.Init(); int max = Math.Max(_w, _h); demo.Width = _w; demo.Height = _h; GLPainterCore pcx = null; GLPainter canvasPainter = null; //if demo not create canvas and painter //the we create for it //int max = Math.Max(w, h); //canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max); //canvasPainter = new GLCanvasPainter(canvas2d, max, max); //canvas2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(w, h); pcx = GLPainterCore.Create(max, max, _w, _h, true); pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOriginKind.LeftTop; canvasPainter = new GLPainter(); canvasPainter.BindToPainterCore(pcx); //create text printer for opengl //---------------------- //1. win gdi based //var printer = new WinGdiFontPrinter(canvas2d, w, h); //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 AggFontPrinter(canvasPainter, w, h); //canvasPainter.TextPrinter = printer; //---------------------- //4. texture atlas based font texture //------------ //resolve request font //var printer = new GLBmpGlyphTextPrinter(canvasPainter, YourImplementation.BootStrapWinGdi.myFontLoader); //canvasPainter.TextPrinter = printer; _getTextPrinterDel?.Invoke(canvasPainter); demo.SetEssentialGLHandlers( null, () => IntPtr.Zero, () => IntPtr.Zero); DemoBase.InvokeGLPainterReady(demo, pcx, canvasPainter); DemoBase.InvokePainterReady(demo, canvasPainter); }
public void InitRootGraphics(RootGraphic rootgfx, ITopWindowEventRoot topWinEventRoot, InnerViewportKind innerViewportKind, IGpuOpenGLSurfaceView nativeWindow, AbstractTopWindowBridge bridge) { //create a proper bridge**** _rootgfx = rootgfx; _topWinEventRoot = topWinEventRoot; _innerViewportKind = innerViewportKind; _viewport = nativeWindow; _winBridge = bridge; nativeWindow.SetSize(rootgfx.Width, rootgfx.Height); switch (innerViewportKind) { case InnerViewportKind.GdiPlusOnGLES: case InnerViewportKind.AggOnGLES: case InnerViewportKind.GLES: { _winBridge.OnHostControlLoaded(); try { nativeWindow.MakeCurrent(); } catch (Exception ex) { } int w = nativeWindow.Width; int h = nativeWindow.Height; int max = Math.Max(w, h); _pcx = PixelFarm.DrawingGL.GLPainterCore.Create(max, max, w, h, true); _glPainter = new GLPainter(); _glPainter.BindToPainterCore(_pcx); if (PixelFarm.Drawing.GLES2.GLES2Platform.TextService != null) { var printer = new GLBitmapGlyphTextPrinter(_glPainter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService); _glPainter.TextPrinter = printer; } else { //warn....! } //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 //_glPainter.TextPrinter = new CpuBlitTextSpanPrinter2(_glPainter, 400, 50, PixelFarm.Drawing.GLES2.GLES2Platform.TextService); //TODO: review this again! //3 var drawboard = new PixelFarm.Drawing.GLES2.MyGLDrawBoard(_glPainter); _glPainter.SetDrawboard(drawboard); _drawboard = drawboard; //{ //in mixed mode //GDI+ on GLES, Agg on GLES we provide a software rendering layer too PixelFarm.Drawing.DrawBoard cpuDrawBoard = null; // CreateSoftwareDrawBoard(view.Width, view.Height, innerViewportKind); drawboard.SetCpuBlitDrawBoardCreator(() => cpuDrawBoard ?? (cpuDrawBoard = CreateSoftwareDrawBoard(w, h, innerViewportKind))); //} ((OpenGL.MyTopWindowBridgeOpenGL)_winBridge).SetCanvas(drawboard); } break; } }