public override void PrepareInstanced(RendererContext rc, VertexBufferLayoutKind[] vblks, VertexBuffer vb) { if (MyModel != null) { foreach (Mesh msh in MyModel.Meshes) { msh.m_VertexBufferArray.BindVertexBufferArray(); vb.BindBuffer(); foreach (VertexBufferLayoutKind vblk in vblks) { rc.EnableVertexAttribute((int)vblk.AttributeID); rc.VertexAttributePointer(vblk); rc.VertexAttributeDivisor((int)vblk.AttributeID, 1); } vb.UnbindBuffer(); msh.m_VertexBufferArray.UnbindVertexBufferArray(); } } else this.ErrorCount++; }
/// <summary> /// Updates the buffers in GPU memory. /// </summary> /// <param name="gl">The GL.</param> public void UpdateGeometry(OpenGL gl) { var verts = Vertices.SelectMany(v => v.to_array()).ToArray(); var norms = Normals.SelectMany(v => v.to_array()).ToArray(); VertexBuffer.BindBuffer(gl); // gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, VertexBufferId.Value); VertexBuffer.SetBufferData(gl, OGLBufferDataTarget.ArrayBuffer, verts, Usage, 3); // gl.BufferData(OpenGL.GL_ARRAY_BUFFER, verts, (uint)Usage); NormalBuffer.BindBuffer(gl); // gl.BindBuffer(OpenGL.GL_ARRAY_BUFFER, NormalBufferId.Value); NormalBuffer.SetBufferData(gl, OGLBufferDataTarget.ArrayBuffer, norms, Usage, 3); // gl.BufferData(OpenGL.GL_ARRAY_BUFFER, norms, (uint)Usage); }
public override void PrepareInstanced(RendererContext rc, VertexBufferLayoutKind[] vblks, VertexBuffer vb) { rc._2DVertexBufferArray.BindVertexBufferArray(); vb.BindBuffer(); for (int i = 0; i < vblks.Length; i++) { rc.EnableVertexAttribute((int)vblks[i].AttributeID); rc.VertexAttributePointer(vblks[i]); rc.VertexAttributeDivisor((int)vblks[i].AttributeID, 1); } vb.UnbindBuffer(); rc._2DVertexBufferArray.UnbindVertexBufferArray(); }