Ejemplo n.º 1
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();
        }
Ejemplo n.º 2
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();
        }
Ejemplo n.º 3
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();
        }
Ejemplo n.º 4
0
 void TearDownGL()
 {
     EAGLContext.SetCurrentContext(context);
     demoContext.Close();
 }