public void Render() { if (this.Active) { Matrix4Uniform textProjection = Engine.UniformManager.GetUniform <Matrix4Uniform>("textProjection"); textProjection.Matrix = this.Camera.GetProjectionMatrix(); textProjection.Set(this.GetShader()); Vector3Uniform textColor = Engine.UniformManager.GetUniform <Vector3Uniform>("textColor"); textColor.Value = new Vector3(this.Color.R, this.Color.G, this.Color.B); textColor.Set(this.GetShader()); GL.ActiveTexture(TextureUnit.Texture0); this.vertexArray.Bind(); this.vertexBuffer.Bind(); GL.BufferData(BufferTarget.ArrayBuffer, sizeof(float) * 6 * 4, (IntPtr)null, BufferUsageHint.DynamicDraw); for (int i = 0; i < this.Text.Length; i++) { Font.Character character = this.Font.Characters[this.Text[i]]; GL.BindTexture(TextureTarget.Texture2D, character.TextureId); TextVertex[] subVertices = textVertices.SubArray(i * 6, 6); this.vertexBuffer.Bind(); this.vertexBuffer.BufferSubData((IntPtr)0, TextVertex.Size * subVertices.Length, subVertices); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.DrawArrays(PrimitiveType.Triangles, 0, 6); } } }
public void RenderPool() { if (this.loaded && this.renderCamera != null) { Matrix4 modelview = this.renderCamera.GetViewMatrix(); Matrix4Uniform projectionMatrixUniform = Engine.UniformManager.GetUniform <Matrix4Uniform>("projectionMatrix"); Vector3Uniform cameraPositionUniform = Engine.UniformManager.GetUniform <Vector3Uniform>("cameraPosition"); projectionMatrixUniform.Matrix = Matrix4.Mult(modelview, this.projectionMatrix); cameraPositionUniform.Value = this.renderCamera.GetGameObject().Transform.Position; // Render the pool list foreach (var renderer in this.rendererPool.ToList()) { // Activate shader program and set uniforms ShaderProgram rendererShader = renderer.GetShader(); rendererShader.Use(); projectionMatrixUniform.Set(rendererShader); cameraPositionUniform.Set(rendererShader); Engine.Game.CurrentScene.SetShadingUniforms(rendererShader); renderer.Render(); } } }