From fe15e836bd87963d10bd301a3a24652763059e0d Mon Sep 17 00:00:00 2001 From: jussi Date: Thu, 6 Apr 2023 19:19:44 +0300 Subject: Switched to Raylib vertion 4.5. Removed some functions and added others. Main changes to camera3D. --- src/models.c | 68 +++++++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 44 insertions(+), 24 deletions(-) (limited to 'src/models.c') diff --git a/src/models.c b/src/models.c index cef36dd..313fdb1 100644 --- a/src/models.c +++ b/src/models.c @@ -120,6 +120,26 @@ static int newMesh() { return i; } +// Unload model (but not meshes) from memory (RAM and/or VRAM) +void UnloadModelKeepMeshes( Model model ) { + // Unload materials maps + // NOTE: As the user could be sharing shaders and textures between models, + // we don't unload the material but just free it's maps, + // the user is responsible for freeing models shaders and textures + for (int i = 0; i < model.materialCount; i++) RL_FREE(model.materials[i].maps); + + // Unload arrays + RL_FREE(model.meshes); + RL_FREE(model.materials); + RL_FREE(model.meshMaterial); + + // Unload animation data + RL_FREE(model.bones); + RL_FREE(model.bindPose); + + TRACELOG(LOG_INFO, "MODEL: Unloaded model (but not meshes) from RAM and VRAM"); +} + /* ## Models - Basic */ @@ -292,30 +312,30 @@ Draw cube textured - Failure return false - Success return true */ -int lmodelsDrawCubeTexture( lua_State *L ) { - if ( !lua_isnumber( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { - TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCubeTexture( Texture2D texture, Vector3 position, Vector3 size, Color color )" ); - lua_pushboolean( L, false ); - return 1; - } - Color color = uluaGetColor( L ); - lua_pop( L, 1 ); - Vector3 size = uluaGetVector3( L ); - lua_pop( L, 1 ); - Vector3 pos = uluaGetVector3( L ); - lua_pop( L, 1 ); - size_t texId = lua_tointeger( L, -1 ); - - if ( !validSourceTexture( texId ) ) { - lua_pushboolean( L, false ); - return 1; - } - - DrawCubeTexture( *texturesGetSourceTexture( texId ), pos, size.x, size.y, size.z, color ); - lua_pushboolean( L, true ); - - return 1; -} +// int lmodelsDrawCubeTexture( lua_State *L ) { +// if ( !lua_isnumber( L, -4 ) || !lua_istable( L, -3 ) || !lua_istable( L, -2 ) || !lua_istable( L, -1 ) ) { +// TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.DrawCubeTexture( Texture2D texture, Vector3 position, Vector3 size, Color color )" ); +// lua_pushboolean( L, false ); +// return 1; +// } +// Color color = uluaGetColor( L ); +// lua_pop( L, 1 ); +// Vector3 size = uluaGetVector3( L ); +// lua_pop( L, 1 ); +// Vector3 pos = uluaGetVector3( L ); +// lua_pop( L, 1 ); +// size_t texId = lua_tointeger( L, -1 ); + +// if ( !validSourceTexture( texId ) ) { +// lua_pushboolean( L, false ); +// return 1; +// } + +// DrawCubeTexture( *texturesGetSourceTexture( texId ), pos, size.x, size.y, size.z, color ); +// lua_pushboolean( L, true ); + +// return 1; +// } /* > success = RL.DrawSphere( Vector3 centerPos, float radius, Color color ) -- cgit v1.2.3