From 429a9dff96a5dbe1f526ae7cc6e41815eb862cf0 Mon Sep 17 00:00:00 2001 From: jussi Date: Sat, 6 May 2023 23:40:27 +0300 Subject: uluaGetBoundingBoxIndex, IsTextureReady. --- src/textures.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) (limited to 'src/textures.c') diff --git a/src/textures.c b/src/textures.c index 4def06e..291a7ad 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1740,20 +1740,45 @@ int ltexturesUnloadTexture( lua_State *L ) { lua_pushboolean( L, false ); return 1; } - size_t id = lua_tointeger( L, 1 ); + size_t texId = lua_tointeger( L, 1 ); - if ( !validTexture( id, TEXTURE_TYPE_ALL ) ) { + if ( !validTexture( texId, TEXTURE_TYPE_ALL ) ) { lua_pushboolean( L, false ); return 1; } // UnloadTexture( *state->textures[ id ] ); - texturesFreeTexture( id ); + texturesFreeTexture( texId ); // state->textures[ id ] = NULL; lua_pushboolean( L, true ); return 1; } +/* +> isReady = RL.IsTextureReady( Texture2D texture ) + +Check if a texture is ready + +- Failure return nil +- Success return true +*/ +int ltexturesIsTextureReady( lua_State *L ) { + if ( !lua_isnumber( L, 1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.IsTextureReady( Texture2D texture )" ); + lua_pushnil( L ); + return 1; + } + size_t texId = lua_tointeger( L, 1 ); + + if ( !validTexture( texId, TEXTURE_TYPE_TEXTURE ) ) { + lua_pushnil( L ); + return 1; + } + lua_pushboolean( L, IsTextureReady( state->textures[ texId ]->texture) ); + + return 1; +} + /* > success = RL.UpdateTexture( Texture2D texture, int{} pixels ) -- cgit v1.2.3