public void DrawScreenTexture(Texture2D texture, Shader shader, SamplerObject sampler)
        {
            if (texture == null)
            {
                return;
            }

            // Always check program creation before using shaders to prevent crashes.
            if (!shader.LinkStatusIsOk)
            {
                return;
            }

            // Render using the shader.
            shader.UseProgram();

            // The sampler's parameters are used instead of the texture's parameters.
            int textureUnit = 0;

            sampler.Bind(textureUnit);

            shader.SetInt("attributeIndex", 1);
            Matrix4 matrix4 = Matrix4.Identity;

            shader.SetMatrix4x4("mvpMatrix", ref matrix4);

            shader.SetTexture("uvTexture", texture, textureUnit);

            GL.Disable(EnableCap.DepthTest);

            Draw(shader);
        }
示例#2
0
        public static void DrawTexture(Texture texture)
        {
            if (triangle == null)
            {
                triangle = new ScreenTriangle();
            }
            if (sampler == null)
            {
                sampler = new SamplerObject {
                    MagFilter = TextureMagFilter.Nearest, MinFilter = TextureMinFilter.Nearest
                }
            }
            ;

            var shader = ShaderContainer.GetShader("ScreenTexture");

            shader.UseProgram();

            sampler.Bind(0);
            shader.SetTexture("image", texture, 0);

            triangle.Draw(shader);
        }