Beispiel #1
0
        public AppHostIOS(GameViewController vw, int canvasW, int canvasH)
        {
            //---------------------------------------
            //this specific for WindowForm viewport
            //---------------------------------------
            _vw = vw;
            _formTitleBarHeight = 0;
            _canvasW            = canvasW;
            _canvasH            = canvasH;

            _primaryScreenWorkingAreaW = vw.ViewWidth;
            _primaryScreenWorkingAreaH = vw.ViewHeight;

            string basedir = "";

            PixelFarm.Platforms.StorageService.RegisterProvider(new LocalFileStorageProvider(basedir));
            PixelFarm.CpuBlit.MemBitmapExtensions.DefaultMemBitmapIO = new YourImplementation.ImgCodecMemBitmapIO();

            int max = Math.Max(canvasW, canvasH);

            _pcx            = GLPainterContext.Create(max, max, canvasW, canvasH, true);
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;

            _painter = new GLPainter();
            _painter.BindToPainterContext(_pcx);
            _painter.SetClipBox(0, 0, canvasW, canvasH);
            _painter.TextPrinter = new GLBitmapGlyphTextPrinter(_painter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);
            //

            //
            _rootGfx = new MyRootGraphic(canvasW, canvasH, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);
            SetUpGLSurface();
            _drawBoard = new MyGLDrawBoard(_painter);
        }
Beispiel #2
0
        public void LoadExample(DemoBase demoBase)
        {
            _gfxViewRoot.MakeCurrent();


            GLPainterCore pcx       = _gfxViewRoot.GLPainterCore();
            GLPainter     glPainter = _gfxViewRoot.GetGLPainter();

            pcx.SmoothMode = SmoothMode.Smooth;//set anti-alias

            //create text printer for opengl
            demoBase.Init();
            _demoBase = demoBase;

            _demoUI = new DemoUI(demoBase, _myWidth, _myHeight);
            _demoUI.SetCanvasPainter(pcx, glPainter);
            //-----------------------------------------------
            //demoBase.SetEssentialGLHandlers(
            //    () => _glControl.SwapBuffers(),
            //    () => _glControl.GetEglDisplay(),
            //    () => _glControl.GetEglSurface()
            //);
            //-----------------------------------------------

            DemoBase.InvokeGLPainterReady(demoBase, pcx, glPainter);
            //Add to RenderTree
            _rootGfx.AddChild(_demoUI.GetPrimaryRenderElement());
        }
Beispiel #3
0
        public void LoadDemo(Mini.DemoBase demo)
        {
            _demo = demo;
            demo.Init();

            int max = Math.Max(_w, _h);

            demo.Width  = _w;
            demo.Height = _h;
            GLPainterContext 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            = GLPainterContext.Create(max, max, _w, _h, true);
            pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftBottom;
            canvasPainter  = new GLPainter();
            canvasPainter.BindToPainterContext(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;

            if (_getTextPrinterDel != null)
            {
                _getTextPrinterDel(canvasPainter);
            }



            demo.SetEssentialGLHandlers(
                () => { },
                () => IntPtr.Zero,
                () => IntPtr.Zero);

            DemoBase.InvokeGLPainterReady(demo, pcx, canvasPainter);
            DemoBase.InvokePainterReady(demo, canvasPainter);
        }
Beispiel #4
0
        public void LoadDemo(Mini.DemoBase demo)
        {
            this.demo = demo;
            demo.Init();

            int max = Math.Max(w, h);

            demo.Width  = w;
            demo.Height = h;
            GLRenderSurface glsx;
            GLPainter       canvasPainter;

            demo.BuildCustomDemoGLContext(out glsx, out canvasPainter);
            if (glsx == 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);
                glsx          = PixelFarm.Drawing.GLES2.GLES2Platform.CreateGLRenderSurface(max, max, w, h);
                canvasPainter = new GLPainter(glsx);

                //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;

                if (_getTextPrinterDel != null)
                {
                    _getTextPrinterDel(canvasPainter);
                }
            }

            demo.SetEssentialGLHandlers(
                () => { },
                () => IntPtr.Zero,
                () => IntPtr.Zero);

            DemoBase.InvokeGLContextReady(demo, glsx, canvasPainter);
            DemoBase.InvokePainterReady(demo, canvasPainter);
        }
Beispiel #5
0
        protected override void OnGLPainterReady(GLPainter painter)
        {
            _pcx     = painter.PainterContext;
            _painter = painter;
            UserText = "";
#if DEBUG
            ShowGlyphTexture = ShowMarkers = true;
#endif
        }
        protected override void OnGLPainterReady(GLPainter painter)
        {
            //example;
            //test1_atlas=> atlas filename
            _chk_checked   = new AtlasImageBinder("test1_atlas", "\\chk_checked.png");
            _chk_unchecked = new AtlasImageBinder("test1_atlas", "\\chk_unchecked.png");

            _pcx     = painter.PainterContext;
            _painter = painter;
            //
            //string atlasInfoFile = "test1_atlas"; //see SampleFontAtlasBuilder below
            //_bmpAtlasPainter.ChangeBitmapAtlas(atlasInfoFile);
        }
Beispiel #7
0
        protected virtual bool HasSomeExtension => false;//class that override

        public void CreatePrimaryRenderElement(GLPainterContext pcx, GLPainter painter, RootGraphic rootgfx)
        {
            if (_canvasRenderE == null)
            {
                var glBmp = new GLBitmap(_memBitmapBinder);
                glBmp.IsYFlipped = false;
                //
                var glRenderElem = new CpuBlitGLCanvasRenderElement(rootgfx, _width, _height, glBmp);
                glRenderElem.SetController(this); //connect to event system
                glRenderElem.SetOwnerDemoUI(this);
                _canvasRenderE = glRenderElem;
            }
        }
Beispiel #8
0
        protected override void OnGLPainterReady(GLPainter painter)
        {
            _pcx     = painter.Core;
            _painter = painter;
            _glBmp   = DemoHelper.LoadTexture(RootDemoPath.Path + @"\logo-dark.jpg");
            _glBmp2  = DemoHelper.LoadTexture(RootDemoPath.Path + @"\lion1_v2.png");

            _textureBrush  = new TextureBrush(_glBmp);
            _textureBrush2 = new TextureBrush(_glBmp2);

            _linearGradient = new LinearGradientBrush(
                new PointF(10, 50), new PointF(10, 100),
                Color.Red, Color.White);
        }
Beispiel #9
0
        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);
            //***
        }
Beispiel #10
0
        protected override void OnStart(AppHost host)
        {
            //html box
            _host    = host;
            _painter = (GLPainter)host.GetPainter();


            var loadingQueueMx = new LayoutFarm.ContentManagers.ImageLoadingQueueManager();

            loadingQueueMx.AskForImage += loadingQueue_AskForImg;

            HtmlHost htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(host,
                                                                     (s, e) => loadingQueueMx.AddRequestImage(e.ImageBinder),
                                                                     contentMx_LoadStyleSheet);

            //
            _htmlBox = new HtmlBox(htmlHost, 1024, 800);
            _htmlBox.SetLocation(0, 300); //test
            _rootgfx = host.GetRootGraphics();
            _rootE   = _htmlBox.GetPrimaryRenderElement(_rootgfx);

            _drawBoard = host.GetDrawBoard();

            host.AddChild(_htmlBox);


            //-------

            _htmltext = @"<html>
                    <head>
                    <style> 
                        .myfont1{font-size:30pt;background-color:yellow}
                        .myfont2{font-size:24pt;background-color:rgb(255,215,0)}
                    </style>
                    </head>
                    <body>
                           <div class='myfont1'>Hello</div>
                           <div class='myfont2'>... from HtmlRenderer</div>
                    </body>        
            </html>";

            //if (_htmltext == null)
            //{
            //    _htmltext = @"<html><head></head><body>NOT FOUND!</body></html>";
            //}
            _htmlBox.LoadHtmlString(_htmltext);
        }
Beispiel #11
0
        protected override void OnGLPainterReady(GLPainter painter)
        {
            //example;
            //test1_atlas=> atlas filename


            //the AtlasImageBinder will be resolved for actual image inside GLPainter's _bmpAtlasPainter.
            //it use StorageService.Provider.
            //-----

            _chk_checked   = new AtlasImageBinder("test1_atlas", "\\chk_checked.png");
            _chk_unchecked = new AtlasImageBinder("test1_atlas", "\\chk_unchecked.png");

            _pcx     = painter.Core;
            _painter = painter;
            //
            //string atlasInfoFile = "test1_atlas"; //see SampleFontAtlasBuilder below
            //_bmpAtlasPainter.ChangeBitmapAtlas(atlasInfoFile);
        }
        public MyGLDrawBoard(GLPainter painter)
        {
            //----------------
            //set painter first
            _gpuPainter = painter;
            //----------------
            _left   = 0; //default start at 0,0
            _top    = 0;
            _width  = painter.Width;
            _height = painter.Height;

            _currentClipRect      = new Rectangle(0, 0, _width, _height);
            this.CurrentFont      = painter.CurrentFont;
            this.CurrentTextColor = Color.Black;
#if DEBUG
            debug_canvas_id   = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif
            this.StrokeWidth = 1;
        }
Beispiel #13
0
        public MyGLDrawBoard(
            GLPainter painter, //*** we wrap around GLPainter ***
            int width,
            int height)
        {
            //----------------
            //set painter first
            this.painter1 = painter;
            //----------------
            this._left   = 0; //default start at 0,0
            this._top    = 0;
            this._width  = width;
            this._height = height;

            currentClipRect = new Rectangle(0, 0, width, height);

            this.CurrentFont      = new RequestFont("tahoma", 10);
            this.CurrentTextColor = Color.Black;
#if DEBUG
            debug_canvas_id   = dbug_canvasCount + 1;
            dbug_canvasCount += 1;
#endif
            this.StrokeWidth = 1;
        }
Beispiel #14
0
 public void SetCanvasPainter(GLPainterCore pcx, GLPainter painter)
 {
     _pcx     = pcx;
     _painter = painter;
 }
Beispiel #15
0
        public void Setup(int canvasW, int canvasH)
        {
            //string curdir = Directory.GetCurrentDirectory();
            //string oneLevelDir = Path.GetDirectoryName(curdir);
            //string basedir = "/";// oneLevelDir + "/newdir";
            //LocalFileStorageProvider.s_globalBaseDir = basedir;
            //Directory.CreateDirectory(basedir);

            string basedir = "";

            PixelFarm.Platforms.StorageService.RegisterProvider(new LocalFileStorageProvider(basedir));
            PixelFarm.CpuBlit.MemBitmapExtensions.DefaultMemBitmapIO = new YourImplementation.ImgCodecMemBitmapIO();



            int max = Math.Max(canvasW, canvasH);

            _pcx            = GLPainterContext.Create(max, max, canvasW, canvasH, true);
            _pcx.OriginKind = PixelFarm.Drawing.RenderSurfaceOrientation.LeftTop;

            _painter = new GLPainter();
            _painter.BindToPainterContext(_pcx);
            _painter.SetClipBox(0, 0, canvasW, canvasH);
            _painter.TextPrinter = new GLBitmapGlyphTextPrinter(_painter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);

            ////--------------------------------------
            ////TODO: review here again

            ////--------------------------------------
            //simpleCanvas = new SimpleCanvas(canvasW, canvasH);

            //var text = "Typography";


            ////optional ....
            ////var directory = AndroidOS.Environment.ExternalStorageDirectory;
            ////var fullFileName = Path.Combine(directory.ToString(), "TypographyTest.txt");
            ////if (File.Exists(fullFileName))
            ////{
            ////    text = File.ReadAllText(fullFileName);
            ////}
            ////--------------------------------------------------------------------------
            ////we want to create a prepared visual object ***
            ////textContext = new TypographyTextContext()
            ////{
            ////    FontFamily = "DroidSans.ttf", //corresponding to font file Assets/DroidSans.ttf
            ////    FontSize = 64,//size in Points
            ////    FontStretch = FontStretch.Normal,
            ////    FontStyle = FontStyle.Normal,
            ////    FontWeight = FontWeight.Normal,
            ////    Alignment = DrawingGL.Text.TextAlignment.Leading
            ////};
            ////--------------------------------------------------------------------------
            ////create blank text run
            //textRun = new TextRun();
            ////generate glyph run inside text text run

            //TextPrinter textPrinter = simpleCanvas.TextPrinter;
            //textPrinter.FontFilename = "DroidSans.ttf"; //corresponding to font file Assets/DroidSans.ttf
            //textPrinter.FontSizeInPoints = 64;
            ////
            //simpleCanvas.TextPrinter.GenerateGlyphRuns(textRun, text.ToCharArray(), 0, text.Length);
            ////--------------------------------------------------------------------------

            //_memBmp = PixelFarm.CpuBlit.MemBitmap.LoadBitmap("rgb_test1.pngx");

            //_memBmp = new PixelFarm.CpuBlit.MemBitmap(64 * 2, 65);
            //PixelFarm.CpuBlit.AggPainter p = PixelFarm.CpuBlit.AggPainter.Create(_memBmp);
            //p.Clear(Color.Red);

            //_memBmp.SaveImage("output.png");
            //GL.Enable(EnableCap.Texture2D);
        }
Beispiel #16
0
 protected virtual void OnGLPainterReady(GLPainter painter)
 {
 }
Beispiel #17
0
 public static void InvokeGLPainterReady(DemoBase demo, GLPainterContext pcx, GLPainter painter)
 {
     demo.OnGLPainterReady(painter);
     demo.OnReadyForInitGLShaderProgram();
 }
Beispiel #18
0
        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;
            }
        }
Beispiel #19
0
        public void LoadExample(DemoBase demoBase)
        {
            _glControl.MakeCurrent();

            _demoBase = demoBase;
            demoBase.Init();

            if (WithGdiPlusDrawBoard)
            {
                _bridgeUI = new GdiOnGLESUIElement(_myWidth, _myHeight);
            }
            else
            {
                //pure agg's cpu blit
                _bridgeUI = new CpuBlitGLESUIElement(_myWidth, _myHeight);
            }
            //
            _bridgeUI.SetUpdateCpuBlitSurfaceDelegate((p, updateArea) => _demoBase.Draw(p));

            DemoBase.InvokePainterReady(_demoBase, _bridgeUI.GetAggPainter());
            //
            //use existing GLRenderSurface and GLPainter
            //see=>UISurfaceViewportControl.InitRootGraphics()

            GLPainterContext pcx       = _surfaceViewport.GetGLRenderSurface();
            GLPainter        glPainter = _surfaceViewport.GetGLPainter();

            _bridgeUI.CreatePrimaryRenderElement(pcx, glPainter, _rootGfx);
            //-----------------------------------------------
            demoBase.SetEssentialGLHandlers(
                () => _glControl.SwapBuffers(),
                () => _glControl.GetEglDisplay(),
                () => _glControl.GetEglSurface()
                );
            //-----------------------------------------------
            DemoBase.InvokeGLPainterReady(demoBase, pcx, glPainter);
            //Add to RenderTree
            _rootGfx.AddChild(_bridgeUI.GetPrimaryRenderElement(_rootGfx));
            //-----------------------------------------------
            //***
            GeneralEventListener genEvListener = new GeneralEventListener();

            genEvListener.MouseDown += e =>
            {
                _demoBase.MouseDown(e.X, e.Y, e.Button == UIMouseButtons.Right);
                _bridgeUI.InvalidateGraphics();
            };
            genEvListener.MouseMove += e =>
            {
                if (e.IsDragging)
                {
                    _bridgeUI.InvalidateGraphics();
                    _demoBase.MouseDrag(e.X, e.Y);
                    _bridgeUI.InvalidateGraphics();
                }
            };
            genEvListener.MouseUp += e =>
            {
                _demoBase.MouseUp(e.X, e.Y);
            };
            //-----------------------------------------------
            _bridgeUI.AttachExternalEventListener(genEvListener);
        }
        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
            }
        }
Beispiel #21
0
 public void SetPainter(GLPainter canvasPainter)
 {
     _painter = canvasPainter;
 }
Beispiel #22
0
 protected override void OnGLPainterReady(GLPainter painter)
 {
     _pcx               = painter.PainterContext;
     _painter           = painter;
     SelectedGlyphImage = T107_2_GlyphImages.Img1;
 }
Beispiel #23
0
 public void Dispose()
 {
     _painter = null;
     _demo    = null;
 }
Beispiel #24
0
 protected virtual void OnGLSurfaceReady(GLRenderSurface glsx, GLPainter painter)
 {
 }
Beispiel #25
0
 protected override void OnGLPainterReady(GLPainter painter)
 {
     _pcx     = painter.PainterContext;
     _painter = painter;
 }
Beispiel #26
0
 //----------------------------------------------------
 //for GL
 public virtual void BuildCustomDemoGLContext(out GLRenderSurface glsx, out GLPainter painter)
 {
     glsx    = null;
     painter = null;
 }
 protected override void OnGLSurfaceReady(GLRenderSurface glsx, GLPainter painter)
 {
     this._glsx   = glsx;
     this.painter = painter;
 }
Beispiel #28
0
 public static void InvokeGLContextReady(DemoBase demo, GLRenderSurface glsx, GLPainter painter)
 {
     demo._painter = painter;
     demo.OnGLSurfaceReady(glsx, painter);
     demo.OnReadyForInitGLShaderProgram();
 }
Beispiel #29
0
 protected override void OnGLPainterReady(GLPainter painter)
 {
     _pcx     = painter.Core;
     _painter = painter;
 }
        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:
            {
#if GL_ENABLE
                //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        = 1200;
                view.Height       = 1200;
                openGLSurfaceView = view;
                //view.Dock = DockStyle.Fill;
                //this.Controls.Add(view);
                this.panel1.Visible = true;
                this.panel1.Controls.Add(view);

                //---------------------------------------
                view.Bind(bridge);
                this.winBridge = bridge;
                //---------------------------------------
                view.SetGLPaintHandler(null);
                hh1 = view.Handle;         //force real window handle creation
                view.MakeCurrent();


                int max = Math.Max(view.Width, view.Height);
                _glsx = PixelFarm.Drawing.GLES2.GLES2Platform.CreateGLRenderSurface(max, max, view.Width, view.Height);
                //---------------
                //canvas2d.FlipY = true;//
                //---------------
                canvasPainter = new GLPainter(_glsx);

                //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 printer = new GLBitmapGlyphTextPrinter(canvasPainter, PixelFarm.Drawing.GLES2.GLES2Platform.TextService);
                canvasPainter.TextPrinter = printer;

                //
                var myGLCanvas1 = new PixelFarm.Drawing.GLES2.MyGLDrawBoard(canvasPainter, _glsx.CanvasWidth, _glsx.CanvasHeight);
                bridge.SetCanvas(myGLCanvas1);
#endif
            }
            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;
            }
        }