mirror of
https://github.com/love2d/love.git
synced 2026-08-19 04:06:17 +02:00
Switched Image wrap modes to the new string syntax too.
This commit is contained in:
@@ -38,6 +38,16 @@ namespace graphics
|
|||||||
return filterModes.find(in, out);
|
return filterModes.find(in, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Image::getConstant(const char * in, WrapMode & out)
|
||||||
|
{
|
||||||
|
return wrapModes.find(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Image::getConstant(WrapMode in, const char *& out)
|
||||||
|
{
|
||||||
|
return wrapModes.find(in, out);
|
||||||
|
}
|
||||||
|
|
||||||
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM>::Entry Image::filterModeEntries[] =
|
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM>::Entry Image::filterModeEntries[] =
|
||||||
{
|
{
|
||||||
{ "linear", Image::FILTER_LINEAR },
|
{ "linear", Image::FILTER_LINEAR },
|
||||||
@@ -45,6 +55,15 @@ namespace graphics
|
|||||||
};
|
};
|
||||||
|
|
||||||
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM> Image::filterModes(Image::filterModeEntries, sizeof(Image::filterModeEntries));
|
StringMap<Image::FilterMode, Image::FILTER_MAX_ENUM> Image::filterModes(Image::filterModeEntries, sizeof(Image::filterModeEntries));
|
||||||
|
|
||||||
|
StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM>::Entry Image::wrapModeEntries[] =
|
||||||
|
{
|
||||||
|
{ "clamp", Image::WRAP_CLAMP },
|
||||||
|
{ "repeat", Image::WRAP_REPEAT },
|
||||||
|
};
|
||||||
|
|
||||||
|
StringMap<Image::WrapMode, Image::WRAP_MAX_ENUM> Image::wrapModes(Image::wrapModeEntries, sizeof(Image::wrapModeEntries));
|
||||||
|
|
||||||
|
|
||||||
} // graphics
|
} // graphics
|
||||||
} // love
|
} // love
|
||||||
|
|||||||
@@ -37,8 +37,9 @@ namespace graphics
|
|||||||
|
|
||||||
enum WrapMode
|
enum WrapMode
|
||||||
{
|
{
|
||||||
WRAP_CLAMP,
|
WRAP_CLAMP = 1,
|
||||||
WRAP_REPEAT
|
WRAP_REPEAT,
|
||||||
|
WRAP_MAX_ENUM
|
||||||
};
|
};
|
||||||
|
|
||||||
enum FilterMode
|
enum FilterMode
|
||||||
@@ -64,11 +65,15 @@ namespace graphics
|
|||||||
|
|
||||||
static bool getConstant(const char * in, FilterMode & out);
|
static bool getConstant(const char * in, FilterMode & out);
|
||||||
static bool getConstant(FilterMode in, const char *& out);
|
static bool getConstant(FilterMode in, const char *& out);
|
||||||
|
static bool getConstant(const char * in, WrapMode & out);
|
||||||
|
static bool getConstant(WrapMode in, const char *& out);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
static StringMap<FilterMode, FILTER_MAX_ENUM>::Entry filterModeEntries[];
|
static StringMap<FilterMode, FILTER_MAX_ENUM>::Entry filterModeEntries[];
|
||||||
static StringMap<FilterMode, FILTER_MAX_ENUM> filterModes;
|
static StringMap<FilterMode, FILTER_MAX_ENUM> filterModes;
|
||||||
|
static StringMap<WrapMode, WRAP_MAX_ENUM>::Entry wrapModeEntries[];
|
||||||
|
static StringMap<WrapMode, WRAP_MAX_ENUM> wrapModes;
|
||||||
|
|
||||||
}; // Image
|
}; // Image
|
||||||
|
|
||||||
|
|||||||
@@ -84,20 +84,37 @@ namespace opengl
|
|||||||
|
|
||||||
int w_Image_setWrap(lua_State * L)
|
int w_Image_setWrap(lua_State * L)
|
||||||
{
|
{
|
||||||
Image * t = luax_checkimage(L, 1);
|
Image * i = luax_checkimage(L, 1);
|
||||||
Image::Wrap w;
|
Image::Wrap w;
|
||||||
w.s = (Image::WrapMode)luaL_checkint(L, 2);
|
Image::WrapMode s;
|
||||||
w.t = (Image::WrapMode)luaL_checkint(L, 3);
|
Image::WrapMode t;
|
||||||
t->setWrap(w);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int w_Image_getWrap(lua_State * L)
|
int w_Image_getWrap(lua_State * L)
|
||||||
{
|
{
|
||||||
Image * t = luax_checkimage(L, 1);
|
Image * i = luax_checkimage(L, 1);
|
||||||
Image::Wrap w = t->getWrap();
|
Image::Wrap w = i->getWrap();
|
||||||
lua_pushinteger(L, w.s);
|
Image::WrapMode s = w.s;
|
||||||
lua_pushinteger(L, w.t);
|
Image::WrapMode t = w.t;
|
||||||
|
const char * sstr;
|
||||||
|
const char * tstr;
|
||||||
|
if (!Image::getConstant(s, sstr))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", sstr);
|
||||||
|
if (!Image::getConstant(t, tstr))
|
||||||
|
return luaL_error(L, "Invalid filter mode: %s", tstr);
|
||||||
|
lua_pushstring(L, sstr);
|
||||||
|
lua_pushstring(L, tstr);
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user