diff options
| author | jussi | 2023-05-06 23:40:27 +0300 |
|---|---|---|
| committer | jussi | 2023-05-06 23:40:27 +0300 |
| commit | 429a9dff96a5dbe1f526ae7cc6e41815eb862cf0 (patch) | |
| tree | d8e081074498425f17c0fda3d8cb6d929403d1e3 /src | |
| parent | cf92c94097e1e8ce61a6bc73671be4ee5e229571 (diff) | |
| download | reilua-enhanced-429a9dff96a5dbe1f526ae7cc6e41815eb862cf0.tar.gz reilua-enhanced-429a9dff96a5dbe1f526ae7cc6e41815eb862cf0.tar.bz2 reilua-enhanced-429a9dff96a5dbe1f526ae7cc6e41815eb862cf0.zip | |
uluaGetBoundingBoxIndex, IsTextureReady.
Diffstat (limited to 'src')
| -rw-r--r-- | src/lua_core.c | 3 | ||||
| -rw-r--r-- | src/textures.c | 31 |
2 files changed, 30 insertions, 4 deletions
diff --git a/src/lua_core.c b/src/lua_core.c index bc2c7e3..a718de5 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -997,6 +997,7 @@ void luaRegister() { assingGlobalFunction( "LoadTextureCubemap", ltexturesLoadTextureCubemap ); assingGlobalFunction( "LoadRenderTexture", ltexturesLoadRenderTexture ); assingGlobalFunction( "UnloadTexture", ltexturesUnloadTexture ); + assingGlobalFunction( "IsTextureReady", ltexturesIsTextureReady ); assingGlobalFunction( "UpdateTexture", ltexturesUpdateTexture ); assingGlobalFunction( "UpdateTextureRec", ltexturesUpdateTextureRec ); /* Texture Drawing. */ @@ -1763,7 +1764,7 @@ BoundingBox uluaGetBoundingBoxIndex( lua_State *L, int index ) { lua_pushnil( L ); while ( lua_next( L, t ) != 0 ) { - if ( lua_isnumber( L, -1 ) ) { + if ( lua_istable( L, -1 ) ) { if ( lua_isnumber( L, -2 ) ) { switch ( i ) { case 0: diff --git a/src/textures.c b/src/textures.c index 4def06e..291a7ad 100644 --- a/src/textures.c +++ b/src/textures.c @@ -1740,14 +1740,14 @@ 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 ); @@ -1755,6 +1755,31 @@ int ltexturesUnloadTexture( lua_State *L ) { } /* +> 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 ) Update GPU texture with new data |
