private void CreateInstanceData(string name, List <Matrix4> instanceData, int bufferSize) { GL.BindVertexArray(_objectsHandleDictionary[name].ObjectHandle); var instancesArray = instanceData.ToArray(); GL.BindBuffer(BufferTarget.ArrayBuffer, _objectsHandleDictionary[name].InstanceBufferHandle); GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(bufferSize * 4 * Vector4.SizeInBytes), instancesArray, BufferUsageHint.DynamicDraw); _objectsHandleDictionary[name].InstanceBufferSize = bufferSize; }
private void CreateVerticesData(string name, List <Vector3> data, int bufferSize) { GL.BindVertexArray(_objectsHandleDictionary[name].ObjectHandle); var verticesArray = data.ToArray(); GL.BindBuffer(BufferTarget.ArrayBuffer, _objectsHandleDictionary[name].VertexBufferHandle); GL.BufferData(BufferTarget.ArrayBuffer, new IntPtr(bufferSize * Vector3.SizeInBytes), verticesArray, BufferUsageHint.DynamicDraw); _objectsHandleDictionary[name].VertexBufferSize = bufferSize; }
private void CreateIndexData(string name, List <int> indices, int bufferSize) { GL.BindVertexArray(_objectsHandleDictionary[name].ObjectHandle); var indicesArray = new uint[indices.Count]; for (int i = 0; i < indices.Count; i++) { indicesArray[i] = (uint)indices[i]; } GL.BindBuffer(BufferTarget.ElementArrayBuffer, _objectsHandleDictionary[name].IndexBufferHandle); GL.BufferData(BufferTarget.ElementArrayBuffer, new IntPtr(bufferSize * sizeof(uint)), indicesArray, BufferUsageHint.DynamicDraw); _objectsHandleDictionary[name].IndexBufferSize = bufferSize; }