diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index f3af67bd8..a4f8ffac7 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -201,6 +201,11 @@ void SpriteBatch::setColor() color = 0; } +const Color *SpriteBatch::getColor() const +{ + return color; +} + int SpriteBatch::getCount() const { return next; diff --git a/src/modules/graphics/opengl/SpriteBatch.h b/src/modules/graphics/opengl/SpriteBatch.h index 811a48b64..6ef526fe4 100644 --- a/src/modules/graphics/opengl/SpriteBatch.h +++ b/src/modules/graphics/opengl/SpriteBatch.h @@ -86,6 +86,12 @@ public: */ void setColor(); + /** + * Get the current color for this SpriteBatch. Returns NULL if no color is + * set. + **/ + const Color *getColor() const; + /** * Get the number of sprites currently in this SpriteBatch. **/ diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index af18029b1..39db51fba 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -197,6 +197,23 @@ int w_SpriteBatch_setColor(lua_State *L) return 0; } +int w_SpriteBatch_getColor(lua_State *L) +{ + SpriteBatch *t = luax_checkspritebatch(L, 1); + const Color *color = t->getColor(); + + // getColor returns NULL if no color is set. + if (!color) + return 0; + + lua_pushinteger(L, (lua_Integer) color->r); + lua_pushinteger(L, (lua_Integer) color->g); + lua_pushinteger(L, (lua_Integer) color->b); + lua_pushinteger(L, (lua_Integer) color->a); + + return 4; +} + int w_SpriteBatch_getCount(lua_State *L) { SpriteBatch *t = luax_checkspritebatch(L, 1); @@ -223,6 +240,7 @@ static const luaL_Reg functions[] = { "setImage", w_SpriteBatch_setImage }, { "getImage", w_SpriteBatch_getImage }, { "setColor", w_SpriteBatch_setColor }, + { "getColor", w_SpriteBatch_getColor }, { "getCount", w_SpriteBatch_getCount }, { "getBufferSize", w_SpriteBatch_getBufferSize }, { 0, 0 } diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.h b/src/modules/graphics/opengl/wrap_SpriteBatch.h index c726df378..87c8e467e 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.h +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.h @@ -33,7 +33,7 @@ namespace opengl SpriteBatch *luax_checkspritebatch(lua_State *L, int idx); int w_SpriteBatch_add(lua_State *L); -int w_SpriteBatch_addq(lua_State *L); +int w_SpriteBatch_addg(lua_State *L); int w_SpriteBatch_set(lua_State *L); int w_SpriteBatch_setg(lua_State *L); int w_SpriteBatch_clear(lua_State *L); @@ -42,6 +42,7 @@ int w_SpriteBatch_unbind(lua_State *L); int w_SpriteBatch_setImage(lua_State *L); int w_SpriteBatch_getImage(lua_State *L); int w_SpriteBatch_setColor(lua_State *L); +int w_SpriteBatch_getColor(lua_State *L); int w_SpriteBatch_getCount(lua_State *L); int w_SpriteBatch_getBufferSize(lua_State *L);