diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index e80c4b491..2145e9bc0 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -190,6 +190,16 @@ void SpriteBatch::setColor() color = 0; } +bool SpriteBatch::isEmpty() const +{ + return next == 0; +} + +bool SpriteBatch::isFull() const +{ + return next >= size; +} + void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const { const int color_offset = 0; diff --git a/src/modules/graphics/opengl/SpriteBatch.h b/src/modules/graphics/opengl/SpriteBatch.h index 5cf71b928..42c9b008a 100644 --- a/src/modules/graphics/opengl/SpriteBatch.h +++ b/src/modules/graphics/opengl/SpriteBatch.h @@ -86,6 +86,16 @@ public: */ void setColor(); + /** + * Returns whether the SpriteBatch is empty of sprites or not. + **/ + bool isEmpty() const; + + /** + * Returns whether the amount of sprites has reached the buffer limit or not. + **/ + bool isFull() const; + // Implements Drawable. void draw(float x, float y, float angle, float sx, float sy, float ox, float oy, float kx, float ky) const; diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index 6d9f501c1..e31c865b9 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -184,6 +184,20 @@ int w_SpriteBatch_setColor(lua_State *L) return 0; } +int w_SpriteBatch_isEmpty(lua_State *L) +{ + SpriteBatch *t = luax_checkspritebatch(L, 1); + luax_pushboolean(L, t->isEmpty()); + return 1; +} + +int w_SpriteBatch_isFull(lua_State *L) +{ + SpriteBatch *t = luax_checkspritebatch(L, 1); + luax_pushboolean(L, t->isFull()); + return 1; +} + static const luaL_Reg functions[] = { { "add", w_SpriteBatch_add }, @@ -196,6 +210,8 @@ static const luaL_Reg functions[] = { "setImage", w_SpriteBatch_setImage }, { "getImage", w_SpriteBatch_getImage }, { "setColor", w_SpriteBatch_setColor }, + { "isEmpty", w_SpriteBatch_isEmpty }, + { "isFull", w_SpriteBatch_isFull }, { 0, 0 } }; diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.h b/src/modules/graphics/opengl/wrap_SpriteBatch.h index aa737dcc9..58e5be8f0 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.h +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.h @@ -37,10 +37,13 @@ int w_SpriteBatch_addq(lua_State *L); int w_SpriteBatch_set(lua_State *L); int w_SpriteBatch_setq(lua_State *L); int w_SpriteBatch_clear(lua_State *L); -int w_SpriteBatch_lock(lua_State *L); -int w_SpriteBatch_unlock(lua_State *L); +int w_SpriteBatch_bind(lua_State *L); +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_isEmpty(lua_State *L); +int w_SpriteBatch_isFull(lua_State *L); extern "C" int luaopen_spritebatch(lua_State *L);