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:
@@ -63,6 +63,17 @@ public:
|
||||
VENDOR_UNKNOWN
|
||||
};
|
||||
|
||||
// Vertex attributes used in shaders by LOVE. The values map to OpenGL
|
||||
// generic vertex attribute indices, when applicable.
|
||||
// LOVE uses the old hard-coded attribute APIs for positions, colors, etc.
|
||||
// (for now.)
|
||||
enum VertexAttrib
|
||||
{
|
||||
// Instance ID when pseudo-instancing is used.
|
||||
ATTRIB_PSEUDO_INSTANCE_ID = 1,
|
||||
ATTRIB_MAX_ENUM
|
||||
};
|
||||
|
||||
// A rectangle representing an OpenGL viewport or a scissor box.
|
||||
struct Viewport
|
||||
{
|
||||
@@ -99,6 +110,16 @@ public:
|
||||
**/
|
||||
void prepareDraw();
|
||||
|
||||
/**
|
||||
* glDrawArraysInstanced with a pseudo-instancing fallback.
|
||||
**/
|
||||
void drawArraysInstanced(GLenum mode, GLint first, GLsizei count, GLsizei primcount);
|
||||
|
||||
/**
|
||||
* glDrawElementsInstanced with a pseudo-instancing fallback.
|
||||
**/
|
||||
void drawElementsInstanced(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei primcount);
|
||||
|
||||
/**
|
||||
* Sets the current constant color.
|
||||
**/
|
||||
@@ -230,6 +251,9 @@ private:
|
||||
Viewport viewport;
|
||||
Viewport scissor;
|
||||
|
||||
// The last ID value used for pseudo-instancing.
|
||||
int lastPseudoInstanceID;
|
||||
|
||||
} state;
|
||||
|
||||
}; // OpenGL
|
||||
|
||||
Reference in New Issue
Block a user