Moved to raylib 4.2.0. Renamed some directory functions to raylib 4.2.0 conventions. Removed GenMeshBinormals and GetRayCollisionModel. Sound and music pan.
This commit is contained in:
44
src/audio.c
44
src/audio.c
@@ -520,6 +520,30 @@ int laudioSetSoundPitch( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
@@ -760,6 +784,26 @@ int laudioSetMusicPitch( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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()
|
||||
|
||||
|
||||
37
src/core.c
37
src/core.c
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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 );
|
||||
|
||||
|
||||
53
src/models.c
53
src/models.c
@@ -1451,32 +1451,6 @@ int lmodelsGenMeshTangents( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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
|
||||
*/
|
||||
@@ -2385,33 +2359,6 @@ int lmodelsGetRayCollisionBox( lua_State *L ) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
> 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 )
|
||||
|
||||
|
||||
@@ -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 ) );
|
||||
|
||||
Reference in New Issue
Block a user