Added instancing support to Meshes via Mesh:setInstanceCount. Added a new built-in variable to vertex shaders: int love_InstanceID.

love.graphics.draw(mesh) will draw the mesh instancecount times, using hardware instancing when available. The only way to draw individual instances differently from each other is to use the love_InstanceID variable in a vertex shader.

Added love.graphics.isSupported(“instancing”). Hardware instancing is supported if true, otherwise a (slower) pseudo-instancing fallback is used internally when drawing instanced meshes.
This commit is contained in:
Alex Szpakowski
2014-01-21 06:01:50 -04:00
parent 81d9810ed8
commit 73f1ce0d40
13 changed files with 217 additions and 13 deletions
+11
View File
@@ -109,6 +109,15 @@ public:
**/
size_t getVertexMapCount() const;
/**
* Sets the number of instances of this Mesh to draw (uses hardware
* instancing when possible.)
* A custom vertex shader is necessary in order to introduce differences
* in each instance.
**/
void setInstanceCount(int count);
int getInstanceCount() const;
/**
* Sets the texture used when drawing the Mesh.
**/
@@ -165,6 +174,8 @@ private:
VertexBuffer *ibo;
size_t element_count;
int instance_count;
DrawMode draw_mode;
Texture *texture;