internal VertexBufferArray(string name, int id, VertexBufferLayoutKind[] vblk, VertexBuffer vb, IndexBuffer ib = null) : base(name, id, GraphicsResourceType.VertexBufferArray) { _LayoutElements = new List<VertexBufferLayoutKind[]>(); _InternalBuffers = new List<VertexBuffer>(); VertexBufferLayoutKind[] layout = new VertexBufferLayoutKind[vblk.Length]; Array.Copy(vblk, layout, layout.Length); _LayoutElements.Add(layout); _InternalBuffers.Add(vb); vb.SetUseCount(vb.InternalUseCount + 1); _InternalOptionalIndexBuffer = ib; if(ib != null) _InternalOptionalIndexBuffer.SetUseCount(_InternalOptionalIndexBuffer.InternalUseCount + 1); }
public void AddVertexBuffer(VertexBufferLayoutKind[] vblk, VertexBuffer vb) { if (!m_PrepareMode) { GL.BindVertexArray(ID); } if (vb.Created) { GL.BindBuffer(BufferTarget.ArrayBuffer, vb.ID); for (int i = 0; i < vblk.Length; i++) { GL.EnableVertexAttribArray(vblk[i].AttributeID); GL.VertexAttribPointer(vblk[i].AttributeID, vblk[i].AttributeSize, (VertexAttribPointerType)vblk[i].AttributeType, vblk[i].Normalized, vblk[i].Stride, (IntPtr)vblk[i].Offset); } VertexBufferLayoutKind[] layout = new VertexBufferLayoutKind[vblk.Length]; Array.Copy(vblk, layout, layout.Length); _LayoutElements.Add(layout); _InternalBuffers.Add(vb); vb.SetUseCount(vb.InternalUseCount + 1); } if(!m_PrepareMode) { GL.BindVertexArray(0); } }