public static void Start() { PixelFarm.Platforms.StorageService.RegisterProvider(s_LocalStorageProvider); //--------------------------------------------------- PixelFarm.CpuBlit.MemBitmapExtensions.DefaultMemBitmapIO = new YourImplementation.ImgCodecMemBitmapIO(); //PixelFarm.CpuBlit.MemBitmapExtensions.DefaultMemBitmapIO = new PixelFarm.Drawing.WinGdi.GdiBitmapIO(); if (!GLFWPlatforms.Init()) { System.Diagnostics.Debug.WriteLine("can't init glfw"); return; } bool useMyGLFWForm = true; if (!useMyGLFWForm) { GlFwForm form1 = new GlFwForm(800, 600, "PixelFarm on GLfw and GLES2"); MyApp glfwApp = new MyApp(); form1.SetDrawFrameDelegate(e => glfwApp.UpdateViewContent(e)); } else { MyGLFWForm form1 = new MyGLFWForm(800, 600, "PixelFarm on GLfw and GLES2"); MyApp glfwApp = new MyApp(); form1.SetDrawFrameDelegate(e => glfwApp.UpdateViewContent(e)); } GlfwApp.RunMainLoop(); }
public void CreateMainForm() { int w = 800, h = 600; GlFwForm form1 = new GlFwForm(w, h, "PixelFarm on GLfw and GLES2"); MyRootGraphic myRootGfx = new MyRootGraphic(w, h, s_textServices); var canvasViewport = new UISurfaceViewportControl(); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, InnerViewportKind.GLES); canvasViewport.SetBounds(0, 0, w, h); form1.Controls.Add(canvasViewport); //demoContext2.LoadDemo(new T45_TextureWrap()); //demoContext2.LoadDemo(new T48_MultiTexture()); //demoContext2.LoadDemo(new T107_1_DrawImages()); _demoBase = new OpenTkEssTest.T108_LionFill();//new T45_TextureWrap(),T48_MultiTexture() //_demoBase = new T110_DrawText(); //_demoBase = new T107_1_DrawImages(); _demoContext = new GLDemoContext(w, h); _demoContext.SetTextPrinter(painter => { var printer = new PixelFarm.DrawingGL.GLBitmapGlyphTextPrinter(painter, s_textServices); painter.TextPrinter = printer; //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; }); form1.SetDrawFrameDelegate(e => _demoContext.Render()); _demoContext.LoadDemo(_demoBase); }
public static void Start() { if (!GLFWPlatforms.Init()) { Console.WriteLine("can't init"); return; } GlFwForm form1 = new GlFwForm( 800, 600, "PixelFarm on GLfw and OpenGLES2"); //---------------- //this not need if we use glfwcontext for opentk // new OpenTK.Graphics.ES20.GL().LoadEntryPoints(); //---------------- //var demo = new OpenTkEssTest.T52_HelloTriangle2(); //var demo = new OpenTkEssTest.T107_SampleDrawImage(); //var demo = new OpenTkEssTest.T107_SampleDrawImage(); var demoContext = new Mini.GLDemoContext(800, 600); demoContext.LoadDemo(new OpenTkEssTest.T108_LionFill()); ////var demo = new OpenTkEssTest.T107_SampleDrawImage(); form1.SetDrawFrameDelegate(e => { demoContext.Render(); //demo.Render(); }); //--------------------------------- GlFwForm f2 = new GlFwForm(800, 600, "Form2"); f2.SetDrawFrameDelegate(e => { //simple draw GL.ClearColor(0, 1, 1, 1); }); GlfwApp.RunMainLoop(); demoContext.Close(); }
public void CreateMainForm(int w, int h) { GlFwForm form1 = new GlFwForm(w, h, "PixelFarm on GLfw and GLES2"); MyRootGraphic myRootGfx = new MyRootGraphic(w, h, s_textServices); var canvasViewport = new UISurfaceViewportControl(); canvasViewport.InitRootGraphics(myRootGfx, myRootGfx.TopWinEventPortal, InnerViewportKind.GLES); canvasViewport.SetBounds(0, 0, w, h); form1.Controls.Add(canvasViewport); _surfaceViewport = canvasViewport; LayoutFarm.AppHostNeutral appHost = new LayoutFarm.AppHostNeutral(canvasViewport); form1.SetDrawFrameDelegate(e => { _surfaceViewport.PaintMeFullMode(); }); if (_app != null) { appHost.StartApp(_app);//start app canvasViewport.TopDownRecalculateContent(); canvasViewport.PaintMe(); } }
public static void Start() { if (!GLFWPlatforms.Init()) { Console.WriteLine("can't init"); } Glfw.SwapInterval(1); GlFwForm form1 = GlfwApp.CreateGlfwForm( 800, 600, "PixelFarm on GLfw and OpenGLES2"); form1.MakeCurrent(); //------------------------------------ //*** GLFWPlatforms.CreateGLESContext(); //------------------------------------ form1.Activate(); //---------------- //this not need if we use glfwcontext for opentk // new OpenTK.Graphics.ES20.GL().LoadEntryPoints(); //---------------- //var demo = new OpenTkEssTest.T52_HelloTriangle2(); //var demo = new OpenTkEssTest.T107_SampleDrawImage(); //var demo = new OpenTkEssTest.T107_SampleDrawImage(); var demo = new OpenTkEssTest.T108_LionFill(); demo.Width = 800; demo.Height = 600; demo.InitGLProgram(); //var demo = new OpenTkEssTest.T107_SampleDrawImage(); //demo.Width = 800; //demo.Height = 600; //-------------------------------------------------------------------------------- GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ClearColor(1, 1, 1, 1); //-------------------------------------------------------------------------------- //setup viewport size //set up canvas int ww_w = 800; int ww_h = 600; int max = Math.Max(ww_w, ww_h); //GL.Viewport(0, 0, 800, 600); GL.Viewport(0, 0, max, max); //-------------------------------------------------------------------------------- form1.SetDrawFrameDelegate(() => { demo.Render(); }); //--------------------------------- GlFwForm f2 = GlfwApp.CreateGlfwForm( 800, 600, "Form 2"); f2.MakeCurrent(); f2.Activate(); GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ClearColor(1, 1, 1, 1); //GL.Viewport(0, 0, 800, 600); GL.Viewport(0, 0, max, max); //--------------------------------- f2.SetDrawFrameDelegate(() => { GL.ClearColor(0, 1, 1, 1); }); while (!GlfwApp.ShouldClose()) { //--------------- //render phase and swap GlfwApp.UpdateWindowsFrame(); /* Poll for and process events */ Glfw.PollEvents(); } demo.Close(); Glfw.Terminate(); }
public static void Start() { if (!Glfw.Init()) { Console.WriteLine("can't init glfw"); return; } //--------------------------------------------------- //specific OpenGLES *** Glfw.WindowHint(WindowHint.GLFW_CLIENT_API, (int)OpenGLAPI.OpenGLESAPI); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_CREATION_API, (int)OpenGLContextCreationAPI.GLFW_EGL_CONTEXT_API); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MAJOR, 2); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MINOR, 0); //--------------------------------------------------- Glfw.SwapInterval(1); GlFwForm form1 = GlfwApp.CreateGlfwForm( 800, 600, "PixelFarm + Skia on GLfw and OpenGLES2"); form1.MakeCurrent(); //------------------------------------ //*** GLFWPlatforms.CreateGLESContext(); //------------------------------------ form1.Activate(); int ww_w = 800; int ww_h = 600; int max = Math.Max(ww_w, ww_h); canvasGL2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max); //------------------------------------ GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ClearColor(1, 1, 1, 1); //-------------------------------------------------------------------------------- //setup viewport size //set up canvas needUpdateContent = true; //GL.Viewport(0, 0, 800, 600); GL.Viewport(0, 0, max, max); FormRenderUpdateEventArgs formRenderUpdateEventArgs = new FormRenderUpdateEventArgs(); formRenderUpdateEventArgs.form = form1; form1.SetDrawFrameDelegate(() => { if (needUpdateContent) { UpdateViewContent(formRenderUpdateEventArgs); } canvasGL2d.Clear(Color.Blue); canvasGL2d.DrawImage(glBmp, 0, 600); }); while (!GlfwApp.ShouldClose()) { //--------------- //render phase and swap GlfwApp.UpdateWindowsFrame(); /* Poll for and process events */ Glfw.PollEvents(); } Glfw.Terminate(); }
public static void Start() { //--------------------------------------------------- //register image loader Mini.DemoHelper.RegisterImageLoader(LoadImage); PixelFarm.Platforms.StorageService.RegisterProvider(file_storageProvider); //--------------------------------------------------- if (!Glfw.Init()) { Console.WriteLine("can't init glfw"); return; } //--------------------------------------------------- //specific OpenGLES *** Glfw.WindowHint(WindowHint.GLFW_CLIENT_API, (int)OpenGLAPI.OpenGLESAPI); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_CREATION_API, (int)OpenGLContextCreationAPI.GLFW_EGL_CONTEXT_API); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MAJOR, 2); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MINOR, 0); //--------------------------------------------------- Glfw.SwapInterval(1); GlFwForm form1 = GlfwApp.CreateGlfwForm( 800, 600, "PixelFarm + Skia on GLfw and OpenGLES2"); form1.MakeCurrent(); //------------------------------------ //*** GLFWPlatforms.CreateGLESContext(); //------------------------------------ form1.Activate(); int ww_w = 800; int ww_h = 600; int max = Math.Max(ww_w, ww_h); //------------------------------------ GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ClearColor(1, 1, 1, 1); //-------------------------------------------------------------------------------- //setup viewport size //set up canvas GL.Viewport(0, 0, max, max); FormRenderUpdateEventArgs formRenderUpdateEventArgs = new FormRenderUpdateEventArgs(); formRenderUpdateEventArgs.form = form1; GlfwGLES2 glfwApp = new GlfwGLES2(); form1.SetDrawFrameDelegate(() => { glfwApp.UpdateViewContent(formRenderUpdateEventArgs); }); while (!GlfwApp.ShouldClose()) { //--------------- //render phase and swap GlfwApp.UpdateWindowsFrame(); /* Poll for and process events */ Glfw.PollEvents(); } Glfw.Terminate(); }
public static void Start() { if (!Glfw.Init()) { Console.WriteLine("can't init glfw"); return; } //--------------------------------------------------- //specific OpenGLES *** Glfw.WindowHint(WindowHint.GLFW_CLIENT_API, (int)OpenGLAPI.OpenGLESAPI); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_CREATION_API, (int)OpenGLContextCreationAPI.GLFW_EGL_CONTEXT_API); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MAJOR, 2); Glfw.WindowHint(WindowHint.GLFW_CONTEXT_VERSION_MINOR, 0); //--------------------------------------------------- Glfw.SwapInterval(1); GlFwForm form1 = GlfwApp.CreateGlfwForm( 800, 600, "PixelFarm + Skia on GLfw and OpenGLES2"); form1.MakeCurrent(); //------------------------------------ //*** GLFWPlatforms.CreateGLESContext(); //------------------------------------ form1.Activate(); int ww_w = 800; int ww_h = 600; int max = Math.Max(ww_w, ww_h); canvasGL2d = PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvasGL2d(max, max); //------------------------------------ GL.Enable(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GL.ClearColor(1, 1, 1, 1); //-------------------------------------------------------------------------------- //setup viewport size //set up canvas needUpdateContent = true; //GL.Viewport(0, 0, 800, 600); GL.Viewport(0, 0, max, max); FormRenderUpdateEventArgs formRenderUpdateEventArgs = new FormRenderUpdateEventArgs(); formRenderUpdateEventArgs.form = form1; LayoutFarm.Ease.EaseHost.StartGraphicsHost(); var rootgfx = new MyRootGraphic( LayoutFarm.UI.UIPlatformWinNeutral.platform, LayoutFarm.UI.UIPlatformWinNeutral.platform.GetIFonts(), ww_w, ww_h); var surfaceViewportControl = new LayoutFarm.UI.WinNeutral.UISurfaceViewportControl(); surfaceViewportControl.InitRootGraphics(rootgfx, rootgfx.TopWinEventPortal, InnerViewportKind.GL); //lion fill sample OpenTkEssTest.T108_LionFill lionFill = new OpenTkEssTest.T108_LionFill(); lionFill.Init2(canvasGL2d); GLCanvasPainter painter1 = lionFill.Painter; var myCanvasGL = new PixelFarm.Drawing.GLES2.MyGLCanvas(painter1, 0, 0, 800, 600); //(PixelFarm.Drawing.GLES2.GLES2Platform.CreateCanvas(0, 0, 800, 600, canvasGL2d, painter1); surfaceViewportControl.SetupCanvas(myCanvasGL); SampleViewport viewport = new LayoutFarm.SampleViewport(surfaceViewportControl); HtmlHost htmlHost; htmlHost = HtmlHostCreatorHelper.CreateHtmlHost(viewport, null, null); ////================================================== //html box HtmlBox lightHtmlBox = new HtmlBox(htmlHost, 800, 50); { lightHtmlBox.SetLocation(50, 450); viewport.AddContent(lightHtmlBox); //light box can't load full html //all light boxs of the same lightbox host share resource with the host string html = @"<div>OK1</div><div>OK2</div>"; //if you want to use full html-> use HtmlBox instead lightHtmlBox.LoadHtmlString(html); } form1.SetDrawFrameDelegate(() => { //render each frame if (needUpdateContent) { UpdateViewContent(formRenderUpdateEventArgs); } canvasGL2d.Clear(Color.White); //canvasGL2d.DrawRect(0, 0, 200, 200); ////canvasGL2d.DrawImage(glBmp, 0, 600); //int tmp_x = lightHtmlBox.Left; //int tmp_y = lightHtmlBox.Top; //myCanvasGL.SetCanvasOrigin(tmp_x, tmp_y); canvasGL2d.SmoothMode = CanvasSmoothMode.No; //--------- //flip y axis for html box (and other UI) canvasGL2d.FlipY = true; lightHtmlBox.CurrentPrimaryRenderElement.DrawToThisCanvas( myCanvasGL, new Rectangle(0, 0, 800, 600)); canvasGL2d.FlipY = false; //myCanvasGL.SetCanvasOrigin(tmp_x, -tmp_y); //lion use canvas coordinate system lionFill.TestRender(); //surfaceViewportControl.PaintMe(canvasGL2d); }); while (!GlfwApp.ShouldClose()) { //--------------- //render phase and swap GlfwApp.UpdateWindowsFrame(); /* Poll for and process events */ Glfw.PollEvents(); } Glfw.Terminate(); }