11 Commits

13 changed files with 121 additions and 53 deletions
Split View
  1. +5
    -0
      .gitignore
  2. +1
    -1
      examples/Makefile
  3. +44
    -0
      examples/audio/audio_music_stream.c
  4. +3
    -0
      examples/audio/audio_sound_positioning.c
  5. +20
    -30
      examples/textures/textures_sprite_stacking.c
  6. +6
    -6
      src/raudio.c
  7. +2
    -2
      src/raylib.h
  8. +22
    -0
      tools/rexm/reports/examples_testing_linux.md
  9. +10
    -6
      tools/rexm/rexm.c
  10. +2
    -2
      tools/rlparser/output/raylib_api.json
  11. +2
    -2
      tools/rlparser/output/raylib_api.lua
  12. +2
    -2
      tools/rlparser/output/raylib_api.txt
  13. +2
    -2
      tools/rlparser/output/raylib_api.xml

+ 5
- 0
.gitignore View File

@ -62,10 +62,15 @@ packages/
emsdk
# Ignore wasm data in examples/
examples/**/*
!examples/**/*.*
!examples/**/*/
examples/**/*.exe
examples/**/*.wasm
examples/**/*.data
examples/**/*.js
examples/**/*.html
examples/**/logs/*
# Ignore files build by xcode
*.mode*v*

+ 1
- 1
examples/Makefile View File

@ -231,7 +231,7 @@ endif
# -Wno-missing-braces ignore invalid warning (GCC bug 53119)
# -Wno-unused-value ignore unused return values of some functions (i.e. fread())
# -D_DEFAULT_SOURCE use with -std=c99 on Linux and PLATFORM_WEB, required for timespec
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wunused-result
CFLAGS = -Wall -std=c99 -D_DEFAULT_SOURCE -Wno-missing-braces -Wno-unused-result
ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -D_DEBUG

+ 44
- 0
examples/audio/audio_music_stream.c View File

@ -35,6 +35,12 @@ int main(void)
float timePlayed = 0.0f; // Time played normalized [0.0f..1.0f]
bool pause = false; // Music playing paused
float pan = 0.0f; // Default audio pan center [-1.0f..1.0f]
SetMusicPan(music, pan);
float volume = 0.8f; // Default audio volume [0.0f..1.0f]
SetMusicVolume(music, volume);
SetTargetFPS(30); // Set our game to run at 30 frames-per-second
//--------------------------------------------------------------------------------------
@ -61,6 +67,34 @@ int main(void)
if (pause) PauseMusicStream(music);
else ResumeMusicStream(music);
}
// Set audio pan
if (IsKeyDown(KEY_LEFT))
{
pan -= 0.05f;
if (pan < -1.0f) pan = -1.0f;
SetMusicPan(music, pan);
}
else if (IsKeyDown(KEY_RIGHT))
{
pan += 0.05f;
if (pan > 1.0f) pan = 1.0f;
SetMusicPan(music, pan);
}
// Set audio volume
if (IsKeyDown(KEY_DOWN))
{
volume -= 0.05f;
if (volume < 0.0f) volume = 0.0f;
SetMusicVolume(music, volume);
}
else if (IsKeyDown(KEY_UP))
{
volume += 0.05f;
if (volume > 1.0f) volume = 1.0f;
SetMusicVolume(music, volume);
}
// Get normalized time played for current music stream
timePlayed = GetMusicTimePlayed(music)/GetMusicTimeLength(music);
@ -75,6 +109,11 @@ int main(void)
ClearBackground(RAYWHITE);
DrawText("MUSIC SHOULD BE PLAYING!", 255, 150, 20, LIGHTGRAY);
DrawText("LEFT-RIGHT for PAN CONTROL", 320, 74, 10, DARKBLUE);
DrawRectangle(300, 100, 200, 12, LIGHTGRAY);
DrawRectangleLines(300, 100, 200, 12, GRAY);
DrawRectangle(300 + (pan + 1.0)/2.0f*200 - 5, 92, 10, 28, DARKGRAY);
DrawRectangle(200, 200, 400, 12, LIGHTGRAY);
DrawRectangle(200, 200, (int)(timePlayed*400.0f), 12, MAROON);
@ -82,6 +121,11 @@ int main(void)
DrawText("PRESS SPACE TO RESTART MUSIC", 215, 250, 20, LIGHTGRAY);
DrawText("PRESS P TO PAUSE/RESUME MUSIC", 208, 280, 20, LIGHTGRAY);
DrawText("UP-DOWN for VOLUME CONTROL", 320, 334, 10, DARKGREEN);
DrawRectangle(300, 360, 200, 12, LIGHTGRAY);
DrawRectangleLines(300, 360, 200, 12, GRAY);
DrawRectangle(300 + volume*200 - 5, 352, 10, 28, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------

+ 3
- 0
examples/audio/audio_sound_positioning.c View File

@ -69,6 +69,7 @@ int main(void)
};
SetSoundPosition(camera, sound, spherePos, 20.0f);
if (!IsSoundPlaying(sound)) PlaySound(sound);
//----------------------------------------------------------------------------------
@ -94,6 +95,8 @@ int main(void)
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//------------------------------------------------------------------------------------

+ 20
- 30
examples/textures/textures_sprite_stacking.c View File

@ -17,7 +17,8 @@
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#include "raymath.h" // Required for: Clamp()
//------------------------------------------------------------------------------------
// Program main entry point
@ -33,18 +34,14 @@ int main(void)
Texture2D booth = LoadTexture("resources/booth.png");
// The overall scale of the stacked sprite
float stackScale = 3.0f;
// The vertical spacing between each layer
float stackSpacing = 2.0f;
// The number of layers. Used for calculating the size of a single slice
unsigned int stackCount = 122;
// The speed to rotate the stacked sprite
float rotationSpeed = 30.0f;
// The current rotation of the stacked sprite
float rotation = 0.0f;
// The amount that speed will change by when the user presses A/D
const float speedChange = 0.25f;
float stackScale = 3.0f; // Overall scale of the stacked sprite
float stackSpacing = 2.0f; // Vertical spacing between each layer
unsigned int stackCount = 122; // Number of layers, used for calculating the size of a single slice
float rotationSpeed = 30.0f; // Stacked sprites rotation speed
float rotation = 0.0f; // Current rotation of the stacked sprite
const float speedChange = 0.25f; // Amount speed will change by when the user presses A/D
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
// Main game loop
@ -57,22 +54,16 @@ int main(void)
stackSpacing = Clamp(stackSpacing, 0.0f, 5.0f);
// Add a positive/negative offset to spin right/left at different speeds
if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_A))
{
rotationSpeed -= speedChange;
}
if (IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_D))
{
rotationSpeed += speedChange;
}
rotation += rotationSpeed * GetFrameTime();
if (IsKeyDown(KEY_LEFT) || IsKeyDown(KEY_A)) rotationSpeed -= speedChange;
if (IsKeyDown(KEY_RIGHT) || IsKeyDown(KEY_D)) rotationSpeed += speedChange;
rotation += rotationSpeed*GetFrameTime();
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
// Get the size of a single slice
@ -86,20 +77,19 @@ int main(void)
// Draw the stacked sprite, rotated to the correct angle, with an vertical offset applied based on its y location
for (int i = stackCount - 1; i >= 0; i--)
{
Rectangle source = { 0.0f, (float)i*frameHeight, frameWidth, frameHeight };
// Center vertically
Rectangle source = { 0.0f, (float)i*frameHeight, frameWidth, frameHeight };
Rectangle dest = { screenWidth/2.0f, (screenHeight/2.0f) + (i*stackSpacing) - (stackSpacing*stackCount/2.0f), scaledWidth, scaledHeight };
Vector2 origin = { scaledWidth/2.0f, scaledHeight/2.0f };
DrawTexturePro(booth, source, dest, origin, rotation, WHITE);
}
DrawText("a/d to spin\nmouse wheel to change separation (aka 'angle')", 10, 10, 20, DARKGRAY);
const char *spacingText = TextFormat("current spacing: %.01f", stackSpacing);
DrawText(spacingText, 10, 50, 20, DARKGRAY);
const char *speedText = TextFormat("current speed: %.02f", rotationSpeed);
DrawText(speedText, 10, 70, 20, DARKGRAY);
DrawText("A/D to spin\nmouse wheel to change separation (aka 'angle')", 10, 10, 20, DARKGRAY);
DrawText(TextFormat("current spacing: %.01f", stackSpacing), 10, 50, 20, DARKGRAY);
DrawText(TextFormat("current speed: %.02f", rotationSpeed), 10, 70, 20, DARKGRAY);
DrawText("redbooth model (c) kluchek under cc 4.0", 10, 420, 20, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}

+ 6
- 6
src/raudio.c View File

@ -593,7 +593,7 @@ AudioBuffer *LoadAudioBuffer(ma_format format, ma_uint32 channels, ma_uint32 sam
// Init audio buffer values
audioBuffer->volume = 1.0f;
audioBuffer->pitch = 1.0f;
audioBuffer->pan = 0.5f;
audioBuffer->pan = 0.0f; // Center
audioBuffer->callback = NULL;
audioBuffer->processor = NULL;
@ -720,7 +720,7 @@ void SetAudioBufferPitch(AudioBuffer *buffer, float pitch)
// Set pan for an audio buffer
void SetAudioBufferPan(AudioBuffer *buffer, float pan)
{
if (pan < mf">0.0f) pan = mf">0.0f;
if (pan < o">-1.0f) pan = o">-1.0f;
else if (pan > 1.0f) pan = 1.0f;
if (buffer != NULL)
@ -985,10 +985,10 @@ Sound LoadSoundAlias(Sound source)
audioBuffer->sizeInFrames = source.stream.buffer->sizeInFrames;
audioBuffer->data = source.stream.buffer->data;
// initalize the buffer as if it was new
// Initalize the buffer as if it was new
audioBuffer->volume = 1.0f;
audioBuffer->pitch = 1.0f;
audioBuffer->pan = 0.5f;
audioBuffer->pan = 0.0f; // Center
sound.frameCount = source.frameCount;
sound.stream.sampleRate = AUDIO.System.device.sampleRate;
@ -2605,8 +2605,8 @@ static void MixAudioFrames(float *framesOut, const float *framesIn, ma_uint32 fr
if (channels == 2) // We consider panning
{
const float left = buffer->pan;
const float right = 1.0f - left;
const float right = (buffer->pan + 1.0f)/2.0f; // Normalize: [-1..1] -> [0..1]
const float left = 1.0f - right;
// Fast sine approximation in [0..1] for pan law: y = 0.5f*x*(3 - x*x);
const float levels[2] = { localVolume*0.5f*left*(3.0f - left*left), localVolume*0.5f*right*(3.0f - right*right) };

+ 2
- 2
src/raylib.h View File

@ -1672,7 +1672,7 @@ RLAPI void ResumeSound(Sound sound); // Resume
RLAPI bool IsSoundPlaying(Sound sound); // Check if a sound is currently playing
RLAPI void SetSoundVolume(Sound sound, float volume); // Set volume for a sound (1.0 is max level)
RLAPI void SetSoundPitch(Sound sound, float pitch); // Set pitch for a sound (1.0 is base level)
RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (mf">0.5 is center)
RLAPI void SetSoundPan(Sound sound, float pan); // Set pan for a sound (o">-1.0 left, 0.0 center, 1.0 right)
RLAPI Wave WaveCopy(Wave wave); // Copy a wave to a new wave
RLAPI void WaveCrop(Wave *wave, int initFrame, int finalFrame); // Crop a wave to defined frames range
RLAPI void WaveFormat(Wave *wave, int sampleRate, int sampleSize, int channels); // Convert wave data to desired format
@ -1693,7 +1693,7 @@ RLAPI void ResumeMusicStream(Music music); // Resume
RLAPI void SeekMusicStream(Music music, float position); // Seek music to a position (in seconds)
RLAPI void SetMusicVolume(Music music, float volume); // Set volume for music (1.0 is max level)
RLAPI void SetMusicPitch(Music music, float pitch); // Set pitch for a music (1.0 is base level)
RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (mf">0.5 is center)
RLAPI void SetMusicPan(Music music, float pan); // Set pan for a music (o">-1.0 left, 0.0 center, 1.0 right)
RLAPI float GetMusicTimeLength(Music music); // Get music time length (in seconds)
RLAPI float GetMusicTimePlayed(Music music); // Get current music time played (in seconds)

+ 22
- 0
tools/rexm/reports/examples_testing_linux.md View File

@ -0,0 +1,22 @@
# EXAMPLES COLLECTION - TESTING REPORT
## Tested Platform: Linux
```
Example automated testing elements validated:
- [CWARN] : Compilation WARNING messages
- [LWARN] : Log WARNING messages count
- [INIT] : Initialization
- [CLOSE] : Closing
- [ASSETS] : Assets loading
- [RLGL] : OpenGL-wrapped initialization
- [PLAT] : Platform initialization
- [FONT] : Font default initialization
- [TIMER] : Timer initialization
```
| **EXAMPLE NAME** | [CWARN] | [LWARN] | [INIT] | [CLOSE] | [ASSETS] | [RLGL] | [PLAT] | [FONT] | [TIMER] |
|:---------------------------------|:-------:|:-------:|:------:|:-------:|:--------:|:------:|:------:|:------:|:-------:|
| text_font_loading | 0 | 10 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| text_codepoints_loading | 0 | 1 | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| models_animation_playing | 0 | 1 | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | ✔ |

+ 10
- 6
tools/rexm/rexm.c View File

@ -51,9 +51,9 @@
#include "raylib.h"
#include <stdlib.h> // Required for: NULL, calloc(), free()
#include <stdio.h> // Required for: rename(), remove()
#include <string.h> // Required for: strcmp(), strcpy()
#include <stdlib.h> // Required for: NULL, calloc(), free()
#define SUPPORT_LOG_INFO
#if defined(SUPPORT_LOG_INFO) //&& defined(_DEBUG)
@ -1517,7 +1517,7 @@ int main(int argc, char *argv[])
TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName));
char *srcText = LoadFileText(TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
cp">#define BUILD_TESTING_WEB
o">//#define BUILD_TESTING_WEB
#if defined(BUILD_TESTING_WEB)
static const char *mainReplaceText =
"#include <stdio.h>\n"
@ -1620,8 +1620,9 @@ int main(int argc, char *argv[])
exBasePath, exCategory, exName, exBasePath, exCategory, exName));
#else
LOG("INFO: [%s] Building example for PLATFORM_DESKTOP (Host: POSIX)\n", exName);
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B", exBasePath, exCategory, exName));
#endif
system(TextFormat("make -C %s %s/%s PLATFORM=PLATFORM_DESKTOP -B > %s/%s/logs/%s.build.log 2>&1",
exBasePath, exCategory, exName, exBasePath, exCategory, exName));
#endif
// Restore original source code before continue
FileCopy(TextFormat("%s/%s/%s.original.c", exBasePath, exCategory, exName),
TextFormat("%s/%s/%s.c", exBasePath, exCategory, exName));
@ -1630,7 +1631,7 @@ int main(int argc, char *argv[])
// STEP 3: Run example with required arguments
// NOTE: Not easy to retrieve process return value from system(), it's platform dependant
ChangeDirectory(TextFormat("%s/%s", exBasePath, exCategory));
system(TextFormat("%s --frames 2 > logs/%s.log", exName, exName));
system(TextFormat("./%s --frames 2 > logs/%s.log", exName, exName));
#endif
}
} break;
@ -1712,7 +1713,9 @@ int main(int argc, char *argv[])
char **exTestLogLines = LoadTextLines(exTestLog, &exTestLogLinesCount);
for (int k = 0; k < exTestLogLinesCount; k++)
{
if (TextFindIndex(exTestLogLines[k], "WARNING: GL: NPOT") >= 0) continue; // Ignore warning
#if defined(BUILD_TESTING_WEB)
if (TextFindIndex(exTestLogLines[k], "WARNING: GL: NPOT") >= 0) continue; // Ignore web-specific warning
#endif
if (TextFindIndex(exTestLogLines[k], "WARNING") >= 0) testing[i].warnings++;
}
UnloadTextLines(exTestLogLines, exTestLogLinesCount);
@ -1842,6 +1845,7 @@ int main(int argc, char *argv[])
printf(" rename <old_examples_name> <new_example_name> : Rename an existing example\n");
printf(" remove <example_name> : Remove an existing example\n");
printf(" build <example_name> : Build example for Desktop and Web platforms\n");
printf(" test <example_name> : Build and Test example for Desktop and Web platforms\n");
printf(" validate : Validate examples collection, generates report\n");
printf(" update : Validate and update examples collection, generates report\n\n");
printf("OPTIONS:\n\n");

+ 2
- 2
tools/rlparser/output/raylib_api.json View File

@ -11897,7 +11897,7 @@
},
{
"name": "SetSoundPan",
"description": "Set pan for a sound (0.5 is center)",
"description": "Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)",
"returnType": "void",
"params": [
{
@ -12150,7 +12150,7 @@
},
{
"name": "SetMusicPan",
"description": "Set pan for a music (0.5 is center)",
"description": "Set pan for a music (-1.0 left, 0.0 center, 1.0 right)",
"returnType": "void",
"params": [
{

+ 2
- 2
tools/rlparser/output/raylib_api.lua View File

@ -8105,7 +8105,7 @@ return {
},
{
name = "SetSoundPan",
description = "Set pan for a sound (0.5 is center)",
description = "Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)",
returnType = "void",
params = {
{type = "Sound", name = "sound"},
@ -8268,7 +8268,7 @@ return {
},
{
name = "SetMusicPan",
description = "Set pan for a music (0.5 is center)",
description = "Set pan for a music (-1.0 left, 0.0 center, 1.0 right)",
returnType = "void",
params = {
{type = "Music", name = "music"},

+ 2
- 2
tools/rlparser/output/raylib_api.txt View File

@ -4554,7 +4554,7 @@ Function 556: SetSoundPitch() (2 input parameters)
Function 557: SetSoundPan() (2 input parameters)
Name: SetSoundPan
Return type: void
Description: Set pan for a sound (0.5 is center)
Description: Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)
Param[1]: sound (type: Sound)
Param[2]: pan (type: float)
Function 558: WaveCopy() (1 input parameters)
@ -4660,7 +4660,7 @@ Function 575: SetMusicPitch() (2 input parameters)
Function 576: SetMusicPan() (2 input parameters)
Name: SetMusicPan
Return type: void
Description: Set pan for a music (0.5 is center)
Description: Set pan for a music (-1.0 left, 0.0 center, 1.0 right)
Param[1]: music (type: Music)
Param[2]: pan (type: float)
Function 577: GetMusicTimeLength() (1 input parameters)

+ 2
- 2
tools/rlparser/output/raylib_api.xml View File

@ -3043,7 +3043,7 @@
<Param type="Sound" name="sound" desc="" />
<Param type="float" name="pitch" desc="" />
</Function>
<Function name="SetSoundPan" retType="void" paramCount="2" desc="Set pan for a sound (0.5 is center)">
<Function name="SetSoundPan" retType="void" paramCount="2" desc="Set pan for a sound (-1.0 left, 0.0 center, 1.0 right)">
<Param type="Sound" name="sound" desc="" />
<Param type="float" name="pan" desc="" />
</Function>
@ -3111,7 +3111,7 @@
<Param type="Music" name="music" desc="" />
<Param type="float" name="pitch" desc="" />
</Function>
<Function name="SetMusicPan" retType="void" paramCount="2" desc="Set pan for a music (0.5 is center)">
<Function name="SetMusicPan" retType="void" paramCount="2" desc="Set pan for a music (-1.0 left, 0.0 center, 1.0 right)">
<Param type="Music" name="music" desc="" />
<Param type="float" name="pan" desc="" />
</Function>

Loading…
Cancel
Save