Example #1
0
int w_ParticleSystem_setSprite(lua_State *L)
{
	ParticleSystem *t = luax_checkparticlesystem(L, 1);
	Image *i = luax_checkimage(L, 2);
	t->setSprite(i);
	return 0;
}
Example #2
0
int w_Image_setMipmapFilter(lua_State *L)
{
	Image *t = luax_checkimage(L, 1);
	Image::Filter f = t->getFilter();

	if (lua_isnoneornil(L, 2))
		f.mipmap = Image::FILTER_NONE; // mipmapping is disabled if no argument is given
	else
	{
		const char *mipmapstr = luaL_checkstring(L, 2);
		if (!Image::getConstant(mipmapstr, f.mipmap))
			return luaL_error(L, "Invalid filter mode: %s", mipmapstr);
	}

	try
	{
		t->setFilter(f);
	}
	catch(love::Exception &e)
	{
		return luaL_error(L, "%s", e.what());
	}
	
	return 0;
}
Example #3
0
int w_Image_setMipmapSharpness(lua_State *L)
{
	Image *i = luax_checkimage(L, 1);

	float sharpness = (float) luaL_checknumber(L, 2);
	i->setMipmapSharpness(sharpness);

	return 0;
}
Example #4
0
int w_Image_getWrap(lua_State *L)
{
	Image *i = luax_checkimage(L, 1);
	const Image::Wrap w = i->getWrap();
	const char *sstr;
	const char *tstr;
	Image::getConstant(w.s, sstr);
	Image::getConstant(w.t, tstr);
	lua_pushstring(L, sstr);
	lua_pushstring(L, tstr);
	return 2;
}
Example #5
0
int w_Image_getFilter(lua_State *L)
{
	Image *t = luax_checkimage(L, 1);
	const Image::Filter f = t->getFilter();
	const char *minstr;
	const char *magstr;
	Image::getConstant(f.min, minstr);
	Image::getConstant(f.mag, magstr);
	lua_pushstring(L, minstr);
	lua_pushstring(L, magstr);
	return 2;
}
Example #6
0
int w_Image_refresh(lua_State *L)
{
	Image *i = luax_checkimage(L, 1);

	int xoffset = (int) luaL_optnumber(L, 2, 0);
	int yoffset = (int) luaL_optnumber(L, 3, 0);
	int w = (int) luaL_optnumber(L, 4, i->getWidth());
	int h = (int) luaL_optnumber(L, 5, i->getHeight());

	luax_catchexcept(L, [&](){ i->refresh(xoffset, yoffset, w, h); });
	return 0;
}
Example #7
0
int w_Image_getMipmapFilter(lua_State *L)
{
	Image *t = luax_checkimage(L, 1);
	const Image::Filter f = t->getFilter();

	const char *mipmapstr;
	if (!Image::getConstant(f.mipmap, mipmapstr))
		return 0; // only return a mipmap filter if mipmapping is enabled

	lua_pushstring(L, mipmapstr);

	return 1;
}
Example #8
0
int w_Image_getFlags(lua_State *L)
{
	Image *i = luax_checkimage(L, 1);
	Image::Flags flags = i->getFlags();

	lua_createtable(L, 0, 2);

	lua_pushboolean(L, flags.mipmaps);
	lua_setfield(L, -2, imageFlagName(Image::FLAG_TYPE_MIPMAPS));

	lua_pushboolean(L, flags.linear);
	lua_setfield(L, -2, imageFlagName(Image::FLAG_TYPE_LINEAR));

	return 1;
}
Example #9
0
int w_Image_getMipmapFilter(lua_State *L)
{
	Image *t = luax_checkimage(L, 1);

	const Texture::Filter &f = t->getFilter();

	const char *mipmapstr;
	if (Texture::getConstant(f.mipmap, mipmapstr))
		lua_pushstring(L, mipmapstr);
	else
		lua_pushnil(L); // only return a mipmap filter if mipmapping is enabled

	lua_pushnumber(L, t->getMipmapSharpness());
	return 2;
}
Example #10
0
	int w_Image_setWrap(lua_State * L)
	{
		Image * i = luax_checkimage(L, 1);
		Image::Wrap w;
		Image::WrapMode s;
		Image::WrapMode t;
		const char * sstr = luaL_checkstring(L, 2);
		const char * tstr = luaL_checkstring(L, 3);
		if (!Image::getConstant(sstr, s))
			return luaL_error(L, "Invalid wrap mode: %s", sstr);
		if (!Image::getConstant(tstr, t))
			return luaL_error(L, "Invalid wrap mode, %s", tstr);

		w.s = s;
		w.t = t;
		i->setWrap(w);
		return 0;
	}
Example #11
0
	int w_Image_setFilter(lua_State * L)
	{
		Image * t = luax_checkimage(L, 1);
		Image::Filter f;
		Image::FilterMode min;
		Image::FilterMode mag;
		const char * minstr = luaL_checkstring(L, 2);
		const char * magstr = luaL_checkstring(L, 3);
		if (!Image::getConstant(minstr, min))
			return luaL_error(L, "Invalid filter mode: %s", minstr);
		if (!Image::getConstant(magstr, mag))
			return luaL_error(L, "Invalid filter mode: %s", magstr);

		f.min = min;
		f.mag = mag;
		t->setFilter(f);
		return 0;
	}
Example #12
0
int w_Image_setMipmapFilter(lua_State *L)
{
	Image *t = luax_checkimage(L, 1);
	Texture::Filter f = t->getFilter();

	if (lua_isnoneornil(L, 2))
		f.mipmap = Texture::FILTER_NONE; // mipmapping is disabled if no argument is given
	else
	{
		const char *mipmapstr = luaL_checkstring(L, 2);
		if (!Texture::getConstant(mipmapstr, f.mipmap))
			return luaL_error(L, "Invalid filter mode: %s", mipmapstr);
	}

	luax_catchexcept(L, [&](){ t->setFilter(f); });
	t->setMipmapSharpness((float) luaL_optnumber(L, 3, 0.0));

	return 0;
}
Example #13
0
int w_Image_setFilter(lua_State *L)
{
	Image *t = luax_checkimage(L, 1);
	Image::Filter f = t->getFilter();

	const char *minstr = luaL_checkstring(L, 2);
	const char *magstr = luaL_optstring(L, 3, minstr);

	if (!Image::getConstant(minstr, f.min))
		return luaL_error(L, "Invalid filter mode: %s", minstr);
	if (!Image::getConstant(magstr, f.mag))
		return luaL_error(L, "Invalid filter mode: %s", magstr);

	try
	{
		t->setFilter(f);
	}
	catch(love::Exception &e)
	{
		return luaL_error(L, "%s", e.what());
	}

	return 0;
}
Example #14
0
int w_Image_getData(lua_State *L)
{
	Image *i = luax_checkimage(L, 1);
	int n = 0;

	if (i->isCompressed())
	{
		for (const auto &cdata : i->getCompressedData())
		{
			luax_pushtype(L, IMAGE_COMPRESSED_IMAGE_DATA_ID, cdata.get());
			n++;
		}
	}
	else
	{
		for (const auto &data : i->getImageData())
		{
			luax_pushtype(L, IMAGE_IMAGE_DATA_ID, data.get());
			n++;
		}
	}

	return n;
}
Example #15
0
int w_Image_getMipmapSharpness(lua_State *L)
{
	Image *i = luax_checkimage(L, 1);
	lua_pushnumber(L, i->getMipmapSharpness());
	return 1;
}
Example #16
0
	int w_Image_getHeight(lua_State * L)
	{
		Image * t = luax_checkimage(L, 1);
		lua_pushnumber(L, t->getHeight());
		return 1;
	}
Example #17
0
int w_Image_isCompressed(lua_State *L)
{
	Image *i = luax_checkimage(L, 1);
	luax_pushboolean(L, i->isCompressed());
	return 1;
}