Issue #262: Add per-sprite colors.

This commit is contained in:
rude
2011-07-23 17:12:29 +02:00
parent 26277b6450
commit 387a8ab2dc
3 changed files with 88 additions and 1 deletions
+29
View File
@@ -31,6 +31,7 @@
#include <common/Matrix.h>
#include <graphics/Drawable.h>
#include <graphics/Volatile.h>
#include <graphics/Color.h>
// OpenGL
#include "GLee.h"
@@ -73,6 +74,10 @@ namespace opengl
// If the buffer is locked, this pointer is nonzero.
vertex * lockp;
// Current color. This color, if present, will be applied to the next
// added quad.
Color * color;
public:
enum UsageHint
@@ -98,6 +103,21 @@ namespace opengl
void setImage(Image * newimage);
/**
* Set the current color for this SpriteBatch. The geometry added
* after this call will use this color. Note that global color
* will not longer apply to the SpriteBatch if this is used.
*
* @param color The color to use for the following geometry.
*/
void setColor(const Color & color);
/**
* Disable per-quad colors for this SpriteBatch. The next call to
* draw will use the global color for all sprites.
*/
void setColor();
// Implements Drawable.
void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const;
@@ -105,6 +125,15 @@ namespace opengl
void addv(const vertex * v);
/**
* Set the color for vertices.
*
* @param v The vertices to set the color for. Must be an array of
* of size 4.
* @param color The color to assign to each vertex.
*/
void setColorv(vertex * v, const Color & color);
}; // SpriteBatch
} // opengl