Beispiel #1
0
        public override void Run()
        {
            if (nop)
            {
                return;
            }

            GL.SetClearColor(Color.FromArgb(BackgroundColor));
            GL.Clear(OpenTK.Graphics.OpenGL.ClearBufferMask.ColorBufferBit);

            GuiRenderer.Begin(OutputSize.Width, OutputSize.Height);
            GuiRenderer.SetBlendState(GL.BlendNone);
            GuiRenderer.Modelview.Push();
            //GuiRenderer.Modelview.Translate(LL.vx, LL.vy);
            //GuiRenderer.Modelview.Scale(LL.WidthScale, LL.HeightScale);
            if (FilterOption != eFilterOption.None)
            {
                InputTexture.SetFilterLinear();
            }
            else
            {
                InputTexture.SetFilterNearest();
            }

            if (FilterOption == eFilterOption.Bicubic)
            {
            }


            GuiRenderer.Draw(InputTexture, LL.vx, LL.vy, LL.vw, LL.vh);

            GuiRenderer.End();
        }
Beispiel #2
0
        public override void Run()
        {
            GuiRenderer renderer = FilterProgram.GuiRenderer;

            renderer.Begin(FindOutput().SurfaceFormat.Size);
            renderer.SetBlendState(FilterProgram.GL.BlendNone);
            renderer.Draw(InputTexture);
            renderer.End();
        }
Beispiel #3
0
        static unsafe void Main(string[] args)
        {
            BizHawk.Bizware.BizwareGL.IGL igl = new BizHawk.Bizware.BizwareGL.Drivers.OpenTK.IGL_TK();

            List <Art> testArts = new List <Art>();
            ArtManager am       = new ArtManager(igl);

            foreach (var name in typeof(Program).Assembly.GetManifestResourceNames())
            {
                if (name.Contains("flame"))
                {
                    testArts.Add(am.LoadArt(typeof(Program).Assembly.GetManifestResourceStream(name)));
                }
            }
            var smile = am.LoadArt(typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Bizware.Test.TestImages.smile.png"));

            am.Close(true);
            StringRenderer sr;

            using (var xml = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Bizware.Test.TestImages.courier16px.fnt"))
                using (var tex = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Bizware.Test.TestImages.courier16px_0.png"))
                    sr = new StringRenderer(igl, xml, tex);

            GuiRenderer gr = new GuiRenderer(igl);

            TestForm tf = new TestForm();
            RetainedGraphicsControl c = new RetainedGraphicsControl(igl);

            tf.Controls.Add(c);
            c.Dock          = System.Windows.Forms.DockStyle.Fill;
            tf.FormClosing += (object sender, System.Windows.Forms.FormClosingEventArgs e) =>
            {
                tf.Controls.Remove(c);
                c.Dispose();
                c = null;
            };
            tf.Show();

            //tf.Paint += (object sender, PaintEventArgs e) => c.Refresh();

            c.SetVsync(false);

            //create a render target
            RenderTarget rt = igl.CreateRenderTarget(60, 60);

            rt.Bind();
            igl.SetClearColor(Color.Blue);
            igl.Clear(ClearBufferMask.ColorBufferBit);
            gr.Begin(60, 60, true);
            gr.Draw(smile);
            gr.End();
            rt.Unbind();

            Texture2d rttex2d = igl.LoadTexture(rt.Texture2d.Resolve());

            //test retroarch shader
            RenderTarget rt2 = igl.CreateRenderTarget(240, 240);

            rt2.Bind();
            igl.SetClearColor(Color.CornflowerBlue);
            igl.Clear(ClearBufferMask.ColorBufferBit);
            RetroShader shader;

            using (var stream = typeof(Program).Assembly.GetManifestResourceStream("BizHawk.Bizware.Test.TestImages.4xSoft.glsl"))
                shader = new RetroShader(igl, new System.IO.StreamReader(stream).ReadToEnd());
            igl.SetBlendState(igl.BlendNone);
            shader.Run(rttex2d, new Size(60, 60), new Size(240, 240), true);


            bool running = true;

            c.MouseClick += (object sender, MouseEventArgs e) =>
            {
                if (e.Button == MouseButtons.Left)
                {
                    running ^= true;
                }
                if (e.Button == MouseButtons.Right)
                {
                    c.Retain ^= true;
                }
            };

            DateTime start  = DateTime.Now;
            int      wobble = 0;

            for (; ;)
            {
                if (c == null)
                {
                    break;
                }

                if (running)
                {
                    c.Begin();

                    igl.SetClearColor(Color.Red);
                    igl.Clear(ClearBufferMask.ColorBufferBit);

                    int frame = (int)((DateTime.Now - start).TotalSeconds) % testArts.Count;

                    gr.Begin(c.ClientSize.Width, c.ClientSize.Height);

                    gr.SetModulateColor(Color.Green);
                    gr.RectFill(250, 0, 16, 16);

                    gr.SetBlendState(igl.BlendNone);
                    gr.Draw(rttex2d, 0, 20);
                    gr.SetBlendState(igl.BlendNormal);

                    sr.RenderString(gr, 0, 0, "?? fps");
                    gr.SetModulateColor(Color.FromArgb(255, 255, 255, 255));
                    gr.SetCornerColor(0, OpenTK.Graphics.Color4.Red);
                    gr.Draw(rt2.Texture2d, 0, 0);
                    gr.SetCornerColor(0, OpenTK.Graphics.Color4.White);
                    gr.SetModulateColorWhite();
                    gr.Modelview.Translate((float)Math.Sin(wobble / 360.0f) * 50, 0);
                    gr.Modelview.Translate(100, 100);
                    gr.Modelview.Push();
                    gr.Modelview.Translate(testArts[frame].Width, 0);
                    gr.Modelview.Scale(-1, 1);
                    wobble++;
                    gr.SetModulateColor(Color.Yellow);
                    gr.DrawFlipped(testArts[frame], true, false);
                    gr.SetModulateColorWhite();
                    gr.Modelview.Pop();
                    gr.SetBlendState(igl.BlendNormal);
                    gr.Draw(smile);

                    gr.End();


                    c.SwapBuffers();
                    c.End();
                }

                System.Windows.Forms.Application.DoEvents();
                System.Threading.Thread.Sleep(0);
            }
        }