Browse Source

Added Image:getFlags.

Alex Szpakowski 10 years ago
parent
commit
b39036eaa5

+ 24 - 0
src/modules/graphics/opengl/wrap_Image.cpp

@@ -101,6 +101,29 @@ int w_Image_getData(lua_State *L)
 	return 1;
 }
 
+static const char *imageFlagName(Image::FlagType flagtype)
+{
+	const char *name = nullptr;
+	Image::getConstant(flagtype, name);
+	return name;
+}
+
+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.sRGB);
+	lua_setfield(L, -2, imageFlagName(Image::FLAG_TYPE_SRGB));
+
+	return 1;
+}
+
 static const luaL_Reg functions[] =
 {
 	// From wrap_Texture.
@@ -117,6 +140,7 @@ static const luaL_Reg functions[] =
 	{ "isCompressed", w_Image_isCompressed },
 	{ "refresh", w_Image_refresh },
 	{ "getData", w_Image_getData },
+	{ "getFlags", w_Image_getFlags },
 	{ 0, 0 }
 };
 

+ 1 - 0
src/modules/graphics/opengl/wrap_Image.h

@@ -39,6 +39,7 @@ int w_Image_getMipmapFilter(lua_State *L);
 int w_Image_isCompressed(lua_State *L);
 int w_Image_refresh(lua_State *L);
 int w_Image_getData(lua_State *L);
+int w_Image_getFlags(lua_State *L);
 extern "C" int luaopen_image(lua_State *L);
 
 } // opengl