protected override void DoRender(RenderEventArgs e) { mat4 projectionMatrix, viewMatrix, modelMatrix; { IUILayout element = this as IUILayout; element.GetMatrix(out projectionMatrix, out viewMatrix, out modelMatrix, e.Camera); } this.axisElement.mvp = projectionMatrix * viewMatrix * modelMatrix; this.axisElement.Render(e); }
static void SimpleUI_BeforeRendering(object sender, RenderEventArgs e) { mat4 projectionMatrix, viewMatrix, modelMatrix; { IUILayout element = sender as IUILayout; element.GetMatrix(out projectionMatrix, out viewMatrix, out modelMatrix, e.Camera); } { IMVP element = sender as IMVP; element.SetShaderProgram(projectionMatrix * viewMatrix * modelMatrix); } }
protected override void DoRender(RenderEventArgs e) { mat4 projectionMatrix, viewMatrix, modelMatrix; { IUILayout element = this as IUILayout; element.GetMatrix(out projectionMatrix, out viewMatrix, out modelMatrix, e.Camera); } this.shaderProgram.Bind(); this.shaderProgram.SetUniformMatrix4("MVP", (projectionMatrix * viewMatrix * modelMatrix).to_array()); GL.BindVertexArray(vao[0]); GL.DrawArrays(this.axisPrimitiveMode, 0, this.axisVertexCount); GL.BindVertexArray(0); this.shaderProgram.Unbind(); }
protected override void DoRender(RenderEventArgs e) { mat4 projectionMatrix, viewMatrix, modelMatrix; { IUILayout element = this as IUILayout; element.GetMatrix(out projectionMatrix, out viewMatrix, out modelMatrix, e.Camera); } this.shaderProgram.Bind(); this.shaderProgram.SetUniformMatrix4(strMVP, (projectionMatrix * viewMatrix * modelMatrix).to_array()); // 记录当前多边形状态 int[] polygonMode = new int[2]; GL.GetInteger(GetTarget.PolygonMode, polygonMode); GL.BindVertexArray(vao[0]); // 画面 GL.PolygonMode(PolygonModeFaces.FrontAndBack, PolygonModes.Filled); GL.DrawArrays(this.axisPrimitiveMode, 0, this.vertexCount); // 启用静态顶点属性 GL.DisableVertexAttribArray(in_ColorLocation); GL.VertexAttrib3(in_ColorLocation, 1.0f, 1.0f, 1.0f); // 画线 GL.PolygonMode(PolygonModeFaces.FrontAndBack, PolygonModes.Lines); GL.DrawArrays(this.axisPrimitiveMode, 0, this.vertexCount); // 恢复顶点属性数组 GL.EnableVertexAttribArray(in_ColorLocation); GL.BindVertexArray(0); // 恢复多边形状态 GL.PolygonMode(PolygonModeFaces.Front, (PolygonModes)polygonMode[0]); GL.PolygonMode(PolygonModeFaces.Back, (PolygonModes)polygonMode[1]); this.shaderProgram.Unbind(); }