Added SpriteBatch:attachAttribute(attributename, mesh), which lets SpriteBatches use per-vertex information from a vertex attribute in a Mesh when drawing.

Each sprite in a SpriteBatch has 4 vertices in the following order: top-left, bottom-left, top-right, bottom-right. The index returned by SpriteBatch:add (and used by SpriteBatch:set) can be multiplied by 4 to determine the first vertex in a specific sprite.
This commit is contained in:
Alex Szpakowski
2015-11-26 21:24:29 -04:00
parent f1d0187a58
commit 3c1c13793e
7 changed files with 140 additions and 55 deletions
+4 -1
View File
@@ -126,6 +126,7 @@ public:
**/
const std::vector<AttribFormat> &getVertexFormat() const;
DataType getAttributeInfo(int attribindex, int &components) const;
int getAttributeIndex(const std::string &name) const;
/**
* Sets whether a specific vertex attribute is used when drawing the Mesh.
@@ -193,6 +194,8 @@ public:
void setDrawRange();
void getDrawRange(int &min, int &max) const;
int bindAttributeToShaderInput(int attributeindex, const std::string &inputname);
// Implements Drawable.
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) override;
@@ -212,7 +215,7 @@ private:
struct AttachedAttribute
{
Mesh *mesh;
size_t index;
int index;
bool enabled;
};