Audio and shapes now use new argumet style.

This commit is contained in:
jussi
2023-04-07 21:24:14 +03:00
parent 22f70cf06f
commit 6dad6544d7
7 changed files with 367 additions and 464 deletions

8
API.md
View File

@@ -1172,7 +1172,7 @@ Set window minimum dimensions ( for FLAG_WINDOW_RESIZABLE )
--- ---
> position = RL.GetMonitorPosition( int monitor ) > position = RL.GetMonitorPosition( )
Get specified monitor position Get specified monitor position
@@ -2539,7 +2539,7 @@ Draw line using quadratic bezier curves with a control point
--- ---
> success = RL.DrawLineStrip( Vector2{} points, int pointsCount, Color color ) > success = RL.DrawLineStrip( Vector2{} points, Color color )
Draw lines sequence Draw lines sequence
@@ -2728,7 +2728,7 @@ Draw triangle outline ( Vertex in counter-clockwise order! )
--- ---
> success = RL.DrawTriangleFan( Vector2{} points, int pointsCount, Color color ) > success = RL.DrawTriangleFan( Vector2{} points, Color color )
Draw a triangle fan defined by points ( first vertex is the center ) Draw a triangle fan defined by points ( first vertex is the center )
@@ -2737,7 +2737,7 @@ Draw a triangle fan defined by points ( first vertex is the center )
--- ---
> success = RL.DrawTriangleStrip( Vector2{} points, int pointsCount, Color color ) > success = RL.DrawTriangleStrip( Vector2{} points, Color color )
Draw a triangle strip defined by points Draw a triangle strip defined by points

View File

@@ -605,9 +605,8 @@ function RL.SetWindowMinSize( size ) end
---Get specified monitor position ---Get specified monitor position
---- Failure return nil ---- Failure return nil
---- Success return Vector2 ---- Success return Vector2
---@param monitor integer
---@return any position ---@return any position
function RL.GetMonitorPosition( monitor ) end function RL.GetMonitorPosition() end
---Get specified monitor size ---Get specified monitor size
---- Failure return nil ---- Failure return nil
@@ -1673,10 +1672,9 @@ function RL.DrawLineBezierCubic( startPos, endPos, startControlPos, endControlPo
---- Failure return false ---- Failure return false
---- Success return true ---- Success return true
---@param points any ---@param points any
---@param pointsCount integer
---@param color table ---@param color table
---@return any success ---@return any success
function RL.DrawLineStrip( points, pointsCount, color ) end function RL.DrawLineStrip( points, color ) end
---Draw a color-filled circle ---Draw a color-filled circle
---- Failure return false ---- Failure return false
@@ -1885,19 +1883,17 @@ function RL.DrawTriangleLines( v1, v2, v3, color ) end
---- Failure return false ---- Failure return false
---- Success return true ---- Success return true
---@param points any ---@param points any
---@param pointsCount integer
---@param color table ---@param color table
---@return any success ---@return any success
function RL.DrawTriangleFan( points, pointsCount, color ) end function RL.DrawTriangleFan( points, color ) end
---Draw a triangle strip defined by points ---Draw a triangle strip defined by points
---- Failure return false ---- Failure return false
---- Success return true ---- Success return true
---@param points any ---@param points any
---@param pointsCount integer
---@param color table ---@param color table
---@return any success ---@return any success
function RL.DrawTriangleStrip( points, pointsCount, color ) end function RL.DrawTriangleStrip( points, color ) end
---Draw a regular polygon ( Vector version ) ---Draw a regular polygon ( Vector version )
---- Failure return false ---- Failure return false

View File

@@ -30,6 +30,10 @@ Detailed changes:
- ADDED: ColorContrast - ADDED: ColorContrast
- ADDED: GenImagePerlinNoise - ADDED: GenImagePerlinNoise
- ADDED: GenImageText - ADDED: GenImageText
- CHANGED: DrawLineStrip no longer require pointsCount
- CHANGED: DrawTriangleFan no longer require pointsCount
- CHANGED: DrawTriangleStrip no longer require pointsCount
- REVISED: How argumets are handled. Now uluaGet* functions can take index. Also using mostly positive stack indexing.
------------------------------------------------------------------------ ------------------------------------------------------------------------
Release: ReiLua version 0.4.0 Using Raylib 4.2 Release: ReiLua version 0.4.0 Using Raylib 4.2

View File

@@ -22,10 +22,11 @@ Backlog {
* Models * Models
* DrawCapsule and DrawCapsuleWires * DrawCapsule and DrawCapsuleWires
* LoadMaterials * LoadMaterials
* Test * Needs Testing
* UpdateTexture * UpdateTexture
* UpdateTextureRec * UpdateTextureRec
* GetColor * GetColor
* LoadShader * LoadShader
* LoadShaderFromMemory * LoadShaderFromMemory
* LoadSoundFromWave
} }

View File

@@ -53,6 +53,34 @@ static void checkWaveRealloc( int i ) {
} }
} }
static int newSound() {
int i = 0;
for ( i = 0; i < state->soundCount; i++ ) {
if ( state->sounds[i] == NULL ) {
break;
}
}
state->sounds[i] = malloc( sizeof( Sound ) );
checkSoundRealloc( i );
return i;
}
static int newWave() {
int i = 0;
for ( i = 0; i < state->waveCount; i++ ) {
if ( state->waves[i] == NULL ) {
break;
}
}
state->waves[i] = malloc( sizeof( Wave ) );
checkWaveRealloc( i );
return i;
}
/* /*
## Audio - Audio device management ## Audio - Audio device management
*/ */
@@ -66,12 +94,14 @@ Set master volume ( listener )
- Success return true - Success return true
*/ */
int laudioSetMasterVolume( lua_State *L ) { int laudioSetMasterVolume( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMasterVolume( float volume )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMasterVolume( float volume )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SetMasterVolume( lua_tonumber( L, -1 ) ); float volume = lua_tonumber( L, 1 );
SetMasterVolume( volume );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -90,30 +120,22 @@ Load sound from file
- Success return int - Success return int
*/ */
int laudioLoadSound( lua_State *L ) { int laudioLoadSound( lua_State *L ) {
if ( !lua_isstring( L, -1 ) ) { if ( !lua_isstring( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadSound( string fileName )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadSound( string fileName )" );
lua_pushinteger( L, -1 ); lua_pushinteger( L, -1 );
return 1; return 1;
} }
if ( FileExists( lua_tostring( L, -1 ) ) ) { if ( FileExists( lua_tostring( L, 1 ) ) ) {
int i = 0; int i = newSound();
*state->sounds[i] = LoadSound( lua_tostring( L, 1 ) );
for ( i = 0; i < state->soundCount; i++ ) {
if ( state->sounds[i] == NULL ) {
break;
}
}
state->sounds[i] = malloc( sizeof( Sound ) );
*state->sounds[i] = LoadSound( lua_tostring( L, -1 ) );
lua_pushinteger( L, i ); lua_pushinteger( L, i );
checkSoundRealloc( i ); return 1;
} }
else { else {
lua_pushinteger( L, -1 ); lua_pushinteger( L, -1 );
return 1;
} }
return 1;
} }
/* /*
@@ -125,29 +147,22 @@ Load wave data from file
- Success return int - Success return int
*/ */
int laudioLoadWave( lua_State *L ) { int laudioLoadWave( lua_State *L ) {
if ( !lua_isstring( L, -1 ) ) { if ( !lua_isstring( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadWave( string fileName )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadWave( string fileName )" );
lua_pushinteger( L, -1 ); lua_pushinteger( L, -1 );
return 1; return 1;
} }
if ( FileExists( lua_tostring( L, -1 ) ) ) { if ( FileExists( lua_tostring( L, 1 ) ) ) {
int i = 0; int i = newWave();
*state->waves[i] = LoadWave( lua_tostring( L, 1 ) );
for ( i = 0; i < state->waveCount; i++ ) {
if ( state->waves[i] == NULL ) {
break;
}
}
state->waves[i] = malloc( sizeof( Wave ) );
*state->waves[i] = LoadWave( lua_tostring( L, -1 ) );
lua_pushinteger( L, i ); lua_pushinteger( L, i );
checkWaveRealloc( i ); return 1;
} }
else { else {
lua_pushinteger( L, -1 ); lua_pushinteger( L, -1 );
return 1;
} }
return 1;
} }
/* /*
@@ -159,28 +174,20 @@ Load sound from wave data
- Success return int - Success return int
*/ */
int laudioLoadSoundFromWave( lua_State *L ) { int laudioLoadSoundFromWave( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadSoundFromWave( Wave wave )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadSoundFromWave( Wave wave )" );
lua_pushinteger( L, -1 ); lua_pushinteger( L, -1 );
return 1; return 1;
} }
size_t waveId = lua_tointeger( L, -1 ); size_t waveId = lua_tointeger( L, 1 );
if ( !validWave( waveId ) ) { if ( !validWave( waveId ) ) {
lua_pushinteger( L, -1 ); lua_pushinteger( L, -1 );
return 1; return 1;
} }
int i = 0; int i = newSound();
for ( i = 0; i < state->soundCount; i++ ) {
if ( state->sounds[i] == NULL ) {
break;
}
}
state->sounds[i] = malloc( sizeof( Sound ) );
*state->sounds[i] = LoadSoundFromWave( *state->waves[ waveId ] ); *state->sounds[i] = LoadSoundFromWave( *state->waves[ waveId ] );
lua_pushinteger( L, i ); lua_pushinteger( L, i );
checkSoundRealloc( i );
return 1; return 1;
} }
@@ -194,19 +201,19 @@ Unload sound
- Success return true - Success return true
*/ */
int laudioUnloadSound( lua_State *L ) { int laudioUnloadSound( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadSound( Sound sound )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadSound( Sound sound )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t id = lua_tointeger( L, -1 ); size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( id ) ) { if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
UnloadSound( *state->sounds[ id ] ); UnloadSound( *state->sounds[ soundId ] );
state->sounds[ id ] = NULL; state->sounds[ soundId ] = NULL;
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -221,19 +228,19 @@ Unload wave data
- Success return true - Success return true
*/ */
int laudioUnloadWave( lua_State *L ) { int laudioUnloadWave( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadWave( Wave wave )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.UnloadWave( Wave wave )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t id = lua_tointeger( L, -1 ); size_t waveId = lua_tointeger( L, 1 );
if ( !validWave( id ) ) { if ( !validWave( waveId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
UnloadWave( *state->waves[ id ] ); UnloadWave( *state->waves[ waveId ] );
state->waves[ id ] = NULL; state->waves[ waveId ] = NULL;
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -248,18 +255,18 @@ Export wave data to file, returns true on success
- Success return true - Success return true
*/ */
int laudioExportWave( lua_State *L ) { int laudioExportWave( lua_State *L ) {
if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportWave( Wave wave, string fileName )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportWave( Wave wave, string fileName )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t id = lua_tointeger( L, -2 ); size_t waveId = lua_tointeger( L, 1 );
if ( !validWave( id ) ) { if ( !validWave( waveId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
lua_pushboolean( L, ExportWave( *state->waves[ id ], lua_tostring( L, -1 ) ) ); lua_pushboolean( L, ExportWave( *state->waves[ waveId ], lua_tostring( L, 2 ) ) );
return 1; return 1;
} }
@@ -273,18 +280,18 @@ Export wave sample data to code (.h), returns true on success
- Success return true - Success return true
*/ */
int laudioExportWaveAsCode( lua_State *L ) { int laudioExportWaveAsCode( lua_State *L ) {
if ( !lua_isnumber( L, -2 ) || !lua_isstring( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) || !lua_isstring( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportWaveAsCode( Wave wave, string fileName )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ExportWaveAsCode( Wave wave, string fileName )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t id = lua_tointeger( L, -2 ); size_t waveId = lua_tointeger( L, 1 );
if ( !validWave( id ) ) { if ( !validWave( waveId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
lua_pushboolean( L, ExportWaveAsCode( *state->waves[ id ], lua_tostring( L, -1 ) ) ); lua_pushboolean( L, ExportWaveAsCode( *state->waves[ waveId ], lua_tostring( L, 2 ) ) );
return 1; return 1;
} }
@@ -302,12 +309,12 @@ Play a sound
- Success return true - Success return true
*/ */
int laudioPlaySound( lua_State *L ) { int laudioPlaySound( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.PlaySound( Sound sound )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.PlaySound( Sound sound )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t soundId = lua_tointeger( L, -1 ); size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) { if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
@@ -328,12 +335,12 @@ Stop playing a sound
- Success return true - Success return true
*/ */
int laudioStopSound( lua_State *L ) { int laudioStopSound( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.StopSound( Sound sound )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.StopSound( Sound sound )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t soundId = lua_tointeger( L, -1 ); size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) { if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
@@ -354,12 +361,12 @@ Pause a sound
- Success return true - Success return true
*/ */
int laudioPauseSound( lua_State *L ) { int laudioPauseSound( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.PauseSound( Sound sound )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.PauseSound( Sound sound )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t soundId = lua_tointeger( L, -1 ); size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) { if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
@@ -380,12 +387,12 @@ Resume a paused sound
- Success return true - Success return true
*/ */
int laudioResumeSound( lua_State *L ) { int laudioResumeSound( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ResumeSound( Sound sound )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.ResumeSound( Sound sound )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
size_t soundId = lua_tointeger( L, -1 ); size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) { if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
@@ -406,12 +413,12 @@ Check if a sound is currently playing
- Success return bool - Success return bool
*/ */
int laudioIsSoundPlaying( lua_State *L ) { int laudioIsSoundPlaying( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.IsSoundPlaying( Sound sound )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.IsSoundPlaying( Sound sound )" );
lua_pushnil( L ); lua_pushnil( L );
return 1; return 1;
} }
size_t soundId = lua_tointeger( L, -1 ); size_t soundId = lua_tointeger( L, 1 );
if ( !validSound( soundId ) ) { if ( !validSound( soundId ) ) {
lua_pushnil( L ); lua_pushnil( L );
@@ -431,16 +438,19 @@ Set volume for a sound ( 1.0 is max level )
- Success return true - Success return true
*/ */
int laudioSetSoundVolume( lua_State *L ) { int laudioSetSoundVolume( lua_State *L ) {
if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundVolume( Sound sound, float volume )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundVolume( Sound sound, float volume )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
if ( !validSound( lua_tointeger( L, -2 ) ) ) { size_t soundId = lua_tointeger( L, 1 );
float volume = lua_tonumber( L, 2 );
if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SetSoundVolume( *state->sounds[ lua_tointeger( L, -2 ) ], lua_tonumber( L, -1 ) ); SetSoundVolume( *state->sounds[ soundId ], volume );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -455,16 +465,19 @@ Set pitch for a sound ( 1.0 is base level )
- Success return true - Success return true
*/ */
int laudioSetSoundPitch( lua_State *L ) { int laudioSetSoundPitch( lua_State *L ) {
if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundPitch( Sound sound, float pitch )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundPitch( Sound sound, float pitch )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
if ( !validSound( lua_tointeger( L, -2 ) ) ) { size_t soundId = lua_tointeger( L, 1 );
float pitch = lua_tonumber( L, 2 );
if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SetSoundPitch( *state->sounds[ lua_tointeger( L, -2 ) ], lua_tonumber( L, -1 ) ); SetSoundPitch( *state->sounds[ soundId ], pitch );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -479,16 +492,19 @@ Set pan for a sound ( 0.5 is center )
- Success return true - Success return true
*/ */
int laudioSetSoundPan( lua_State *L ) { int laudioSetSoundPan( lua_State *L ) {
if ( !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundPan( Sound sound, float pitch )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetSoundPan( Sound sound, float pitch )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
if ( !validSound( lua_tointeger( L, -2 ) ) ) { size_t soundId = lua_tointeger( L, 1 );
float pan = lua_tonumber( L, 2 );
if ( !validSound( soundId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SetSoundPan( *state->sounds[ lua_tointeger( L, -2 ) ], lua_tonumber( L, -1 ) ); SetSoundPan( *state->sounds[ soundId ], pan );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -503,15 +519,15 @@ Convert wave data to desired format
- Success return true - Success return true
*/ */
int laudioWaveFormat( lua_State *L ) { int laudioWaveFormat( lua_State *L ) {
if ( !lua_isnumber( L, -4 ) || !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) || !lua_isnumber( L, 4 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveFormat( Wave wave, int sampleRate, int sampleSize, int channels )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveFormat( Wave wave, int sampleRate, int sampleSize, int channels )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
int channels = lua_tointeger( L, -1 ); size_t waveId = lua_tointeger( L, 1 );
int sampleSize = lua_tointeger( L, -2 ); int sampleRate = lua_tointeger( L, 2 );
int sampleRate = lua_tointeger( L, -3 ); int sampleSize = lua_tointeger( L, 3 );
size_t waveId = lua_tointeger( L, -4 ); int channels = lua_tointeger( L, 4 );
if ( !validWave( waveId ) ) { if ( !validWave( waveId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
@@ -532,28 +548,20 @@ Copy a wave to a new wave
- Success return int - Success return int
*/ */
int laudioWaveCopy( lua_State *L ) { int laudioWaveCopy( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveCopy( Wave wave )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveCopy( Wave wave )" );
lua_pushinteger( L, -1 ); lua_pushinteger( L, -1 );
return 1; return 1;
} }
size_t waveId = lua_tointeger( L, -1 ); size_t waveId = lua_tointeger( L, 1 );
if ( !validWave( waveId ) ) { if ( !validWave( waveId ) ) {
lua_pushnil( L ); lua_pushinteger( L, -1 );
return 1; return 1;
} }
int i = 0; int i = newWave();
for ( i = 0; i < state->waveCount; i++ ) {
if ( state->waves[i] == NULL ) {
break;
}
}
state->waves[i] = malloc( sizeof( Wave ) );
*state->waves[i] = WaveCopy( *state->waves[ waveId ] ); *state->waves[i] = WaveCopy( *state->waves[ waveId ] );
lua_pushinteger( L, i ); lua_pushinteger( L, i );
checkWaveRealloc( i );
return 1; return 1;
} }
@@ -567,14 +575,14 @@ Crop a wave to defined samples range
- Success return true - Success return true
*/ */
int laudioWaveCrop( lua_State *L ) { int laudioWaveCrop( lua_State *L ) {
if ( !lua_isnumber( L, -3 ) || !lua_isnumber( L, -2 ) || !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) || !lua_isnumber( L, 3 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveCrop( Wave wave, int initSample, int finalSample )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.WaveCrop( Wave wave, int initSample, int finalSample )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
int finalSample = lua_tointeger( L, -1 ); size_t waveId = lua_tointeger( L, 1 );
int initSample = lua_tointeger( L, -2 ); int initSample = lua_tointeger( L, 2 );
size_t waveId = lua_tointeger( L, -3 ); int finalSample = lua_tointeger( L, 3 );
if ( !validWave( waveId ) ) { if ( !validWave( waveId ) ) {
lua_pushboolean( L, false ); lua_pushboolean( L, false );
@@ -599,13 +607,13 @@ Load music stream from file
- Success return true - Success return true
*/ */
int laudioLoadMusicStream( lua_State *L ) { int laudioLoadMusicStream( lua_State *L ) {
if ( !lua_isstring( L, -1 ) ) { if ( !lua_isstring( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadMusicStream( string fileName )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.LoadMusicStream( string fileName )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
if ( FileExists( lua_tostring( L, -1 ) ) ) { if ( FileExists( lua_tostring( L, 1 ) ) ) {
state->music = LoadMusicStream( lua_tostring( L, -1 ) ); state->music = LoadMusicStream( lua_tostring( L, 1 ) );
state->music.looping = false; state->music.looping = false;
lua_pushboolean( L, true ); lua_pushboolean( L, true );
@@ -683,12 +691,14 @@ Seek music to a position ( in seconds )
- Success return true - Success return true
*/ */
int laudioSeekMusicStream( lua_State *L ) { int laudioSeekMusicStream( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SeekMusicStream( float position )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SeekMusicStream( float position )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SeekMusicStream( state->music, lua_tonumber( L, -1 ) ); float position = lua_tonumber( L, 1 );
SeekMusicStream( state->music, position );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -703,12 +713,14 @@ Set volume for music ( 1.0 is max level )
- Success return true - Success return true
*/ */
int laudioSetMusicVolume( lua_State *L ) { int laudioSetMusicVolume( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicVolume( float volume )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicVolume( float volume )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SetMusicVolume( state->music, lua_tonumber( L, -1 ) ); float volume = lua_tonumber( L, 1 );
SetMusicVolume( state->music, volume );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -723,12 +735,14 @@ Set pitch for a music ( 1.0 is base level )
- Success return true - Success return true
*/ */
int laudioSetMusicPitch( lua_State *L ) { int laudioSetMusicPitch( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicPitch( float pitch )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicPitch( float pitch )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SetMusicPitch( state->music, lua_tonumber( L, -1 ) ); float pitch = lua_tonumber( L, 1 );
SetMusicPitch( state->music, pitch );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;
@@ -743,12 +757,14 @@ Set pan for a music ( 0.5 is center )
- Success return true - Success return true
*/ */
int laudioSetMusicPan( lua_State *L ) { int laudioSetMusicPan( lua_State *L ) {
if ( !lua_isnumber( L, -1 ) ) { if ( !lua_isnumber( L, 1 ) ) {
TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicPan( float pan )" ); TraceLog( LOG_WARNING, "%s", "Bad call of function. RL.SetMusicPan( float pan )" );
lua_pushboolean( L, false ); lua_pushboolean( L, false );
return 1; return 1;
} }
SetMusicPitch( state->music, lua_tonumber( L, -1 ) ); float pan = lua_tonumber( L, 1 );
SetMusicPitch( state->music, pan );
lua_pushboolean( L, true ); lua_pushboolean( L, true );
return 1; return 1;

File diff suppressed because it is too large Load Diff

View File

@@ -154,7 +154,6 @@ int ltexturesLoadImage( lua_State *L ) {
int i = newImage(); int i = newImage();
*state->images[i] = LoadImage( lua_tostring( L, 1 ) ); *state->images[i] = LoadImage( lua_tostring( L, 1 ) );
lua_pushinteger( L, i ); lua_pushinteger( L, i );
return 1; return 1;
} }
else { else {