mirror of
https://github.com/love2d/love.git
synced 2026-08-19 20:19:42 +02:00
Add low-level hardware instancing support to Meshes.
Add “instancing” Graphics Feature constant. Add love.graphics.drawInstanced(mesh, instancecount, x, y, …) which draws the mesh multiple times in a single draw call. Each instance of the mesh will appear in the exact same spot unless one of the following are used: - Add an optional vertex attribute step type argument to Mesh:attachAttribute. “pervertex” is the default. “perinstance” causes the attribute to be per-instance instead of per-vertex, when the mesh is drawn. - Add love_InstanceID as a built-in read only int variable in GLSL 3 vertex shaders. It is always 0 except when a Mesh is drawn with more than 1 instance specified in the draw call. It can be used to manually compute or index into per-instance values in a shader. --HG-- branch : minor
This commit is contained in:
@@ -212,8 +212,8 @@ public:
|
||||
* glDrawArrays and glDrawElements which increment the draw-call counter by
|
||||
* themselves.
|
||||
**/
|
||||
void drawArrays(GLenum mode, GLint first, GLsizei count);
|
||||
void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices);
|
||||
void drawArrays(GLenum mode, GLint first, GLsizei count, GLsizei instancecount = 1);
|
||||
void drawElements(GLenum mode, GLsizei count, GLenum type, const void *indices, GLsizei instancecount = 1);
|
||||
|
||||
/**
|
||||
* Sets the enabled vertex attribute arrays based on the specified attribute
|
||||
@@ -222,7 +222,7 @@ public:
|
||||
* See the VertexAttribFlags enum for the standard vertex attributes.
|
||||
* This function *must* be used instead of glEnable/DisableVertexAttribArray.
|
||||
**/
|
||||
void useVertexAttribArrays(uint32 arraybits);
|
||||
void useVertexAttribArrays(uint32 arraybits, uint32 instancedbits = 0);
|
||||
|
||||
/**
|
||||
* Sets the OpenGL rendering viewport to the specified rectangle.
|
||||
@@ -315,6 +315,7 @@ public:
|
||||
|
||||
bool isClampZeroTextureWrapSupported() const;
|
||||
bool isPixelShaderHighpSupported() const;
|
||||
bool isInstancingSupported() const;
|
||||
|
||||
/**
|
||||
* Returns the maximum supported width or height of a texture.
|
||||
@@ -410,6 +411,7 @@ private:
|
||||
int curTextureUnit;
|
||||
|
||||
uint32 enabledAttribArrays;
|
||||
uint32 instancedAttribArrays;
|
||||
|
||||
Colorf constantColor;
|
||||
Colorf lastConstantColor;
|
||||
|
||||
Reference in New Issue
Block a user