Пример #1
0
        protected void DrawLayer(Matrix4 offset, int layer, TextureArray2D texture)
        {
            Debug.Assert(texture != null);

            var finalTransform = offset * GetTransform();

            // draw the checkers background
            models.GlData.CheckersShader.Bind(finalTransform);
            models.GlData.Vao.DrawQuad();

            // blend over the final image
            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            shader.Bind();
            shader.SetTransform(finalTransform);
            shader.SetLayer(layer);
            shader.SetMipmap(models.Display.ActiveMipmap);
            shader.SetGrayscale(models.Display.Grayscale);
            shader.SetCrop(models.Export, layer);

            models.GlData.BindSampler(shader.GetTextureLocation(), true, models.Display.LinearInterpolation);
            texture.Bind(shader.GetTextureLocation());

            models.GlData.Vao.DrawQuad();

            // disable everything
            GL.Disable(EnableCap.Blend);
            Program.Unbind();
        }
Пример #2
0
        public override void Draw(TextureArray2D texture)
        {
            // this will draw the checkers background
            base.Draw(texture);

            GL.Enable(EnableCap.Blend);
            GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha);

            // bind shader
            shader.Bind();
            shader.SetTransform(GetTransform());
            shader.SetMipmap((float)models.Display.ActiveMipmap);
            shader.SetLayer((float)models.Display.ActiveLayer);
            shader.SetFarplane(CalcFarplane());
            shader.SetGrayscale(models.Display.Grayscale);
            shader.SetCrop(models.Export, models.Display.ActiveLayer);

            models.GlData.BindSampler(shader.GetTextureLocation(), true, models.Display.LinearInterpolation);
            texture.Bind(shader.GetTextureLocation());

            models.GlData.Vao.DrawQuad();

            GL.Disable(EnableCap.Blend);
            Program.Unbind();
        }
Пример #3
0
 public void BindSourceImage(TextureArray2D texture, Sampler sampler, int id)
 {
     sampler.Bind(TextureBindingStart + id);
     texture.Bind(TextureBindingStart + id);
     // set srgb variable
     shader.Bind();
     GL.Uniform1(TextureSrgbStart + id, texture.IsSrgb?1:0);
 }
Пример #4
0
        protected override void OnRenderFrame(FrameEventArgs e)
        {
            GL.Enable(EnableCap.DepthTest);
            GL.Enable(EnableCap.CullFace);

            GL.ClearColor(Color.CornflowerBlue);
            GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit | ClearBufferMask.StencilBufferBit);

            shader.Bind();

            Matrix4 worldMat = Matrix4.Identity;

            GL.UniformMatrix4(0, false, ref worldMat);
            GL.UniformMatrix4(4, false, ref camera.view);
            GL.UniformMatrix4(8, false, ref projection);

            textureArray.Bind(TextureUnit.Texture0);

            WorldRenderer.RenderWorld(world);

            SwapBuffers();
        }