Exemple #1
0
        public void Render(SharpGL.OpenGL gl, SharpGL.SceneGraph.Core.RenderMode renderMode)
        {
            // update matrix and bind shader program
            mat4 projectionMatrix = camera.GetProjectionMat4();

            mat4 viewMatrix = camera.GetViewMat4();

            mat4 modelMatrix = glm.scale(mat4.identity(), new vec3(1, 1, this.ZAxisScale));

            shaderProgram.Bind(gl);

            shaderProgram.SetUniformMatrix4(gl, strprojectionMatrix, projectionMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, strviewMatrix, viewMatrix.to_array());
            shaderProgram.SetUniformMatrix4(gl, strmodelMatrix, modelMatrix.to_array());

            gl.BindVertexArray(vao[0]);

            // 启用Primitive restart
            gl.Enable(OpenGL.GL_PRIMITIVE_RESTART);
            gl.PrimitiveRestartIndex(uint.MaxValue);// 截断图元(四边形带、三角形带等)的索引值。

            //GL.DrawArrays(primitiveMode, 0, vertexCount);
            gl.DrawElements((uint)primitiveMode, vertexCount + (this.pipe.Count - 1) * 2, OpenGL.GL_UNSIGNED_INT, IntPtr.Zero);

            gl.BindVertexArray(0);

            gl.Disable(OpenGL.GL_PRIMITIVE_RESTART);

            // unbind shader program
            shaderProgram.Unbind(gl);
        }