Beispiel #1
0
        protected override void DoRender(RenderEventArgs e)
        {
            if (this.axisVAO == null)
            {
                this.axisVAO = new VertexArrayObject[3];
                for (int i = 0; i < 3; i++)
                {
                    var vao = new VertexArrayObject(this.positionBufferRenderers[i], this.colorBufferRenderers[i], this.indexBufferRenderers[i]);
                    vao.Create(e, this.shaderProgram);

                    this.axisVAO[i] = vao;
                }

                {
                    var vao = new VertexArrayObject(this.planPositionBufferRenderer, planColorBufferRenderer, this.planIndexBufferRenderer);
                    vao.Create(e, this.shaderProgram);

                    this.planVAO = vao;
                }
            }

            // 绑定shader
            this.shaderProgram.Bind();

            // 画坐标轴
            for (int i = 0; i < 3; i++)
            {
                this.axisVAO[i].Render(e, this.shaderProgram);
            }
            // 画平面
            {
                this.planVAO.Render(e, this.shaderProgram);
            }

            // 解绑shader
            this.shaderProgram.Unbind();
        }
Beispiel #2
0
        protected override void DoRender(RenderEventArgs e)
        {
            

            ShaderProgram program = this.shaderProgram;
            // 绑定shader
            program.Bind();

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

            int[] originalPolygonMode = new int[1];
            GL.GetInteger(GetTarget.PolygonMode, originalPolygonMode);

            GL.PolygonMode(PolygonModeFaces.FrontAndBack, this.polygonMode);
            if (this.vertexArrayObject == null)
            {
                var vao = new VertexArrayObject(
                    this.positionBufferRenderer,
                    //this.colorBufferRenderer,
                    this.normalBufferRenderer,
                    this.indexBufferRenderer);
                vao.Create(e, this.shaderProgram);

                this.vertexArrayObject = vao;
            }
            else
            {
                this.vertexArrayObject.Render(e, this.shaderProgram);
            }
            GL.PolygonMode(PolygonModeFaces.FrontAndBack, (PolygonModes)(originalPolygonMode[0]));

            // 解绑shader
            program.Unbind();
        }