Commits

Alex Szpakowski committed e0ec6b6

Fixed love.graphics.newMesh(vertexcount, ...) trying to use glDrawArraysInstanced sometimes, fixed Mesh:getVertexMap.

Comments (0)

Files changed (1)

src/modules/graphics/opengl/Mesh.cpp

 	, ibo(nullptr)
 	, element_count(0)
 	, element_data_type(getGLDataTypeFromMax(vertexcount))
+	, instance_count(1)
 	, draw_mode(mode)
 	, range_min(-1)
 	, range_max(-1)
  * Copies index data from a mapped buffer to a vector.
  **/
 template <typename T>
-static void copyFromIndexBuffer(void *buffer, std::vector<uint32> &indices, size_t maxval)
+static void copyFromIndexBuffer(void *buffer, size_t count, std::vector<uint32> &indices)
 {
 	T *elems = (T *) buffer;
-	for (size_t i = 0; i < maxval; i++)
+	for (size_t i = 0; i < count; i++)
 		indices.push_back((uint32) elems[i]);
 }
 
 	switch (element_data_type)
 	{
 	case GL_UNSIGNED_BYTE:
-		copyFromIndexBuffer<uint8>(buffer, map, vertex_count);
+		copyFromIndexBuffer<uint8>(buffer, element_count, map);
 		break;
 	case GL_UNSIGNED_SHORT:
-		copyFromIndexBuffer<uint16>(buffer, map, vertex_count);
+		copyFromIndexBuffer<uint16>(buffer, element_count, map);
 		break;
 	case GL_UNSIGNED_INT:
 	default:
-		copyFromIndexBuffer<uint32>(buffer, map, vertex_count);
+		copyFromIndexBuffer<uint32>(buffer, element_count, map);
 		break;
 	}
 }