diff options
| author | jussi | 2022-08-19 13:38:09 +0300 |
|---|---|---|
| committer | jussi | 2022-08-19 13:38:09 +0300 |
| commit | 49f1dad6b9deeb769e384ae547fca9f64b90bf79 (patch) | |
| tree | b02b240d6c11c1bf29c3dc6ac9a7063137b4c971 /src | |
| parent | 4f54a0a4992358c633e5e3535e2980211028f3a2 (diff) | |
| download | reilua-enhanced-49f1dad6b9deeb769e384ae547fca9f64b90bf79.tar.gz reilua-enhanced-49f1dad6b9deeb769e384ae547fca9f64b90bf79.tar.bz2 reilua-enhanced-49f1dad6b9deeb769e384ae547fca9f64b90bf79.zip | |
Moved to raylib 4.2.0. Renamed some directory functions to raylib 4.2.0 conventions. Removed GenMeshBinormals and GetRayCollisionModel. Sound and music pan.
Diffstat (limited to 'src')
| -rw-r--r-- | src/audio.c | 44 | ||||
| -rw-r--r-- | src/core.c | 37 | ||||
| -rw-r--r-- | src/lua_core.c | 23 | ||||
| -rw-r--r-- | src/models.c | 53 | ||||
| -rw-r--r-- | src/state.c | 4 |
5 files changed, 68 insertions, 93 deletions
diff --git a/src/audio.c b/src/audio.c index 831174f..6a8c33a 100644 --- a/src/audio.c +++ b/src/audio.c @@ -521,6 +521,30 @@ int laudioSetSoundPitch( lua_State *L ) { } /* +> success = RL_SetSoundPan( Sound sound, float pan ) + +Set pan for a sound ( 0.5 is center ) + +- Failure return false +- Success return true +*/ +int laudioSetSoundPan( lua_State *L ) { + if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetSoundPan( Sound sound, float pitch )" ); + lua_pushboolean( L, false ); + return 1; + } + if ( !validSound( lua_tointeger( L, -2 ) ) ) { + lua_pushboolean( L, false ); + return 1; + } + SetSoundPan( *state->sounds[ lua_tointeger( L, -2 ) ], lua_tonumber( L, -1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + +/* > success = RL_WaveFormat( Wave wave, int sampleRate, int sampleSize, int channels ) Convert wave data to desired format @@ -761,6 +785,26 @@ int laudioSetMusicPitch( lua_State *L ) { } /* +> success = RL_SetMusicPan( float pan ) + +Set pan for a music ( 0.5 is center ) + +- Failure return false +- Success return true +*/ +int laudioSetMusicPan( lua_State *L ) { + if ( !lua_isnumber( L, -1 ) ) { + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_SetMusicPan( float pan )" ); + lua_pushboolean( L, false ); + return 1; + } + SetMusicPitch( state->music, lua_tonumber( L, -1 ) ); + lua_pushboolean( L, true ); + + return 1; +} + +/* > length = RL_GetMusicTimeLength() Get music time length ( in seconds ) @@ -2172,29 +2172,28 @@ int lcoreGetWorkingDirectory( lua_State *L ) { } /* -> fileNames = RL_GetDirectoryFiles( string dirPath ) +> fileNames = RL_LoadDirectoryFiles( string dirPath ) -Get filenames in a directory path +Load directory filepaths - Failure return false - Success return string{} */ -int lcoreGetDirectoryFiles( lua_State *L ) { +int lcoreLoadDirectoryFiles( lua_State *L ) { if ( !lua_isstring( L, -1 ) ) { - TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetDirectoryFiles( string dirPath )" ); + TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_LoadDirectoryFiles( string dirPath )" ); lua_pushboolean( L, false ); return 1; } - int count = 0; - char **strings = GetDirectoryFiles( lua_tostring( L, -1 ), &count ); + FilePathList files = LoadDirectoryFiles( lua_tostring( L, -1 ) ); - lua_createtable( L, count, 0 ); + lua_createtable( L, files.count, 0 ); - for ( int i = 0; i < count; ++i ) { - lua_pushstring( L, strings[i] ); + for ( int i = 0; i < files.count; ++i ) { + lua_pushstring( L, files.paths[i] ); lua_rawseti( L, -2, i+1 ); } - ClearDirectoryFiles(); + UnloadDirectoryFiles( files ); return 1; } @@ -2230,24 +2229,22 @@ int lcoreIsFileDropped( lua_State *L ) { } /* -> files = RL_GetDroppedFiles() +> files = RL_LoadDroppedFiles() -Get dropped files names +Load dropped filepaths - Success return string{} */ -int lcoreGetDroppedFiles( lua_State *L ) { - int count = 0; - char **files = GetDroppedFiles( &count ); +int lcoreLoadDroppedFiles( lua_State *L ) { + FilePathList files = LoadDroppedFiles(); - lua_createtable( L, count, 0 ); + lua_createtable( L, files.count, 0 ); - for ( int i = 0; i < count; ++i ) { - lua_pushstring( L, files[i] ); + for ( int i = 0; i < files.count; ++i ) { + lua_pushstring( L, files.paths[i] ); lua_rawseti( L, -2, i+1 ); } - - ClearDroppedFiles(); + UnloadDroppedFiles( files ); return 1; } diff --git a/src/lua_core.c b/src/lua_core.c index 23f6534..7c95b2a 100644 --- a/src/lua_core.c +++ b/src/lua_core.c @@ -529,9 +529,6 @@ bool luaInit() { luaRegister(); defineGlobals(); - // SetConfigFlags( FLAG_VSYNC_HINT ); - // SetWindowState( FLAG_VSYNC_HINT ); - return luaCallMain(); } @@ -546,7 +543,7 @@ int luaTraceback( lua_State *L ) { lua_getfield( L, -1, "traceback" ); if ( !lua_isfunction( L, -1 ) ) { - lua_pop(L, 2); + lua_pop( L, 2 ); return 1; } @@ -623,11 +620,6 @@ void luaCallProcess() { return; } } - // else { - // TraceLog( LOG_WARNING, "%s", "No Lua process found!" ); - // state->run = false; - // return; - // } lua_pop( L, -1 ); } @@ -649,11 +641,6 @@ void luaCallDraw() { EndDrawing(); } - // else { - // TraceLog( LOG_WARNING, "%s", "No Lua render found!" ); - // state->run = false; - // return; - // } lua_pop( L, -1 ); } @@ -742,10 +729,10 @@ void luaRegister() { lua_register( L, "RL_GetDirectoryPath", lcoreGetDirectoryPath ); lua_register( L, "RL_GetPrevDirectoryPath", lcoreGetPrevDirectoryPath ); lua_register( L, "RL_GetWorkingDirectory", lcoreGetWorkingDirectory ); - lua_register( L, "RL_GetDirectoryFiles", lcoreGetDirectoryFiles ); + lua_register( L, "RL_LoadDirectoryFiles", lcoreLoadDirectoryFiles ); lua_register( L, "RL_ChangeDirectory", lcoreChangeDirectory ); lua_register( L, "RL_IsFileDropped", lcoreIsFileDropped ); - lua_register( L, "RL_GetDroppedFiles", lcoreGetDroppedFiles ); + lua_register( L, "RL_LoadDroppedFiles", lcoreLoadDroppedFiles ); lua_register( L, "RL_GetFileModTime", lcoreGetFileModTime ); /* Camera2D. */ lua_register( L, "RL_CreateCamera2D", lcoreCreateCamera2D ); @@ -1014,7 +1001,6 @@ void luaRegister() { lua_register( L, "RL_ExportMesh", lmodelsExportMesh ); lua_register( L, "RL_GetMeshBoundingBox", lmodelsGetMeshBoundingBox ); lua_register( L, "RL_GenMeshTangents", lmodelsGenMeshTangents ); - lua_register( L, "RL_GenMeshBinormals", lmodelsGenMeshBinormals ); /* Material. */ lua_register( L, "RL_LoadMaterialDefault", lmodelsLoadMaterialDefault ); lua_register( L, "RL_CreateMaterial", lmodelsCreateMaterial ); @@ -1047,7 +1033,6 @@ void luaRegister() { lua_register( L, "RL_CheckCollisionBoxSphere", lmodelsCheckCollisionBoxSphere ); lua_register( L, "RL_GetRayCollisionSphere", lmodelsGetRayCollisionSphere ); lua_register( L, "RL_GetRayCollisionBox", lmodelsGetRayCollisionBox ); - lua_register( L, "RL_GetRayCollisionModel", lmodelsGetRayCollisionModel ); lua_register( L, "RL_GetRayCollisionMesh", lmodelsGetRayCollisionMesh ); lua_register( L, "RL_GetRayCollisionTriangle", lmodelsGetRayCollisionTriangle ); lua_register( L, "RL_GetRayCollisionQuad", lmodelsGetRayCollisionQuad ); @@ -1089,6 +1074,7 @@ void luaRegister() { lua_register( L, "RL_IsSoundPlaying", laudioIsSoundPlaying ); lua_register( L, "RL_SetSoundVolume", laudioSetSoundVolume ); lua_register( L, "RL_SetSoundPitch", laudioSetSoundPitch ); + lua_register( L, "RL_SetSoundPan", laudioSetSoundPan ); lua_register( L, "RL_WaveFormat", laudioWaveFormat ); lua_register( L, "RL_WaveCopy", laudioWaveCopy ); lua_register( L, "RL_WaveCrop", laudioWaveCrop ); @@ -1101,6 +1087,7 @@ void luaRegister() { lua_register( L, "RL_ResumeMusicStream", laudioResumeMusicStream ); lua_register( L, "RL_SetMusicVolume", laudioSetMusicVolume ); lua_register( L, "RL_SetMusicPitch", laudioSetMusicPitch ); + lua_register( L, "RL_SetMusicPan", laudioSetMusicPan ); lua_register( L, "RL_GetMusicTimeLength", laudioGetMusicTimeLength ); lua_register( L, "RL_GetMusicTimePlayed", laudioGetMusicTimePlayed ); diff --git a/src/models.c b/src/models.c index fc294e0..3028459 100644 --- a/src/models.c +++ b/src/models.c @@ -1452,32 +1452,6 @@ int lmodelsGenMeshTangents( lua_State *L ) { } /* -> success = RL_GenMeshBinormals( Mesh mesh ) - -Compute mesh binormals - -- Failure return false -- Success return true -*/ -int lmodelsGenMeshBinormals( lua_State *L ) { - if ( !lua_isnumber( L, -1 ) ) { - TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GenMeshBinormals( Mesh mesh )" ); - lua_pushboolean( L, false ); - return 1; - } - size_t meshId = lua_tointeger( L, -1 ); - - if ( !validMesh( meshId ) ) { - lua_pushboolean( L, false ); - return 1; - } - GenMeshBinormals( state->meshes[ meshId ] ); - lua_pushboolean( L, true ); - - return 1; -} - -/* ## Models - Material */ @@ -2386,33 +2360,6 @@ int lmodelsGetRayCollisionBox( lua_State *L ) { } /* -> rayCollision = RL_GetRayCollisionModel( Ray ray, Model model ) - -Get collision info between ray and model - -- Failure return nil -- Success return RayCollision -*/ -int lmodelsGetRayCollisionModel( lua_State *L ) { - if ( !lua_istable( L, -2 ) || !lua_isnumber( L, -1 ) ) { - TraceLog( LOG_WARNING, "%s", "Bad call of function. RL_GetRayCollisionModel( Ray ray, Model model )" ); - lua_pushnil( L ); - return 1; - } - size_t modelId = lua_tointeger( L, -1 ); - lua_pop( L, 1 ); - Ray ray = uluaGetRay( L ); - - if ( !validModel( modelId ) ) { - lua_pushnil( L ); - return 1; - } - uluaPushRayCollision( L, GetRayCollisionModel( ray, *state->models[ modelId ] ) ); - - return 1; -} - -/* > rayCollision = RL_GetRayCollisionMesh( Ray ray, Mesh mesh, Matrix transform ) Get collision info between ray and mesh diff --git a/src/state.c b/src/state.c index c87d064..8cecdcd 100644 --- a/src/state.c +++ b/src/state.c @@ -13,7 +13,7 @@ bool stateInit( const char *exePath ) { state->hasWindow = true; state->run = true; - state->resolution = (Vector2){ 1024, 720 }; + state->resolution = (Vector2){ 800, 600 }; state->luaState = NULL; state->textureSource = TEXTURE_SOURCE_TEXTURE; /* Images. */ @@ -93,7 +93,7 @@ bool stateInit( const char *exePath ) { state->materials[i] = NULL; } } - + InitWindow( state->resolution.x, state->resolution.y, "ReiLua" ); /* Has to be after InitWindod where opengl context is created. */ state->materials[0] = malloc( sizeof( Material ) ); |
