示例#1
0
        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);
        }
示例#2
0
        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();
            }
        }