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); }
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); }