Exemplo n.º 1
0
 void SetupGL()
 {
     EAGLContext.SetCurrentContext(context);
     max         = Math.Max(view_width, view_height);
     demoContext = new Mini.GLDemoContext(800, 600);
     demoContext.LoadDemo(new OpenTkEssTest.T108_LionFill());
     //--------------------------------------------------------------------------------
     GL.Enable(EnableCap.Blend);
     GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
     GL.ClearColor(1, 1, 1, 1);
     //setup viewport size
     //square viewport
 }
Exemplo n.º 2
0
        public static void Start()
        {
            GlfwWindowEventListener winEventListener = new GlfwWindowEventListener();
            var form = new GlFwForm(800, 600, "hello!", winEventListener);

            form.MakeCurrent();

            string versionStr3 = Marshal.PtrToStringAnsi(Glfw3.glfwGetVersionString());


            OpenTK.Platform.Factory.GetCustomPlatformFactory = () => OpenTK.Platform.Egl.EglAngle.NewFactory();
            OpenTK.Toolkit.Init(new OpenTK.ToolkitOptions {
                Backend = OpenTK.PlatformBackend.PreferNative,
            });
            OpenTK.Graphics.PlatformAddressPortal.GetAddressDelegate = OpenTK.Platform.Utilities.CreateGetAddress();

            //-----------
            IntPtr currentContext = Glfw3.glfwGetCurrentContext();
            var    contextHandler = new OpenTK.ContextHandle(currentContext);

            var glfwContext = new GLFWContextForOpenTK(contextHandler);
            var context     = OpenTK.Graphics.GraphicsContext.CreateExternalContext(glfwContext);


            bool isCurrent   = context.IsCurrent;
            var  demoContext = new Mini.GLDemoContext(800, 600);

            demoContext.LoadDemo(new OpenTkEssTest.T108_LionFill());

            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, max, max);

            //---------
            form.RenderDel = () =>
            {
                demoContext.Render();
                form.SwapBuffers();
            };
            //---------

            GlfwAppLoop.Run();
        }
Exemplo n.º 3
0
        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();
        }
Exemplo n.º 4
0
        public override void UpdateViewContent(FormRenderUpdateEventArgs formRenderUpdateEventArgs)
        {
            //1. create platform bitmap
            // create the surface
            int w = 800;
            int h = 600;

            if (demoContext2 == null)
            {
                //var demo = new T44_SimpleVertexShader();
                //var demo = new T42_ES2HelloTriangleDemo();
                demoContext2 = new Mini.GLDemoContext(w, h);
                demoContext2.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;
                });
                //demoContext2.LoadDemo(new T45_TextureWrap());
                //demoContext2.LoadDemo(new T48_MultiTexture());
                //demoContext2.LoadDemo(new T107_SampleDrawImage());

                demoContext2.LoadDemo(new T110_DrawText());
            }
            demoContext2.Render();
        }
Exemplo n.º 5
0
        void SetupGL()
        {
            MakeCurrent();

            int ww_w = view_width;
            int ww_h = view_height;

            max         = Math.Max(ww_w, ww_h);
            demoContext = new Mini.GLDemoContext(800, 600);
            demoContext.LoadDemo(new OpenTkEssTest.T108_LionFill());
            //--------------------------------------------------------------------------------
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);
            GL.ClearColor(1, 1, 1, 1);
            //setup viewport size

            //square viewport
            GL.Viewport(0, 0, max, max);
        }
Exemplo n.º 6
0
        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 demoContext = new Mini.GLDemoContext(800, 600);

            demoContext.LoadDemo(new OpenTkEssTest.T108_LionFill());


            //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(() =>
            {
                demoContext.Render();
                //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();
            }
            demoContext.Close();
            Glfw.Terminate();
        }
Exemplo n.º 7
0
        public static void Start()
        {
            if (!GLFWPlatforms.Init())
            {
                Console.WriteLine("can't init");
                return;
            }

            GlfwWindowPtr glWindow = Glfw.CreateWindow(800, 600,
                                                       "PixelFarm on GLfw and OpenGLES2",
                                                       new GlfwMonitorPtr(), //default monitor
                                                       new GlfwWindowPtr()); //default top window

            /* Make the window's context current */
            Glfw.MakeContextCurrent(glWindow);


            GlfwWindowPtr currentContext = Glfw.GetCurrentContext();
            var           contextHandler = new OpenTK.ContextHandle(currentContext.inner_ptr);


            OpenTK.Platform.Factory.GetCustomPlatformFactory = () => OpenTK.Platform.Egl.EglAngle.NewFactory();
            OpenTK.Toolkit.Init(new OpenTK.ToolkitOptions
            {
                Backend = OpenTK.PlatformBackend.PreferNative,
            });
            OpenTK.Graphics.PlatformAddressPortal.GetAddressDelegate = OpenTK.Platform.Utilities.CreateGetAddress();

            var glfwContext = new GLFWContextForOpenTK(contextHandler);
            var context     = OpenTK.Graphics.GraphicsContext.CreateExternalContext(glfwContext);

            bool isCurrent = context.IsCurrent;

            PixelFarm.GlfwWinInfo winInfo = new PixelFarm.GlfwWinInfo(glWindow);
            context.MakeCurrent(winInfo);
            //--------------------------------------

            //--------------------------------------
            //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();
            //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, max, max);


            while (!Glfw.WindowShouldClose(glWindow))
            {
                demoContext.Render();
                /* Render here */
                /* Swap front and back buffers */
                Glfw.SwapBuffers(glWindow);
                /* Poll for and process events */
                Glfw.PollEvents();
            }
            demoContext.Close();
            Glfw.Terminate();
        }