mirror of
https://github.com/love2d/love.git
synced 2026-08-17 19:23:38 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user