mirror of
https://github.com/raysan5/raylib.git
synced 2026-08-24 21:28:27 -04:00
Compare commits
2 Commits
7ee0b08647
...
1893226cb7
| Author | SHA1 | Date | |
|---|---|---|---|
| 1893226cb7 | |||
| 3580240743 |
@ -4,7 +4,7 @@
|
|||||||
*
|
*
|
||||||
* Example complexity rating: [★★☆☆] 2/4
|
* Example complexity rating: [★★☆☆] 2/4
|
||||||
*
|
*
|
||||||
* Example originally created with raylib 5.5, last time updated with raylib 5.5
|
* Example originally created with raylib 5.5, last time updated with raylib 6.0
|
||||||
*
|
*
|
||||||
* Example contributed by Le Juez Victor (@Bigfoot71) and reviewed by Ramon Santamaria (@raysan5)
|
* Example contributed by Le Juez Victor (@Bigfoot71) and reviewed by Ramon Santamaria (@raysan5)
|
||||||
*
|
*
|
||||||
@ -116,14 +116,14 @@ static void SetSoundPosition(Camera listener, Sound sound, Vector3 position, flo
|
|||||||
// Calculate normalized vectors for spatial positioning
|
// Calculate normalized vectors for spatial positioning
|
||||||
Vector3 normalizedDirection = Vector3Normalize(direction);
|
Vector3 normalizedDirection = Vector3Normalize(direction);
|
||||||
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
Vector3 forward = Vector3Normalize(Vector3Subtract(listener.target, listener.position));
|
||||||
Vector3 right = Vector3Normalize(Vector3CrossProduct(listener.up, forward));
|
Vector3 right = Vector3Normalize(Vector3CrossProduct(forward, listener.up));
|
||||||
|
|
||||||
// Reduce volume for sounds behind the listener
|
// Reduce volume for sounds behind the listener
|
||||||
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
float dotProduct = Vector3DotProduct(forward, normalizedDirection);
|
||||||
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
|
if (dotProduct < 0.0f) attenuation *= (1.0f + dotProduct*0.5f);
|
||||||
|
|
||||||
// Set stereo panning based on sound position relative to listener
|
// Set stereo panning based on sound position relative to listener
|
||||||
float pan = 0.5f + 0.5f*Vector3DotProduct(normalizedDirection, right);
|
float pan = Vector3DotProduct(normalizedDirection, right);
|
||||||
|
|
||||||
// Apply final sound properties
|
// Apply final sound properties
|
||||||
SetSoundVolume(sound, attenuation);
|
SetSoundVolume(sound, attenuation);
|
||||||
|
|||||||
@ -97,9 +97,6 @@ int main(void)
|
|||||||
|
|
||||||
// De-Initialization
|
// De-Initialization
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
// TODO: Unload all loaded resources at this point
|
|
||||||
|
|
||||||
CloseWindow(); // Close window and OpenGL context
|
CloseWindow(); // Close window and OpenGL context
|
||||||
//--------------------------------------------------------------------------------------
|
//--------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|||||||
@ -249,7 +249,7 @@ int main(void)
|
|||||||
DrawText("(c) Character model and texture from kenney.nl", screenWidth - 260, screenHeight - 20, 10, GRAY);
|
DrawText("(c) Character model and texture from kenney.nl", screenWidth - 260, screenHeight - 20, 10, GRAY);
|
||||||
|
|
||||||
// UI elements
|
// UI elements
|
||||||
if (GuiButton((Rectangle){ 10, screenHeight - 1000.f, 100, 60 }, showModel ? "Hide Model" : "Show Model")) showModel = !showModel;
|
if (GuiButton((Rectangle){ 10, screenHeight - 100.0f, 100, 60 }, showModel ? "Hide Model" : "Show Model")) showModel = !showModel;
|
||||||
|
|
||||||
if (GuiButton((Rectangle){ 10 + 110, screenHeight - 100.0f, 100, 60 }, "Clear Decals"))
|
if (GuiButton((Rectangle){ 10 + 110, screenHeight - 100.0f, 100, 60 }, "Clear Decals"))
|
||||||
{
|
{
|
||||||
|
|||||||
@ -66,8 +66,8 @@ int main(void)
|
|||||||
|
|
||||||
// Play animation when spacebar is held down
|
// Play animation when spacebar is held down
|
||||||
animCurrentFrame += 1.0f;
|
animCurrentFrame += 1.0f;
|
||||||
UpdateModelAnimation(model, anims[0], animCurrentFrame);
|
UpdateModelAnimation(model, anims[animIndex], animCurrentFrame);
|
||||||
if (animCurrentFrame >= anims[0].keyframeCount) animCurrentFrame = 0;
|
if (animCurrentFrame >= anims[animIndex].keyframeCount) animCurrentFrame = 0;
|
||||||
//----------------------------------------------------------------------------------
|
//----------------------------------------------------------------------------------
|
||||||
|
|
||||||
// Draw
|
// Draw
|
||||||
|
|||||||
@ -533,8 +533,9 @@ void CloseAudioDevice(void)
|
|||||||
{
|
{
|
||||||
if (AUDIO.System.isReady)
|
if (AUDIO.System.isReady)
|
||||||
{
|
{
|
||||||
ma_mutex_uninit(&AUDIO.System.lock);
|
// Stop the device first (joins the callback thread) before destroying the mutex it locks
|
||||||
ma_device_uninit(&AUDIO.System.device);
|
ma_device_uninit(&AUDIO.System.device);
|
||||||
|
ma_mutex_uninit(&AUDIO.System.lock);
|
||||||
ma_context_uninit(&AUDIO.System.context);
|
ma_context_uninit(&AUDIO.System.context);
|
||||||
|
|
||||||
AUDIO.System.isReady = false;
|
AUDIO.System.isReady = false;
|
||||||
|
|||||||
Reference in New Issue
Block a user