New object types for Wave, Sound, Music and Light.
This commit is contained in:
179
API.md
179
API.md
@@ -4646,13 +4646,10 @@ Get collision info between ray and quad
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetMasterVolume( float volume )
|
||||
> RL.SetMasterVolume( float volume )
|
||||
|
||||
Set master volume (listener)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
## Audio - Wave/Sound Loading
|
||||
@@ -4663,8 +4660,8 @@ Set master volume ( listener )
|
||||
|
||||
Load sound from file
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
- Failure return nil
|
||||
- Success return Sound
|
||||
|
||||
---
|
||||
|
||||
@@ -4672,8 +4669,8 @@ Load sound from file
|
||||
|
||||
Load wave data from file
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
- Failure return nil
|
||||
- Success return Wave
|
||||
|
||||
---
|
||||
|
||||
@@ -4681,26 +4678,7 @@ Load wave data from file
|
||||
|
||||
Load sound from wave data
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
|
||||
---
|
||||
|
||||
> success = RL.UnloadSound( Sound sound )
|
||||
|
||||
Unload sound
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.UnloadWave( Wave wave )
|
||||
|
||||
Unload wave data
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
- Success return Sound
|
||||
|
||||
---
|
||||
|
||||
@@ -4708,8 +4686,7 @@ Unload wave data
|
||||
|
||||
Export wave data to file, returns true on success
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
- Success return bool
|
||||
|
||||
---
|
||||
|
||||
@@ -4717,7 +4694,6 @@ Export wave data to file, returns true on success
|
||||
|
||||
Export wave sample data to code (.h), returns true on success
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
@@ -4726,103 +4702,74 @@ Export wave sample data to code (.h), returns true on success
|
||||
|
||||
---
|
||||
|
||||
> success = RL.PlaySound( Sound sound )
|
||||
> RL.PlaySound( Sound sound )
|
||||
|
||||
Play a sound
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.StopSound( Sound sound )
|
||||
> RL.StopSound( Sound sound )
|
||||
|
||||
Stop playing a sound
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.PauseSound( Sound sound )
|
||||
> RL.PauseSound( Sound sound )
|
||||
|
||||
Pause a sound
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.ResumeSound( Sound sound )
|
||||
> RL.ResumeSound( Sound sound )
|
||||
|
||||
Resume a paused sound
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> playing = RL.IsSoundPlaying( Sound sound )
|
||||
|
||||
Check if a sound is currently playing
|
||||
|
||||
- Failure return nil
|
||||
- Success return bool
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetSoundVolume( Sound sound, float volume )
|
||||
> RL.SetSoundVolume( Sound sound, float volume )
|
||||
|
||||
Set volume for a sound (1.0 is max level)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetSoundPitch( Sound sound, float pitch )
|
||||
> RL.SetSoundPitch( Sound sound, float pitch )
|
||||
|
||||
Set pitch for a sound (1.0 is base level)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetSoundPan( Sound sound, float pan )
|
||||
> RL.SetSoundPan( Sound sound, float pan )
|
||||
|
||||
Set pan for a sound (0.5 is center)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.WaveFormat( Wave wave, int sampleRate, int sampleSize, int channels )
|
||||
> RL.WaveFormat( Wave wave, int sampleRate, int sampleSize, int channels )
|
||||
|
||||
Convert wave data to desired format
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> wave = RL.WaveCopy( Wave wave )
|
||||
|
||||
Copy a wave to a new wave
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
- Success return Wave
|
||||
|
||||
---
|
||||
|
||||
> success = RL.WaveCrop( Wave wave, int initSample, int finalSample )
|
||||
> RL.WaveCrop( Wave wave, int initSample, int finalSample )
|
||||
|
||||
Crop a wave to defined samples range
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
## Audio - Music management
|
||||
@@ -4833,115 +4780,82 @@ Crop a wave to defined samples range
|
||||
|
||||
Load music stream from file
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
- Success return Music
|
||||
|
||||
---
|
||||
|
||||
> success = RL.PlayMusicStream( Music music )
|
||||
> RL.PlayMusicStream( Music music )
|
||||
|
||||
Start music playing
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> playing = RL.IsMusicStreamPlaying( Music music )
|
||||
|
||||
Check if music is playing
|
||||
|
||||
- Failure return nil
|
||||
- Success return bool
|
||||
|
||||
---
|
||||
|
||||
> success = RL.UpdateMusicStream( Music music )
|
||||
> RL.UpdateMusicStream( Music music )
|
||||
|
||||
Updates buffers for music streaming
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.StopMusicStream( Music music )
|
||||
> RL.StopMusicStream( Music music )
|
||||
|
||||
Stop music playing
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.PauseMusicStream( Music music )
|
||||
> RL.PauseMusicStream( Music music )
|
||||
|
||||
Pause music playing
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.ResumeMusicStream( Music music )
|
||||
> RL.ResumeMusicStream( Music music )
|
||||
|
||||
Resume playing paused music
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SeekMusicStream( Music music, float position )
|
||||
> RL.SeekMusicStream( Music music, float position )
|
||||
|
||||
Seek music to a position (in seconds)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetMusicVolume( Music music, float volume )
|
||||
> RL.SetMusicVolume( Music music, float volume )
|
||||
|
||||
Set volume for music (1.0 is max level)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetMusicPitch( Music music, float pitch )
|
||||
> RL.SetMusicPitch( Music music, float pitch )
|
||||
|
||||
Set pitch for a music (1.0 is base level)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetMusicPan( Music music, float pan )
|
||||
> RL.SetMusicPan( Music music, float pan )
|
||||
|
||||
Set pan for a music (0.5 is center)
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetMusicLooping( Music music, bool looping )
|
||||
> RL.SetMusicLooping( Music music, bool looping )
|
||||
|
||||
Set looping for a music
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> looping = RL.GetMusicLooping( Music music )
|
||||
|
||||
Get looping of a music
|
||||
|
||||
- Failure return nil
|
||||
- Success return bool
|
||||
|
||||
---
|
||||
@@ -4950,16 +4864,14 @@ Get looping of a music
|
||||
|
||||
Get music time length (in seconds)
|
||||
|
||||
- Failure return false
|
||||
- Success return float
|
||||
|
||||
---
|
||||
|
||||
> played = RL.GetMusicTimePlayed( Music music )
|
||||
> timePlayed = RL.GetMusicTimePlayed( Music music )
|
||||
|
||||
Get current music time played (in seconds)
|
||||
|
||||
- Failure return false
|
||||
- Success return float
|
||||
|
||||
---
|
||||
@@ -6466,8 +6378,7 @@ Check icon pixel value
|
||||
|
||||
Create a light and get shader locations
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
- Success return Light
|
||||
|
||||
---
|
||||
|
||||
@@ -6477,56 +6388,40 @@ Send light properties to shader
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetLightType( Light light, int type )
|
||||
> RL.SetLightType( Light light, int type )
|
||||
|
||||
Set light type
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetLightPosition( Light light, Vector3 position )
|
||||
> RL.SetLightPosition( Light light, Vector3 position )
|
||||
|
||||
Set light position
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetLightTarget( Light light, Vector3 target )
|
||||
> RL.SetLightTarget( Light light, Vector3 target )
|
||||
|
||||
Set light target
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetLightColor( Light light, Color color )
|
||||
> RL.SetLightColor( Light light, Color color )
|
||||
|
||||
Set light color
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> success = RL.SetLightEnabled( Light light, bool enabled )
|
||||
> RL.SetLightEnabled( Light light, bool enabled )
|
||||
|
||||
Set light enabled
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
|
||||
---
|
||||
|
||||
> type = RL.GetLightType( Light light )
|
||||
|
||||
Get light type
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
|
||||
---
|
||||
@@ -6535,7 +6430,6 @@ Get light type
|
||||
|
||||
Get light position
|
||||
|
||||
- Failure return false
|
||||
- Success return Vector3
|
||||
|
||||
---
|
||||
@@ -6544,7 +6438,6 @@ Get light position
|
||||
|
||||
Get light target
|
||||
|
||||
- Failure return false
|
||||
- Success return Vector3
|
||||
|
||||
---
|
||||
@@ -6553,7 +6446,6 @@ Get light target
|
||||
|
||||
Get light color
|
||||
|
||||
- Failure return false
|
||||
- Success return Color
|
||||
|
||||
---
|
||||
@@ -6562,7 +6454,6 @@ Get light color
|
||||
|
||||
Get light enabled
|
||||
|
||||
- Failure return nil
|
||||
- Success return boolean
|
||||
|
||||
---
|
||||
|
||||
150
ReiLua_API.lua
150
ReiLua_API.lua
@@ -3574,59 +3574,40 @@ function RL.GetRayCollisionQuad( ray, p1, p2, p3, p4 ) end
|
||||
-- Audio - Audio device management
|
||||
|
||||
---Set master volume (listener)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param volume number
|
||||
---@return any success
|
||||
---@return any RL.SetMasterVolume
|
||||
function RL.SetMasterVolume( volume ) end
|
||||
|
||||
-- Audio - Wave/Sound Loading
|
||||
|
||||
---Load sound from file
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---- Failure return nil
|
||||
---- Success return Sound
|
||||
---@param fileName string
|
||||
---@return any sound
|
||||
function RL.LoadSound( fileName ) end
|
||||
|
||||
---Load wave data from file
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---- Failure return nil
|
||||
---- Success return Wave
|
||||
---@param fileName string
|
||||
---@return any wave
|
||||
function RL.LoadWave( fileName ) end
|
||||
|
||||
---Load sound from wave data
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---- Success return Sound
|
||||
---@param wave any
|
||||
---@return any sound
|
||||
function RL.LoadSoundFromWave( wave ) end
|
||||
|
||||
---Unload sound
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@return any success
|
||||
function RL.UnloadSound( sound ) end
|
||||
|
||||
---Unload wave data
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param wave any
|
||||
---@return any success
|
||||
function RL.UnloadWave( wave ) end
|
||||
|
||||
---Export wave data to file, returns true on success
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---- Success return bool
|
||||
---@param wave any
|
||||
---@param fileName string
|
||||
---@return any success
|
||||
function RL.ExportWave( wave, fileName ) end
|
||||
|
||||
---Export wave sample data to code (.h), returns true on success
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param wave any
|
||||
---@param fileName string
|
||||
@@ -3636,200 +3617,155 @@ function RL.ExportWaveAsCode( wave, fileName ) end
|
||||
-- Audio - Wave/Sound management
|
||||
|
||||
---Play a sound
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@return any success
|
||||
---@return any RL.PlaySound
|
||||
function RL.PlaySound( sound ) end
|
||||
|
||||
---Stop playing a sound
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@return any success
|
||||
---@return any RL.StopSound
|
||||
function RL.StopSound( sound ) end
|
||||
|
||||
---Pause a sound
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@return any success
|
||||
---@return any RL.PauseSound
|
||||
function RL.PauseSound( sound ) end
|
||||
|
||||
---Resume a paused sound
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@return any success
|
||||
---@return any RL.ResumeSound
|
||||
function RL.ResumeSound( sound ) end
|
||||
|
||||
---Check if a sound is currently playing
|
||||
---- Failure return nil
|
||||
---- Success return bool
|
||||
---@param sound any
|
||||
---@return any playing
|
||||
function RL.IsSoundPlaying( sound ) end
|
||||
|
||||
---Set volume for a sound (1.0 is max level)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@param volume number
|
||||
---@return any success
|
||||
---@return any RL.SetSoundVolume
|
||||
function RL.SetSoundVolume( sound, volume ) end
|
||||
|
||||
---Set pitch for a sound (1.0 is base level)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@param pitch number
|
||||
---@return any success
|
||||
---@return any RL.SetSoundPitch
|
||||
function RL.SetSoundPitch( sound, pitch ) end
|
||||
|
||||
---Set pan for a sound (0.5 is center)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param sound any
|
||||
---@param pan number
|
||||
---@return any success
|
||||
---@return any RL.SetSoundPan
|
||||
function RL.SetSoundPan( sound, pan ) end
|
||||
|
||||
---Convert wave data to desired format
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param wave any
|
||||
---@param sampleRate integer
|
||||
---@param sampleSize integer
|
||||
---@param channels integer
|
||||
---@return any success
|
||||
---@return any RL.WaveFormat
|
||||
function RL.WaveFormat( wave, sampleRate, sampleSize, channels ) end
|
||||
|
||||
---Copy a wave to a new wave
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---- Success return Wave
|
||||
---@param wave any
|
||||
---@return any wave
|
||||
function RL.WaveCopy( wave ) end
|
||||
|
||||
---Crop a wave to defined samples range
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param wave any
|
||||
---@param initSample integer
|
||||
---@param finalSample integer
|
||||
---@return any success
|
||||
---@return any RL.WaveCrop
|
||||
function RL.WaveCrop( wave, initSample, finalSample ) end
|
||||
|
||||
-- Audio - Music management
|
||||
|
||||
---Load music stream from file
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---- Success return Music
|
||||
---@param fileName string
|
||||
---@return any music
|
||||
function RL.LoadMusicStream( fileName ) end
|
||||
|
||||
---Start music playing
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@return any success
|
||||
---@return any RL.PlayMusicStream
|
||||
function RL.PlayMusicStream( music ) end
|
||||
|
||||
---Check if music is playing
|
||||
---- Failure return nil
|
||||
---- Success return bool
|
||||
---@param music any
|
||||
---@return any playing
|
||||
function RL.IsMusicStreamPlaying( music ) end
|
||||
|
||||
---Updates buffers for music streaming
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@return any success
|
||||
---@return any RL.UpdateMusicStream
|
||||
function RL.UpdateMusicStream( music ) end
|
||||
|
||||
---Stop music playing
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@return any success
|
||||
---@return any RL.StopMusicStream
|
||||
function RL.StopMusicStream( music ) end
|
||||
|
||||
---Pause music playing
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@return any success
|
||||
---@return any RL.PauseMusicStream
|
||||
function RL.PauseMusicStream( music ) end
|
||||
|
||||
---Resume playing paused music
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@return any success
|
||||
---@return any RL.ResumeMusicStream
|
||||
function RL.ResumeMusicStream( music ) end
|
||||
|
||||
---Seek music to a position (in seconds)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@param position number
|
||||
---@return any success
|
||||
---@return any RL.SeekMusicStream
|
||||
function RL.SeekMusicStream( music, position ) end
|
||||
|
||||
---Set volume for music (1.0 is max level)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@param volume number
|
||||
---@return any success
|
||||
---@return any RL.SetMusicVolume
|
||||
function RL.SetMusicVolume( music, volume ) end
|
||||
|
||||
---Set pitch for a music (1.0 is base level)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@param pitch number
|
||||
---@return any success
|
||||
---@return any RL.SetMusicPitch
|
||||
function RL.SetMusicPitch( music, pitch ) end
|
||||
|
||||
---Set pan for a music (0.5 is center)
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@param pan number
|
||||
---@return any success
|
||||
---@return any RL.SetMusicPan
|
||||
function RL.SetMusicPan( music, pan ) end
|
||||
|
||||
---Set looping for a music
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param music any
|
||||
---@param looping boolean
|
||||
---@return any success
|
||||
---@return any RL.SetMusicLooping
|
||||
function RL.SetMusicLooping( music, looping ) end
|
||||
|
||||
---Get looping of a music
|
||||
---- Failure return nil
|
||||
---- Success return bool
|
||||
---@param music any
|
||||
---@return any looping
|
||||
function RL.GetMusicLooping( music ) end
|
||||
|
||||
---Get music time length (in seconds)
|
||||
---- Failure return false
|
||||
---- Success return float
|
||||
---@param music any
|
||||
---@return any length
|
||||
function RL.GetMusicTimeLength( music ) end
|
||||
|
||||
---Get current music time played (in seconds)
|
||||
---- Failure return false
|
||||
---- Success return float
|
||||
---@param music any
|
||||
---@return any played
|
||||
---@return any timePlayed
|
||||
function RL.GetMusicTimePlayed( music ) end
|
||||
|
||||
-- Math - Utils
|
||||
@@ -5189,8 +5125,7 @@ function RL.GuiCheckIconPixel( iconId, pos ) end
|
||||
-- Lights - Basics
|
||||
|
||||
---Create a light and get shader locations
|
||||
---- Failure return -1
|
||||
---- Success return int
|
||||
---- Success return Light
|
||||
---@param type integer
|
||||
---@param position table
|
||||
---@param target table
|
||||
@@ -5206,75 +5141,60 @@ function RL.CreateLight( type, position, target, color, shader ) end
|
||||
function RL.UpdateLightValues( shader, light ) end
|
||||
|
||||
---Set light type
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param light any
|
||||
---@param type integer
|
||||
---@return any success
|
||||
---@return any RL.SetLightType
|
||||
function RL.SetLightType( light, type ) end
|
||||
|
||||
---Set light position
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param light any
|
||||
---@param position table
|
||||
---@return any success
|
||||
---@return any RL.SetLightPosition
|
||||
function RL.SetLightPosition( light, position ) end
|
||||
|
||||
---Set light target
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param light any
|
||||
---@param target table
|
||||
---@return any success
|
||||
---@return any RL.SetLightTarget
|
||||
function RL.SetLightTarget( light, target ) end
|
||||
|
||||
---Set light color
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param light any
|
||||
---@param color table
|
||||
---@return any success
|
||||
---@return any RL.SetLightColor
|
||||
function RL.SetLightColor( light, color ) end
|
||||
|
||||
---Set light enabled
|
||||
---- Failure return false
|
||||
---- Success return true
|
||||
---@param light any
|
||||
---@param enabled boolean
|
||||
---@return any success
|
||||
---@return any RL.SetLightEnabled
|
||||
function RL.SetLightEnabled( light, enabled ) end
|
||||
|
||||
---Get light type
|
||||
---- Failure return false
|
||||
---- Success return int
|
||||
---@param light any
|
||||
---@return any type
|
||||
function RL.GetLightType( light ) end
|
||||
|
||||
---Get light position
|
||||
---- Failure return false
|
||||
---- Success return Vector3
|
||||
---@param light any
|
||||
---@return any position
|
||||
function RL.GetLightPosition( light ) end
|
||||
|
||||
---Get light target
|
||||
---- Failure return false
|
||||
---- Success return Vector3
|
||||
---@param light any
|
||||
---@return any target
|
||||
function RL.GetLightTarget( light ) end
|
||||
|
||||
---Get light color
|
||||
---- Failure return false
|
||||
---- Success return Color
|
||||
---@param light any
|
||||
---@return any color
|
||||
function RL.GetLightColor( light ) end
|
||||
|
||||
---Get light enabled
|
||||
---- Failure return nil
|
||||
---- Success return boolean
|
||||
---@param light any
|
||||
---@return any enabled
|
||||
|
||||
@@ -14,7 +14,9 @@ DETAILED CHANGES:
|
||||
- ADDED: GetRenderTextureTexture and GetRenderTextureDepthTexture.
|
||||
- REMOVED: UnloadCamera2D and UnloadCamera3D.
|
||||
- REMOVED: UnloadShader.
|
||||
- REMOVED: UnloadFont.
|
||||
- ADDED: LoadFontEx takes also fontChars.
|
||||
- REMOVED: UnloadWave and UnloadSound.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
Release: ReiLua version 0.5.0 Using Raylib 4.5
|
||||
|
||||
@@ -6,8 +6,6 @@ int laudioSetMasterVolume( lua_State *L );
|
||||
int laudioLoadSound( lua_State *L );
|
||||
int laudioLoadWave( lua_State *L );
|
||||
int laudioLoadSoundFromWave( lua_State *L );
|
||||
int laudioUnloadSound( lua_State *L );
|
||||
int laudioUnloadWave( lua_State *L );
|
||||
int laudioExportWave( lua_State *L );
|
||||
int laudioExportWaveAsCode( lua_State *L );
|
||||
/* Wave/Sound management. */
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
/* Validators. */
|
||||
bool validLight( size_t id );
|
||||
/* Basics. */
|
||||
int llightsCreateLight( lua_State *L );
|
||||
int llightsUpdateLightValues( lua_State *L );
|
||||
|
||||
@@ -75,6 +75,10 @@ void uluaPushCamera2D( lua_State *L, Camera2D camera );
|
||||
void uluaPushCamera3D( lua_State *L, Camera3D camera );
|
||||
void uluaPushShader( lua_State *L, Shader shader );
|
||||
void uluaPushFont( lua_State *L, Font font );
|
||||
void uluaPushWave( lua_State *L, Wave wave );
|
||||
void uluaPushSound( lua_State *L, Sound sound );
|
||||
void uluaPushMusic( lua_State *L, Music music );
|
||||
void uluaPushLight( lua_State *L, Light light );
|
||||
|
||||
int uluaGetTableLen( lua_State *L );
|
||||
int uluaGetTableLenIndex( lua_State *L, int index );
|
||||
|
||||
@@ -15,18 +15,6 @@ typedef struct {
|
||||
Vector2 resolution;
|
||||
int logLevelInvalid;
|
||||
/* Resources. */
|
||||
/* Sounds. */
|
||||
Wave **waves;
|
||||
size_t waveCount;
|
||||
size_t waveAlloc;
|
||||
/* Sounds. */
|
||||
Sound **sounds;
|
||||
size_t soundCount;
|
||||
size_t soundAlloc;
|
||||
/* Music. */
|
||||
Music **musics;
|
||||
size_t musicCount;
|
||||
size_t musicAlloc;
|
||||
/* Meshes. */
|
||||
Mesh **meshes;
|
||||
size_t meshCount;
|
||||
@@ -43,10 +31,6 @@ typedef struct {
|
||||
ModelAnimations **animations;
|
||||
size_t animationCount;
|
||||
size_t animationAlloc;
|
||||
/* Lights. */
|
||||
Light **lights;
|
||||
size_t lightCount;
|
||||
size_t lightAlloc;
|
||||
/* Raylib GLFW input callback events. */
|
||||
/* Window events. */
|
||||
GLFWwindowsizefun raylibWindowSizeCallback;
|
||||
|
||||
810
src/audio.c
810
src/audio.c
File diff suppressed because it is too large
Load Diff
2
src/gl.c
2
src/gl.c
@@ -15,7 +15,7 @@ Copy a block of pixels from one framebuffer object to another.
|
||||
Use -1 RenderTexture for window framebuffer.
|
||||
*/
|
||||
int lglBlitFramebuffer( lua_State *L ) {
|
||||
// TOCO Currently doesn't support setting window render target because of luaL_checkudata.
|
||||
// TODO Currently doesn't support setting window render target because of luaL_checkudata.
|
||||
RenderTexture *srcTex = luaL_checkudata( L, 1, "RenderTexture" );
|
||||
RenderTexture *dstTex = luaL_checkudata( L, 2, "RenderTexture" );
|
||||
Rectangle srcRect = uluaGetRectangleIndex( L, 3 );
|
||||
|
||||
233
src/lights.c
233
src/lights.c
@@ -7,45 +7,6 @@
|
||||
#define RLIGHTS_IMPLEMENTATION
|
||||
#include "rlights.h"
|
||||
|
||||
static void checkLightRealloc( int i ) {
|
||||
if ( i == state->lightCount ) {
|
||||
state->lightCount++;
|
||||
}
|
||||
|
||||
if ( state->lightCount == state->lightAlloc ) {
|
||||
state->lightAlloc += ALLOC_PAGE_SIZE;
|
||||
state->lights = realloc( state->lights, state->lightAlloc * sizeof( Light* ) );
|
||||
|
||||
for ( i = state->lightCount; i < state->lightAlloc; i++ ) {
|
||||
state->lights[i] = NULL;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool validLight( size_t id ) {
|
||||
if ( id < 0 || state->lightCount < id || state->lights[ id ] == NULL ) {
|
||||
TraceLog( state->logLevelInvalid, "%s %d", "Invalid light", id );
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
static int newLight() {
|
||||
int i = 0;
|
||||
|
||||
for ( i = 0; i < state->lightCount; i++ ) {
|
||||
if ( state->lights[i] == NULL ) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
state->lights[i] = malloc( sizeof( Light ) );
|
||||
checkLightRealloc( i );
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
/*
|
||||
## Lights - Basics
|
||||
*/
|
||||
@@ -55,8 +16,7 @@ static int newLight() {
|
||||
|
||||
Create a light and get shader locations
|
||||
|
||||
- Failure return -1
|
||||
- Success return int
|
||||
- Success return Light
|
||||
*/
|
||||
int llightsCreateLight( lua_State *L ) {
|
||||
int type = luaL_checkinteger( L, 1 );
|
||||
@@ -65,9 +25,7 @@ int llightsCreateLight( lua_State *L ) {
|
||||
Color color = uluaGetColorIndex( L, 4 );
|
||||
Shader *shader = luaL_checkudata( L, 5, "Shader" );
|
||||
|
||||
int i = newLight();
|
||||
*state->lights[i] = CreateLight( type, position, target, color, *shader );
|
||||
lua_pushinteger( L, i );
|
||||
uluaPushLight( L, CreateLight( type, position, target, color, *shader ) );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -79,150 +37,81 @@ Send light properties to shader
|
||||
*/
|
||||
int llightsUpdateLightValues( lua_State *L ) {
|
||||
Shader *shader = luaL_checkudata( L, 1, "Shader" );
|
||||
size_t lightId = lua_tointeger( L, 2 );
|
||||
Light *light = luaL_checkudata( L, 2, "Light" );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
UpdateLightValues( *shader, *state->lights[ lightId ] );
|
||||
UpdateLightValues( *shader, *light );
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.SetLightType( Light light, int type )
|
||||
> RL.SetLightType( Light light, int type )
|
||||
|
||||
Set light type
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int llightsSetLightType( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isnumber( L, 2 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.SetLightType( Light light, int type )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
int type = lua_tointeger( L, 2 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
int type = luaL_checkinteger( L, 2 );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
state->lights[ lightId ]->type = type;
|
||||
lua_pushboolean( L, true );
|
||||
light->type = type;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.SetLightPosition( Light light, Vector3 position )
|
||||
> RL.SetLightPosition( Light light, Vector3 position )
|
||||
|
||||
Set light position
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int llightsSetLightPosition( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.SetLightPosition( Light light, Vecto3 position )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
Vector3 position = uluaGetVector3Index( L, 2 );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
state->lights[ lightId ]->position = position;
|
||||
lua_pushboolean( L, true );
|
||||
light->position = position;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.SetLightTarget( Light light, Vector3 target )
|
||||
> RL.SetLightTarget( Light light, Vector3 target )
|
||||
|
||||
Set light target
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int llightsSetLightTarget( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.SetLightTarget( Light light, Vecto3 target )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
Vector3 target = uluaGetVector3Index( L, 2 );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
state->lights[ lightId ]->target = target;
|
||||
lua_pushboolean( L, true );
|
||||
light->target = target;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.SetLightColor( Light light, Color color )
|
||||
> RL.SetLightColor( Light light, Color color )
|
||||
|
||||
Set light color
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int llightsSetLightColor( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_istable( L, 2 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.SetLightColor( Light light, Color color )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
Color color = uluaGetColorIndex( L, 2 );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
state->lights[ lightId ]->color = color;
|
||||
lua_pushboolean( L, true );
|
||||
light->color = color;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
> success = RL.SetLightEnabled( Light light, bool enabled )
|
||||
> RL.SetLightEnabled( Light light, bool enabled )
|
||||
|
||||
Set light enabled
|
||||
|
||||
- Failure return false
|
||||
- Success return true
|
||||
*/
|
||||
int llightsSetLightEnabled( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) || !lua_isboolean( L, 2 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.SetLightEnabled( Light light, bool enabled )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
bool enabled = lua_toboolean( L, 2 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
bool enabled = uluaGetBoolean( L, 2 );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
state->lights[ lightId ]->enabled = enabled;
|
||||
lua_pushboolean( L, true );
|
||||
light->enabled = enabled;
|
||||
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -230,22 +119,12 @@ int llightsSetLightEnabled( lua_State *L ) {
|
||||
|
||||
Get light type
|
||||
|
||||
- Failure return false
|
||||
- Success return int
|
||||
*/
|
||||
int llightsGetLightType( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetLightType( Light light )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
lua_pushinteger( L, state->lights[ lightId ]->type );
|
||||
lua_pushinteger( L, light->type );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -255,22 +134,12 @@ int llightsGetLightType( lua_State *L ) {
|
||||
|
||||
Get light position
|
||||
|
||||
- Failure return false
|
||||
- Success return Vector3
|
||||
*/
|
||||
int llightsGetLightPosition( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetLightPosition( Light light )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
uluaPushVector3( L, state->lights[ lightId ]->position );
|
||||
uluaPushVector3( L, light->position );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -280,22 +149,12 @@ int llightsGetLightPosition( lua_State *L ) {
|
||||
|
||||
Get light target
|
||||
|
||||
- Failure return false
|
||||
- Success return Vector3
|
||||
*/
|
||||
int llightsGetLightTarget( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetLightTarget( Light light )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
uluaPushVector3( L, state->lights[ lightId ]->target );
|
||||
uluaPushVector3( L, light->target );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -305,22 +164,12 @@ int llightsGetLightTarget( lua_State *L ) {
|
||||
|
||||
Get light color
|
||||
|
||||
- Failure return false
|
||||
- Success return Color
|
||||
*/
|
||||
int llightsGetLightColor( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.GetLightColor( Light light )" );
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushboolean( L, false );
|
||||
return 1;
|
||||
}
|
||||
uluaPushColor( L, state->lights[ lightId ]->color );
|
||||
uluaPushColor( L, light->color );
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -330,22 +179,12 @@ int llightsGetLightColor( lua_State *L ) {
|
||||
|
||||
Get light enabled
|
||||
|
||||
- Failure return nil
|
||||
- Success return boolean
|
||||
*/
|
||||
int llightsIsLightEnabled( lua_State *L ) {
|
||||
if ( !lua_isnumber( L, 1 ) ) {
|
||||
TraceLog( state->logLevelInvalid, "%s", "Bad call of function. RL.IsLightEnabled( Light light )" );
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
size_t lightId = lua_tointeger( L, 1 );
|
||||
Light *light = luaL_checkudata( L, 1, "Light" );
|
||||
|
||||
if ( !validLight( lightId ) ) {
|
||||
lua_pushnil( L );
|
||||
return 1;
|
||||
}
|
||||
lua_pushboolean( L, state->lights[ lightId ]->enabled );
|
||||
lua_pushboolean( L, light->enabled );
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -140,6 +140,69 @@ static void defineFont() {
|
||||
lua_setfield( L, -2, "__gc" );
|
||||
}
|
||||
|
||||
/* Wave. */
|
||||
static int gcWave( lua_State *L ) {
|
||||
Wave *wave = luaL_checkudata ( L, 1, "Wave" );
|
||||
printf( "gcWave\n" );
|
||||
|
||||
UnloadWave( *wave );
|
||||
}
|
||||
|
||||
static void defineWave() {
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
luaL_newmetatable( L, "Wave" );
|
||||
lua_pushvalue( L, -1 );
|
||||
lua_setfield( L, -2, "__index" );
|
||||
lua_pushcfunction( L, gcWave );
|
||||
lua_setfield( L, -2, "__gc" );
|
||||
}
|
||||
|
||||
/* Sound. */
|
||||
static int gcSound( lua_State *L ) {
|
||||
Sound *sound = luaL_checkudata ( L, 1, "Sound" );
|
||||
printf( "gcSound\n" );
|
||||
|
||||
UnloadSound( *sound );
|
||||
}
|
||||
|
||||
static void defineSound() {
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
luaL_newmetatable( L, "Sound" );
|
||||
lua_pushvalue( L, -1 );
|
||||
lua_setfield( L, -2, "__index" );
|
||||
lua_pushcfunction( L, gcSound );
|
||||
lua_setfield( L, -2, "__gc" );
|
||||
}
|
||||
|
||||
/* Music. */
|
||||
static int gcMusic( lua_State *L ) {
|
||||
Music *music = luaL_checkudata ( L, 1, "Music" );
|
||||
printf( "gcMusic\n" );
|
||||
|
||||
UnloadMusicStream( *music );
|
||||
}
|
||||
|
||||
static void defineMusic() {
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
luaL_newmetatable( L, "Music" );
|
||||
lua_pushvalue( L, -1 );
|
||||
lua_setfield( L, -2, "__index" );
|
||||
lua_pushcfunction( L, gcMusic );
|
||||
lua_setfield( L, -2, "__gc" );
|
||||
}
|
||||
|
||||
/* Music. */
|
||||
static void defineLight() {
|
||||
lua_State *L = state->luaState;
|
||||
|
||||
luaL_newmetatable( L, "Light" );
|
||||
lua_pushvalue( L, -1 );
|
||||
lua_setfield( L, -2, "__index" );
|
||||
}
|
||||
|
||||
/* Assing globals. */
|
||||
|
||||
static void assignGlobalInt( int value, const char *name ) {
|
||||
@@ -1162,6 +1225,10 @@ bool luaInit( int argn, const char **argc ) {
|
||||
defineCamera3D();
|
||||
defineShader();
|
||||
defineFont();
|
||||
defineWave();
|
||||
defineSound();
|
||||
defineMusic();
|
||||
defineLight();
|
||||
/* Define globals. */
|
||||
defineGlobals();
|
||||
|
||||
@@ -1777,8 +1844,6 @@ void luaRegister() {
|
||||
assingGlobalFunction( "LoadSound", laudioLoadSound );
|
||||
assingGlobalFunction( "LoadWave", laudioLoadWave );
|
||||
assingGlobalFunction( "LoadSoundFromWave", laudioLoadSoundFromWave );
|
||||
assingGlobalFunction( "UnloadSound", laudioUnloadSound );
|
||||
assingGlobalFunction( "UnloadWave", laudioUnloadWave );
|
||||
assingGlobalFunction( "ExportWave", laudioExportWave );
|
||||
assingGlobalFunction( "ExportWaveAsCode", laudioExportWaveAsCode );
|
||||
/* Wave/Sound management */
|
||||
@@ -2899,6 +2964,30 @@ void uluaPushFont( lua_State *L, Font font ) {
|
||||
luaL_setmetatable( L, "Font" );
|
||||
}
|
||||
|
||||
void uluaPushWave( lua_State *L, Wave wave ) {
|
||||
Wave *waveP = lua_newuserdata( L, sizeof( Wave ) );
|
||||
*waveP = wave;
|
||||
luaL_setmetatable( L, "Wave" );
|
||||
}
|
||||
|
||||
void uluaPushSound( lua_State *L, Sound sound ) {
|
||||
Sound *soundP = lua_newuserdata( L, sizeof( Sound ) );
|
||||
*soundP = sound;
|
||||
luaL_setmetatable( L, "Sound" );
|
||||
}
|
||||
|
||||
void uluaPushMusic( lua_State *L, Music music ) {
|
||||
Music *musicP = lua_newuserdata( L, sizeof( Music ) );
|
||||
*musicP = music;
|
||||
luaL_setmetatable( L, "Music" );
|
||||
}
|
||||
|
||||
void uluaPushLight( lua_State *L, Light light ) {
|
||||
Light *lightP = lua_newuserdata( L, sizeof( Light ) );
|
||||
*lightP = light;
|
||||
luaL_setmetatable( L, "Light" );
|
||||
}
|
||||
|
||||
int uluaGetTableLen( lua_State *L ) {
|
||||
return uluaGetTableLenIndex( L, lua_gettop( L ) );
|
||||
}
|
||||
|
||||
48
src/state.c
48
src/state.c
@@ -17,18 +17,6 @@ bool stateInit( int argn, const char **argc, const char *exePath ) {
|
||||
state->resolution = (Vector2){ 800, 600 };
|
||||
state->luaState = NULL;
|
||||
state->logLevelInvalid = LOG_ERROR;
|
||||
/* Waves. */
|
||||
state->waveAlloc = ALLOC_PAGE_SIZE;
|
||||
state->waveCount = 0;
|
||||
state->waves = malloc( state->waveAlloc * sizeof( Wave* ) );
|
||||
/* Sounds. */
|
||||
state->soundAlloc = ALLOC_PAGE_SIZE;
|
||||
state->soundCount = 0;
|
||||
state->sounds = malloc( state->soundAlloc * sizeof( Sound* ) );
|
||||
/* Musics. */
|
||||
state->musicAlloc = ALLOC_PAGE_SIZE;
|
||||
state->musicCount = 0;
|
||||
state->musics = malloc( state->musicAlloc * sizeof( Music* ) );
|
||||
/* Meshes. */
|
||||
state->meshAlloc = ALLOC_PAGE_SIZE;
|
||||
state->meshCount = 0;
|
||||
@@ -45,18 +33,11 @@ bool stateInit( int argn, const char **argc, const char *exePath ) {
|
||||
state->animationAlloc = ALLOC_PAGE_SIZE;
|
||||
state->animationCount = 0;
|
||||
state->animations = malloc( state->animationAlloc * sizeof( ModelAnimations* ) );
|
||||
/* Lights. */
|
||||
state->lightAlloc = ALLOC_PAGE_SIZE;
|
||||
state->lightCount = 0;
|
||||
state->lights = malloc( state->lightAlloc * sizeof( Light* ) );
|
||||
|
||||
for ( int i = 0; i < ALLOC_PAGE_SIZE; i++ ) {
|
||||
state->waves[i] = NULL;
|
||||
state->sounds[i] = NULL;
|
||||
state->meshes[i] = NULL;
|
||||
state->models[i] = NULL;
|
||||
state->animations[i] = NULL;
|
||||
state->lights[i] = NULL;
|
||||
|
||||
/* The ones we want to save the first. */
|
||||
if ( 0 < i ) {
|
||||
@@ -86,24 +67,6 @@ void stateInitInterpret( int argn, const char **argc ) {
|
||||
}
|
||||
|
||||
void stateFree() {
|
||||
for ( int i = 0; i < state->waveCount; ++i ) {
|
||||
if ( state->waves[i] != NULL ) {
|
||||
UnloadWave( *state->waves[i] );
|
||||
free( state->waves[i] );
|
||||
}
|
||||
}
|
||||
for ( int i = 0; i < state->soundCount; ++i ) {
|
||||
if ( state->sounds[i] != NULL ) {
|
||||
UnloadSound( *state->sounds[i] );
|
||||
free( state->sounds[i] );
|
||||
}
|
||||
}
|
||||
for ( int i = 0; i < state->musicCount; ++i ) {
|
||||
if ( state->musics[i] != NULL ) {
|
||||
UnloadMusicStream( *state->musics[i] );
|
||||
free( state->musics[i] );
|
||||
}
|
||||
}
|
||||
for ( int i = 0; i < state->modelCount; ++i ) {
|
||||
if ( state->models[i] != NULL ) {
|
||||
//TODO Test if UnloadModel causes segfaults on exit.
|
||||
@@ -134,13 +97,6 @@ void stateFree() {
|
||||
}
|
||||
}
|
||||
|
||||
#if !defined( PLATFORM_RPI ) || !defined( PLATFORM_DRM )
|
||||
for ( int i = 0; i < state->lightCount; ++i ) {
|
||||
if ( state->lights[i] != NULL ) {
|
||||
free( state->lights[i] );
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if ( IsAudioDeviceReady() ) {
|
||||
CloseAudioDevice();
|
||||
}
|
||||
@@ -151,14 +107,10 @@ void stateFree() {
|
||||
if ( state->hasWindow ) {
|
||||
CloseWindow();
|
||||
}
|
||||
free( state->waves );
|
||||
free( state->sounds );
|
||||
free( state->musics );
|
||||
free( state->meshes );
|
||||
free( state->materials );
|
||||
free( state->models );
|
||||
free( state->animations );
|
||||
free( state->lights );
|
||||
free( state->exePath );
|
||||
free( state );
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ int ltextLoadFont( lua_State *L ) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
TraceLog( state->logLevelInvalid, "Invalid file path '%s'", lua_tostring( L, 1 ) );
|
||||
TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
|
||||
lua_pushnil( L );
|
||||
|
||||
return 1;
|
||||
@@ -73,7 +73,7 @@ int ltextLoadFontEx( lua_State *L ) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
TraceLog( state->logLevelInvalid, "Invalid file path '%s'", lua_tostring( L, 1 ) );
|
||||
TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
|
||||
lua_pushnil( L );
|
||||
|
||||
return 1;
|
||||
|
||||
@@ -21,7 +21,7 @@ int ltexturesLoadImage( lua_State *L ) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
TraceLog( state->logLevelInvalid, "Invalid file path '%s'", lua_tostring( L, 1 ) );
|
||||
TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
|
||||
lua_pushnil( L );
|
||||
|
||||
return 1;
|
||||
@@ -929,7 +929,7 @@ int ltexturesLoadTexture( lua_State *L ) {
|
||||
|
||||
return 1;
|
||||
}
|
||||
TraceLog( state->logLevelInvalid, "Invalid file path '%s'", lua_tostring( L, 1 ) );
|
||||
TraceLog( state->logLevelInvalid, "Invalid file '%s'", lua_tostring( L, 1 ) );
|
||||
lua_pushnil( L );
|
||||
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user