Commits

Anonymous committed 1c2a050

Apply patch for issue #219

Comments (0)

Files changed (4)

src/modules/graphics/opengl/SpriteBatch.cpp

 		glBindBuffer(GL_ARRAY_BUFFER, 0);
 	}
 
+	void SpriteBatch::setImage(Image * newimage)
+	{
+		image->release();
+		image = newimage;
+		image->retain();
+	}
+
 	void SpriteBatch::draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const
 	{
 		static Matrix t;

src/modules/graphics/opengl/SpriteBatch.h

 		void * lock();
 		void unlock();
 
+		void setImage(Image * newimage);
+
 		// Implements Drawable.
 		void draw(float x, float y, float angle, float sx, float sy, float ox, float oy) const;
 

src/modules/graphics/opengl/wrap_SpriteBatch.cpp

 		return 0;
 	}
 
+	int w_SpriteBatch_setImage(lua_State * L)
+	{
+		SpriteBatch * t = luax_checkspritebatch(L, 1);
+		Image * image = luax_checktype<Image>(L, 2, "Image", GRAPHICS_IMAGE_T);
+		t->setImage(image);
+		return 0;
+	}
+
 	static const luaL_Reg functions[] = {
 		{ "add", w_SpriteBatch_add },
 		{ "addq", w_SpriteBatch_addq },
 		{ "clear", w_SpriteBatch_clear },
 		{ "lock", w_SpriteBatch_lock },
 		{ "unlock", w_SpriteBatch_unlock },
+		{ "setImage", w_SpriteBatch_setImage },
 		{ 0, 0 }
 	};
 
 
 } // opengl
 } // graphics
-} // love
+} // love

src/modules/graphics/opengl/wrap_SpriteBatch.h

 	int w_SpriteBatch_clear(lua_State * L);
 	int w_SpriteBatch_lock(lua_State * L);
 	int w_SpriteBatch_unlock(lua_State * L);
+	int w_SpriteBatch_setImage(lua_State * L);
+
 	int luaopen_spritebatch(lua_State * L);
 
 } // opengl
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.