Exemplo n.º 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);
        }
Exemplo n.º 2
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);
        }
Exemplo n.º 3
0
        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
            }
        }
Exemplo n.º 4
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);
        }