Exemple #1
0
        protected override void DoRender(RenderEventArgs e)
        {
            CSharpGL.Objects.Texture2D texture = this.texture;
            texture.Bind();

            if (this.blend)
            {
                GL.Enable(GL.GL_BLEND);
                GL.BlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
            }

            ShaderProgram shaderProgram = this.shaderProgram;

            shaderProgram.Bind();
            GL.ActiveTexture(GL.GL_TEXTURE0);
            GL.Enable(GL.GL_TEXTURE_2D);
            texture.Bind();
            shaderProgram.SetUniform(strtex, 0);
            shaderProgram.SetUniform(WholeFontTextureElement.strcolor, 1.0f, 1.0f, 1.0f, 1.0f);
            shaderProgram.SetUniformMatrix4("MVP", (projectionMatrix * viewMatrix * modelMatrix).to_array());

            GL.BindVertexArray(vao[0]);
            GL.DrawArrays(this.mode, 0, this.vertexCount);
            GL.BindVertexArray(0);

            texture.Unbind();
            shaderProgram.Unbind();

            GL.BindTexture(GL.GL_TEXTURE_2D, 0);

            if (this.blend)
            {
                GL.Disable(GL.GL_BLEND);
            }
        }
Exemple #2
0
        void element_BeforeRendering(object sender, Objects.RenderEventArgs e)
        {
            CSharpGL.Objects.Texture2D texture = element.texture;
            texture.Bind();

            if (element.blend)
            {
                GL.Enable(GL.GL_BLEND);
                GL.BlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
            }

            mat4 modelMatrix      = mat4.identity();
            mat4 viewMatrix       = this.camera.GetViewMat4();
            mat4 projectionMatrix = this.camera.GetProjectionMat4();

            ShaderProgram shaderProgram = element.shaderProgram;

            shaderProgram.Bind();
            shaderProgram.SetUniform(WholeFontTextureElement.strtex, texture.Name);
            shaderProgram.SetUniform(WholeFontTextureElement.strcolor, 1.0f, 1.0f, 1.0f, 1.0f);

            IMVP iMVP = element as IMVP;

            iMVP.SetShaderProgram(projectionMatrix * viewMatrix * modelMatrix);
        }