public void RenderObject() { // set up float[] vertices = new float[] { -0.5f, -0.5f, 0.0f, 0.5f, -0.5f, 0.0f, 0.0f, 0.5f, 0.0f }; int vao; VertexBufferObject <float> vbo; GL.GenVertexArrays(1, out vao); vbo = new VertexBufferObject <float>(sizeof(float), vertices); GL.BindVertexArray(vao); vbo.BindBuffer(); vbo.CreateBuffer(BufferUsageHint.StaticDraw); GL.VertexAttribPointer(0, 3, VertexAttribPointerType.Float, false, 3 * sizeof(float), 0); GL.EnableVertexAttribArray(0); GL.BindBuffer(BufferTarget.ArrayBuffer, 0); GL.BindVertexArray(0); //actual renderering GL.ClearColor(OpenTK.Graphics.Color4.CornflowerBlue); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); shaderMgr.InitialiseAShader("test1"); shaderMgr.GetShader("test1").Use(); GL.BindVertexArray(vao); vbo.Draw(PrimitiveType.Triangles); GL.BindVertexArray(0); }
public void RenderObject(VertexBufferObject <Vertex> vbo, VertexArrayObject <Vertex> vao, int shaderIndex, Matrix4 modelTransform, int textureIndex) { ApplySettingsNow(); if (!depthteston) { GL.Enable(EnableCap.DepthTest); depthteston = true; } GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); shaderMgr.InitialiseAShader(shaderIndex); Uniform.Matrix4Uniform model = new Uniform.Matrix4Uniform("model"); model.Matrix = modelTransform; Uniform.Matrix4Uniform view = new Uniform.Matrix4Uniform("view"); view.Matrix = cameraMgr.GetActiveCamera().GetVeiwMatrix(); Uniform.Matrix4Uniform projection = new Uniform.Matrix4Uniform("projection"); projection.Matrix = GetProjectionMatrix(); Shader shader = shaderMgr.GetShader(shaderIndex); shader.Use(); model.Set(shader); view.Set(shader); projection.Set(shader); GL.ActiveTexture(TextureUnit.Texture0); textureMgr.GetTexture(textureIndex).BindTexture(); textureMgr.GetTexture(textureIndex).ActivateTexture(TextureUnit.Texture0, shader, "theTexture", 0); vao.Bind(); vbo.BindBuffer(); vbo.Draw(PrimitiveType.Triangles); }
public void Draw(GraphicsDevice device) { foreach (Structure h in Structures) { h.Draw(device); } roadObject?.Draw(device); }
public void RenderObject(VertexBufferObject <Vertex> item, VertexArrayObject <Vertex> vao, int shaderIndex) { if (settingschanged) { ApplySettingsNow(); } GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); shaderMgr.InitialiseAShader(shaderIndex); Shader shader = shaderMgr.GetShader(shaderIndex); shader.Use(); vao.Bind(); item.BindBuffer(); item.Draw(PrimitiveType.Triangles); }
public void RenderObject(VertexBufferObject <Vertex> vbo, VertexArrayObject <Vertex> vao, int shaderIndex, Matrix4 modelTransform) { ApplySettingsNow(); GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); shaderMgr.InitialiseAShader(shaderIndex); Uniform.Matrix4Uniform model = new Uniform.Matrix4Uniform("model"); model.Matrix = modelTransform; Uniform.Matrix4Uniform view = new Uniform.Matrix4Uniform("view"); view.Matrix = cameraMgr.GetActiveCamera().GetVeiwMatrix(); Uniform.Matrix4Uniform projection = new Uniform.Matrix4Uniform("projection"); projection.Matrix = GetProjectionMatrix(); Shader shader = shaderMgr.GetShader(shaderIndex); shader.Use(); model.Set(shader); view.Set(shader); projection.Set(shader); vao.Bind(); vbo.BindBuffer(); vbo.Draw(PrimitiveType.Triangles); }