public void UpdateVerticesData(string name, List <Vector3> data)
        {
            if (data.Count > _objectsHandleDictionary[name].VertexBufferSize)
            {
                CreateVerticesData(name, data, data.Count * 2);
            }
            else
            {
                GL.BindVertexArray(_objectsHandleDictionary[name].ObjectHandle);
                var vertexValuesArray = new float[data.Count * 3];
                var index             = 0;
                foreach (var vertex in data)
                {
                    vertexValuesArray[index++] = vertex.X;
                    vertexValuesArray[index++] = vertex.Y;
                    vertexValuesArray[index++] = vertex.Z;
                }
                var memoryPointer = GL.MapBuffer(BufferTarget.ArrayBuffer, BufferAccess.WriteOnly);
                var byteArray     = new byte[vertexValuesArray.Length * sizeof(float)];
                Buffer.BlockCopy(vertexValuesArray, 0, byteArray, 0, byteArray.Length);
                Marshal.Copy(byteArray, 0, memoryPointer, byteArray.Length);

                GL.UnmapBuffer(BufferTarget.ArrayBuffer);
            }
        }
        public void UpdateInstanceData(string name, List <Matrix4> instanceData)
        {
            if (instanceData.Count > _objectsHandleDictionary[name].InstanceBufferSize)
            {
                CreateInstanceData(name, instanceData, instanceData.Count * 2);
            }
            else
            {
                GL.BindVertexArray(_objectsHandleDictionary[name].ObjectHandle);
                var instancesValuesArray = new float[instanceData.Count * 16];
                var index = 0;
                foreach (var instance in instanceData)
                {
                    instancesValuesArray[index++] = instance.Column0.X;
                    instancesValuesArray[index++] = instance.Column0.Y;
                    instancesValuesArray[index++] = instance.Column0.Z;
                    instancesValuesArray[index++] = instance.Column0.W;

                    instancesValuesArray[index++] = instance.Column1.X;
                    instancesValuesArray[index++] = instance.Column1.Y;
                    instancesValuesArray[index++] = instance.Column1.Z;
                    instancesValuesArray[index++] = instance.Column1.W;

                    instancesValuesArray[index++] = instance.Column2.X;
                    instancesValuesArray[index++] = instance.Column2.Y;
                    instancesValuesArray[index++] = instance.Column2.Z;
                    instancesValuesArray[index++] = instance.Column2.W;

                    instancesValuesArray[index++] = instance.Column3.X;
                    instancesValuesArray[index++] = instance.Column3.Y;
                    instancesValuesArray[index++] = instance.Column3.Z;
                    instancesValuesArray[index++] = instance.Column3.W;
                }
                var memoryPointer = GL.MapBuffer(BufferTarget.ArrayBuffer, BufferAccess.WriteOnly);
                var byteArray     = new byte[instancesValuesArray.Length * sizeof(float)];
                Buffer.BlockCopy(instancesValuesArray, 0, byteArray, 0, byteArray.Length);
                Marshal.Copy(byteArray, 0, memoryPointer, byteArray.Length);

                GL.UnmapBuffer(BufferTarget.ArrayBuffer);
            }
        }
        public void UpdateIndexData(string name, List <int> indices)
        {
            if (indices.Count > _objectsHandleDictionary[name].IndexBufferSize)
            {
                CreateIndexData(name, indices, indices.Count * 2);
            }
            else
            {
                GL.BindVertexArray(_objectsHandleDictionary[name].ObjectHandle);
                var indicesArray = new uint[indices.Count];
                for (int i = 0; i < indices.Count; i++)
                {
                    indicesArray[i] = (uint)indices[i];
                }
                var memoryPointer = GL.MapBuffer(BufferTarget.ElementArrayBuffer, BufferAccess.WriteOnly);
                var byteArray     = new byte[indicesArray.Length * sizeof(uint)];
                Buffer.BlockCopy(indicesArray, 0, byteArray, 0, byteArray.Length);
                Marshal.Copy(byteArray, 0, memoryPointer, byteArray.Length);

                GL.UnmapBuffer(BufferTarget.ElementArrayBuffer);
            }
        }