示例#1
0
        protected override void OnResize(EventArgs e)
        {
            // Update viewport and camera settings
            GL.Viewport(0, 0, Width, Height);
            camera.Perspective(Width, Height, (float)Math.PI / 4, 1f, 1000);

            // Release old and generate new framebuffer
            fbo.Release();
            if (msaa)
            {
                fbo = new Framebuffer(Width, Height, msaaLevel);
            }
            else
            {
                fbo = new Framebuffer(Width, Height, 0);
            }
        }
示例#2
0
        protected override void OnKeyPress(KeyPressEventArgs e)
        {
            base.OnKeyPress(e);

            if (e.KeyChar == 'r')
            {
                if(msaa)
                {
                    fbo.Release();
                    fbo = new Framebuffer(Width, Height, 0);
                }
                blur = false;
                msaa = false;
                fxaa = false;
            }
            if(e.KeyChar == 'b')
            {
                if (msaa)
                {
                    fbo.Release();
                    fbo = new Framebuffer(Width, Height, 0);
                }
                blur = true;
                msaa = false;
                fxaa = false;
            }
            if (e.KeyChar == 'f')
            {
                if (msaa)
                {
                    fbo.Release();
                    fbo = new Framebuffer(Width, Height, 0);
                }
                blur = false;
                msaa = false;
                fxaa = true;
            }
            if (e.KeyChar == 'm')
            {
                if (!msaa)
                {
                    fbo.Release();
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                }
                blur = false;
                msaa = true;
                fxaa = false;
            }
            if(msaa)
            {
                if (e.KeyChar == '1')
                {
                    fbo.Release();
                    msaaLevel = 1;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '2')
                {
                    fbo.Release();
                    msaaLevel = 2;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '3')
                {
                    fbo.Release();
                    msaaLevel = 4;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '4')
                {
                    fbo.Release();
                    msaaLevel = 8;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '5')
                {
                    fbo.Release();
                    msaaLevel = 16;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '6')
                {
                    fbo.Release();
                    msaaLevel = 32;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '7')
                {
                    fbo.Release();
                    msaaLevel = 64;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '8')
                {
                    fbo.Release();
                    msaaLevel = 128;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
                if (e.KeyChar == '9')
                {
                    fbo.Release();
                    msaaLevel = 256;
                    fbo = new Framebuffer(Width, Height, msaaLevel);
                    msaaLevel = fbo.MSAA;
                }
            }
        }
示例#3
0
        protected override void OnLoad(EventArgs e)
        {
            // Initialize GL settings
            GPUCapabilities.Initialize();
            GLState.DepthTest = true;
            GLState.CullFace = true;
            GLState.BlendFunc(BlendingFactorSrc.DstAlpha, BlendingFactorDest.OneMinusDstAlpha);

            PackageManager.BasePath = "../../Assets/";

            // Load shaders
            ShaderManager.LoadCollection("Shaders/collection.xml");
            fboShader = ShaderManager.Get("framebufferexample");
            blurShader = ShaderManager.Get("framebufferexample.blur");
            msaaShader = ShaderManager.Get("framebufferexample.msaa");
            fxaaShader = ShaderManager.Get("framebufferexample.fxaa");

            // Initialize framebuffer
            if(msaa)
            {
                fbo = new Framebuffer(Width, Height, 32);
            }
            else
            {
                fbo = new Framebuffer(Width, Height, 0);
            }

            // Load other stuff
            LoadMeshStuff();

            textShader = ShaderManager.Get("Text");

            font = new Font();
            font.LoadBMFont("Fonts/OpenSans-Regular.ttf_sdf.txt");
            font.Texture = textures.Get("Textures/OpenSans-Regular.ttf_sdf.tex", true);

            text = new GuiText();
            text.Font = font;
            text.Text = GenerateInfoText();
        }