Skip to content

Commit

Permalink
added texture.IsValid() lua binding
Browse files Browse the repository at this point in the history
  • Loading branch information
turanszkij committed Aug 31, 2024
1 parent c5c77b0 commit 3e638bb
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
1 change: 1 addition & 0 deletions Content/Documentation/ScriptingAPI-Documentation.md
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ Gives you the ability to render text with a custom font.
A texture image data.
- [constructor]Texture(opt string filename) -- creates a texture from file
- [outer]texturehelper -- a global helper texture creation utility
- IsValid() : bool -- whether the texture contains valid data, if it has been created successfully
- GetWidth() : int
- GetHeight() : int
- GetDepth() : int
Expand Down
6 changes: 6 additions & 0 deletions WickedEngine/wiTexture_BindLua.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace wi::lua
lunamethod(Texture_BindLua, CreateLensDistortionNormalMap),
lunamethod(Texture_BindLua, Save),

lunamethod(Texture_BindLua, IsValid),
lunamethod(Texture_BindLua, GetWidth),
lunamethod(Texture_BindLua, GetHeight),
lunamethod(Texture_BindLua, GetDepth),
Expand Down Expand Up @@ -203,6 +204,11 @@ namespace wi::lua
return 0;
}

int Texture_BindLua::IsValid(lua_State* L)
{
wi::lua::SSetBool(L, resource.IsValid() && resource.GetTexture().IsValid());
return 1;
}
int Texture_BindLua::GetWidth(lua_State* L)
{
if (!resource.IsValid() || !resource.GetTexture().IsValid())
Expand Down
1 change: 1 addition & 0 deletions WickedEngine/wiTexture_BindLua.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ namespace wi::lua
int CreateLensDistortionNormalMap(lua_State* L);
int Save(lua_State* L);

int IsValid(lua_State* L);
int GetWidth(lua_State* L);
int GetHeight(lua_State* L);
int GetDepth(lua_State* L);
Expand Down
2 changes: 1 addition & 1 deletion WickedEngine/wiVersion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 562;
const int revision = 563;

const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);

Expand Down

0 comments on commit 3e638bb

Please sign in to comment.