From b39036eaa5ed029fa61de7838b385ac59c0afaf6 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Wed, 4 Mar 2015 23:07:05 -0400 Subject: [PATCH] Added Image:getFlags. --- src/modules/graphics/opengl/wrap_Image.cpp | 24 ++++++++++++++++++++++ src/modules/graphics/opengl/wrap_Image.h | 1 + 2 files changed, 25 insertions(+) diff --git a/src/modules/graphics/opengl/wrap_Image.cpp b/src/modules/graphics/opengl/wrap_Image.cpp index b99d856f0..e822f6e06 100644 --- a/src/modules/graphics/opengl/wrap_Image.cpp +++ b/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 } }; diff --git a/src/modules/graphics/opengl/wrap_Image.h b/src/modules/graphics/opengl/wrap_Image.h index 7204890be..edf8f7892 100644 --- a/src/modules/graphics/opengl/wrap_Image.h +++ b/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