Commits

Alex Szpakowski committed 2445d1b

Added SpriteBatch:isEmpty() and SpriteBatch:isFull()

  • Participants
  • Parent commits 8699059

Comments (0)

Files changed (4)

File src/modules/graphics/opengl/SpriteBatch.cpp

 	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;

File src/modules/graphics/opengl/SpriteBatch.h

 	 */
 	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;
 

File src/modules/graphics/opengl/wrap_SpriteBatch.cpp

 	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 },
 	{ "setImage", w_SpriteBatch_setImage },
 	{ "getImage", w_SpriteBatch_getImage },
 	{ "setColor", w_SpriteBatch_setColor },
+	{ "isEmpty", w_SpriteBatch_isEmpty },
+	{ "isFull", w_SpriteBatch_isFull },
 	{ 0, 0 }
 };
 

File src/modules/graphics/opengl/wrap_SpriteBatch.h

 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);