diff --git a/changes.txt b/changes.txt index 2863cc0c7..209b680bc 100644 --- a/changes.txt +++ b/changes.txt @@ -33,6 +33,7 @@ LOVE 0.8.0 [Rubber Piggy] * Added SpriteBatch:set. * Added new events system, with support for custom events and long event names. * Added sound attenuation by distance. + * Added SpriteBatch:getImage. * Fixed wrapping for single words. * Fixed tracebacks not showing filenames. diff --git a/src/modules/graphics/opengl/SpriteBatch.cpp b/src/modules/graphics/opengl/SpriteBatch.cpp index 6a4e8b028..8eececf4f 100644 --- a/src/modules/graphics/opengl/SpriteBatch.cpp +++ b/src/modules/graphics/opengl/SpriteBatch.cpp @@ -176,6 +176,11 @@ namespace opengl image->retain(); } + Image *SpriteBatch::getImage() + { + return image; + } + void SpriteBatch::setColor(const Color & color) { if (!this->color) diff --git a/src/modules/graphics/opengl/SpriteBatch.h b/src/modules/graphics/opengl/SpriteBatch.h index 7737ebcef..8a01169b7 100644 --- a/src/modules/graphics/opengl/SpriteBatch.h +++ b/src/modules/graphics/opengl/SpriteBatch.h @@ -90,6 +90,7 @@ namespace opengl void unlock(); void setImage(Image * newimage); + Image *getImage(); /** * Set the current color for this SpriteBatch. The geometry added diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp index 913fc690d..cfced15c9 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.cpp +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.cpp @@ -18,6 +18,7 @@ * 3. This notice may not be removed or altered from any source distribution. **/ +#include "Image.h" #include "wrap_SpriteBatch.h" namespace love @@ -129,6 +130,15 @@ namespace opengl return 0; } + int w_SpriteBatch_getImage(lua_State * L) + { + SpriteBatch * t = luax_checkspritebatch(L, 1); + Image * image = t->getImage(); + image->retain(); + luax_newtype(L, "Image", GRAPHICS_IMAGE_T, (void*)image); + return 1; + } + int w_SpriteBatch_setColor(lua_State * L) { SpriteBatch * t = luax_checkspritebatch(L, 1); @@ -157,6 +167,7 @@ namespace opengl { "bind", w_SpriteBatch_bind }, { "unbind", w_SpriteBatch_unbind }, { "setImage", w_SpriteBatch_setImage }, + { "getImage", w_SpriteBatch_getImage }, { "setColor", w_SpriteBatch_setColor }, { 0, 0 } }; diff --git a/src/modules/graphics/opengl/wrap_SpriteBatch.h b/src/modules/graphics/opengl/wrap_SpriteBatch.h index f7d1089b1..c3de9a0fe 100644 --- a/src/modules/graphics/opengl/wrap_SpriteBatch.h +++ b/src/modules/graphics/opengl/wrap_SpriteBatch.h @@ -39,6 +39,7 @@ namespace opengl int w_SpriteBatch_lock(lua_State * L); int w_SpriteBatch_unlock(lua_State * L); int w_SpriteBatch_setImage(lua_State * L); + int w_SpriteBatch_getImage(lua_State * L); extern "C" int luaopen_spritebatch(lua_State * L);