1. Alexey Lubimov
  2. love

Commits

Matthias Richter  committed 3f25413

Add love.graphics.getPixelEffect() (issue #372) -- thanks, slime73!

  • Participants
  • Parent commits 17238f8
  • Branches default

Comments (0)

Files changed (3)

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

View file
  • Ignore whitespace
 {
 namespace opengl
 {
+	PixelEffect * PixelEffect::current = NULL;
+
 	std::map<std::string, GLint> PixelEffect::_texture_unit_pool;
 	GLint PixelEffect::_current_texture_unit = 0;
 	GLint PixelEffect::_max_texture_units = 0;
 	void PixelEffect::attach()
 	{
 		glUseProgram(_program);
+		current = this;
 	}
 
 	void PixelEffect::detach()
 	{
 		glUseProgram(0);
+		current = NULL;
 	}
 
 	void PixelEffect::sendFloat(const std::string& name, int size, const GLfloat* vec, int count)

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

View file
  • Ignore whitespace
 		static void detach();
 		static std::string getGLSLVersion();
 		static bool isSupported();
+		
+		static PixelEffect * current;
 
 		void sendFloat(const std::string& name, int size, const GLfloat* vec, int count);
 		void sendMatrix(const std::string& name, int size, const GLfloat* m, int count);

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

View file
  • Ignore whitespace
 		effect->attach();
 		return 0;
 	}
+	
+	int w_getPixelEffect(lua_State * L)
+	{
+		PixelEffect * effect = PixelEffect::current;
+		if (effect)
+		{
+			effect->retain();
+			luax_newtype(L, "PixelEffect", GRAPHICS_PIXELEFFECT_T, (void*) effect);
+		}
+		else
+			lua_pushnil(L);
+		
+		return 1;
+	}
 
 	int w_isSupported(lua_State * L)
 	{
 		{ "getCanvas", w_getCanvas },
 
 		{ "setPixelEffect", w_setPixelEffect },
+		{ "getPixelEffect", w_getPixelEffect },
 
 		{ "isSupported", w_isSupported },