void MeshRenderer::Update(GameTime* gameTime,GraphicsDevice* graphicsDevice)
{
	int drawCalls = 0;
	int triangles = 0;
	if(_mesh != NULL)
	{
		VertexBuffer* vertexBuffer = _mesh->GetVertexBuffer();
		IndexBuffer* indexBuffer = _mesh->GetIndexBuffer();
		
		//Set the per object uniforms of the game object(for example - the world matrix)
		_material->SetObjectUniforms(graphicsDevice, GetGameObject());

		vertexBuffer->BindBuffer();
		//Draw the mesh
		unsigned int numberOfAttributeInformations = vertexBuffer->GetNumberOfAttributeInfos();
		for(unsigned int i = 0; i < numberOfAttributeInformations; i++)
		{
			const VertexAttributeInformation& thisInfo = vertexBuffer->GetVertexAttributeInformation(i);
			graphicsDevice->EnableVertexAttribute(thisInfo.GetIndex());
			graphicsDevice->SetVertexAttribute(thisInfo.GetIndex(), 
							  thisInfo.GetSize(), 
							  thisInfo.GetType(),
							  thisInfo.GetIsNormalized(), 
							  thisInfo.GetStride(), 
							  thisInfo.GetOffset());
		}

		//Bind the index buffer
		indexBuffer->BindBuffer();
		//DRAW
		graphicsDevice->DrawElements(GraphicsPrimitiveType::Triangles(), indexBuffer->GetNumberOfElements(), indexBuffer->GetIndexDataType(), (void*)0);
		drawCalls++;
		triangles += indexBuffer->GetNumberOfElements() / 3;

		for(unsigned int i = 0; i < numberOfAttributeInformations; i++)
		{
			graphicsDevice->DisableVertexAttribute(vertexBuffer->GetVertexAttributeInformation(i).GetIndex());
		}
		indexBuffer->UnbindBuffer();
		vertexBuffer->UnbindBuffer();
	}
	SetNumberOfDrawCalls(drawCalls);
	SetNumberOfTriangles(triangles);
}