diff --git a/.gitignore b/.gitignore index 559f9f0d9..6ff0e2346 100644 --- a/.gitignore +++ b/.gitignore @@ -54,6 +54,7 @@ packages/ *.bc *.so *.so.* +*.dll # Ignore wasm data in examples/ examples/**/*.wasm diff --git a/examples/audio/audio_stream_effects.c b/examples/audio/audio_stream_effects.c index 219305057..2262d41f9 100644 --- a/examples/audio/audio_stream_effects.c +++ b/examples/audio/audio_stream_effects.c @@ -2,7 +2,7 @@ * * raylib [audio] example - Music stream processing effects * -* Example originally created with raylib 4.2, last time updated with raylib 4.2 +* Example originally created with raylib 4.2, last time updated with raylib 5.0 * * Example licensed under an unmodified zlib/libpng license, which is an OSI-certified, * BSD-like license that allows static linking with closed source software @@ -13,7 +13,7 @@ #include "raylib.h" -#include // Required for: NULL +#include // Required for: NULL // Required delay effect variables static float *delayBuffer = NULL; @@ -149,13 +149,17 @@ static void AudioProcessEffectLPF(void *buffer, unsigned int frames) static const float cutoff = 70.0f / 44100.0f; // 70 Hz lowpass filter const float k = cutoff / (cutoff + 0.1591549431f); // RC filter formula + // Converts the buffer data before using it + float *bufferData = (float *)buffer; for (unsigned int i = 0; i < frames*2; i += 2) { - float l = ((float *)buffer)[i], r = ((float *)buffer)[i + 1]; + const float l = bufferData[i]; + const float r = bufferData[i + 1]; + low[0] += k * (l - low[0]); low[1] += k * (r - low[1]); - ((float *)buffer)[i] = low[0]; - ((float *)buffer)[i + 1] = low[1]; + bufferData[i] = low[0]; + bufferData[i + 1] = low[1]; } } @@ -176,4 +180,4 @@ static void AudioProcessEffectDelay(void *buffer, unsigned int frames) delayBuffer[delayWriteIndex++] = ((float *)buffer)[i + 1]; if (delayWriteIndex == delayBufferSize) delayWriteIndex = 0; } -} \ No newline at end of file +} diff --git a/examples/core/core_vr_simulator.c b/examples/core/core_vr_simulator.c index fc2dee6b9..9acea1972 100644 --- a/examples/core/core_vr_simulator.c +++ b/examples/core/core_vr_simulator.c @@ -39,7 +39,6 @@ int main(void) .vResolution = 1200, // Vertical resolution in pixels .hScreenSize = 0.133793f, // Horizontal size in meters .vScreenSize = 0.0669f, // Vertical size in meters - .vScreenCenter = 0.04678f, // Screen center in meters .eyeToScreenDistance = 0.041f, // Distance between eye and display in meters .lensSeparationDistance = 0.07f, // Lens separation distance in meters .interpupillaryDistance = 0.07f, // IPD (distance between pupils) in meters diff --git a/src/raylib.h b/src/raylib.h index fd870c188..206b26573 100644 --- a/src/raylib.h +++ b/src/raylib.h @@ -484,7 +484,6 @@ typedef struct VrDeviceInfo { int vResolution; // Vertical resolution in pixels float hScreenSize; // Horizontal size in meters float vScreenSize; // Vertical size in meters - float vScreenCenter; // Screen center in meters float eyeToScreenDistance; // Distance between eye and display in meters float lensSeparationDistance; // Lens separation distance in meters float interpupillaryDistance; // IPD (distance between pupils) in meters @@ -1481,6 +1480,7 @@ RLAPI const char *TextToUpper(const char *text); // Get upp RLAPI const char *TextToLower(const char *text); // Get lower case version of provided string RLAPI const char *TextToPascal(const char *text); // Get Pascal case notation version of provided string RLAPI int TextToInteger(const char *text); // Get integer value from text (negative values not supported) +RLAPI float TextToFloat(const char *text); // Get float value from text (negative values not supported) //------------------------------------------------------------------------------------ // Basic 3d Shapes Drawing Functions (Module: models) diff --git a/src/rcore.c b/src/rcore.c index a85b0971f..8691be304 100644 --- a/src/rcore.c +++ b/src/rcore.c @@ -1192,8 +1192,8 @@ VrStereoConfig LoadVrStereoConfig(VrDeviceInfo device) // NOTE: Camera movement might seem more natural if we model the head. // Our axis of rotation is the base of our head, so we might want to add // some y (base of head to eye level) and -z (center of head to eye protrusion) to the camera positions. - config.viewOffset[0] = MatrixTranslate(-device.interpupillaryDistance*0.5f, 0.075f, 0.045f); - config.viewOffset[1] = MatrixTranslate(device.interpupillaryDistance*0.5f, 0.075f, 0.045f); + config.viewOffset[0] = MatrixTranslate(device.interpupillaryDistance*0.5f, 0.075f, 0.045f); + config.viewOffset[1] = MatrixTranslate(-device.interpupillaryDistance*0.5f, 0.075f, 0.045f); // Compute eyes Viewports /* diff --git a/src/rtext.c b/src/rtext.c index 1ab45277a..a919fa4ad 100644 --- a/src/rtext.c +++ b/src/rtext.c @@ -1421,6 +1421,28 @@ int TextToInteger(const char *text) return value*sign; } +float TextToFloat(const char *text) +{ + float value = 0.0f; + float sign = 1.0f; + + if ((text[0] == '+') || (text[0] == '-')) + { + if (text[0] == '-') sign = -1; + text++; + } + int i = 0; + for (; ((text[i] >= '0') && (text[i] <= '9')); ++i) value = value*10.0f + (float)(text[i] - '0'); + if (text[i++] != '.') return value*sign; + float divisor = 10.0f; + for (; ((text[i] >= '0') && (text[i] <= '9')); ++i) + { + value += ((float)(text[i] - '0'))/divisor; + divisor = divisor*10.0f; + } + return value; +} + #if defined(SUPPORT_TEXT_MANIPULATION) // Copy one string to another, returns bytes copied int TextCopy(char *dst, const char *src) diff --git a/src/rtextures.c b/src/rtextures.c index a7632f3d3..d42304c7d 100644 --- a/src/rtextures.c +++ b/src/rtextures.c @@ -1959,29 +1959,24 @@ void ImageBlurGaussian(Image *image, int blurSize) { float avgG = 0.0f; float avgB = 0.0f; float avgAlpha = 0.0f; - int convolutionSize = blurSize+1; + int convolutionSize = blurSize; - for (int i = 0; i < blurSize+1; i++) + for (int i = 0; i < blurSize; i++) { avgR += pixelsCopy1[row*image->width + i].x; avgG += pixelsCopy1[row*image->width + i].y; avgB += pixelsCopy1[row*image->width + i].z; avgAlpha += pixelsCopy1[row*image->width + i].w; - } - - pixelsCopy2[row*image->width].x = avgR/convolutionSize; - pixelsCopy2[row*image->width].y = avgG/convolutionSize; - pixelsCopy2[row*image->width].z = avgB/convolutionSize; - pixelsCopy2[row*image->width].w = avgAlpha/convolutionSize; + } - for (int x = 1; x < image->width; x++) + for (int x = 0; x < image->width; x++) { - if (x-blurSize >= 0) + if (x-blurSize-1 >= 0) { - avgR -= pixelsCopy1[row*image->width + x-blurSize].x; - avgG -= pixelsCopy1[row*image->width + x-blurSize].y; - avgB -= pixelsCopy1[row*image->width + x-blurSize].z; - avgAlpha -= pixelsCopy1[row*image->width + x-blurSize].w; + avgR -= pixelsCopy1[row*image->width + x-blurSize-1].x; + avgG -= pixelsCopy1[row*image->width + x-blurSize-1].y; + avgB -= pixelsCopy1[row*image->width + x-blurSize-1].z; + avgAlpha -= pixelsCopy1[row*image->width + x-blurSize-1].w; convolutionSize--; } @@ -1999,7 +1994,7 @@ void ImageBlurGaussian(Image *image, int blurSize) { pixelsCopy2[row*image->width + x].z = avgB/convolutionSize; pixelsCopy2[row*image->width + x].w = avgAlpha/convolutionSize; } - } + } // Vertical motion blur for (int col = 0; col < image->width; col++) @@ -2008,9 +2003,9 @@ void ImageBlurGaussian(Image *image, int blurSize) { float avgG = 0.0f; float avgB = 0.0f; float avgAlpha = 0.0f; - int convolutionSize = blurSize+1; + int convolutionSize = blurSize; - for (int i = 0; i < blurSize+1; i++) + for (int i = 0; i < blurSize; i++) { avgR += pixelsCopy2[i*image->width + col].x; avgG += pixelsCopy2[i*image->width + col].y; @@ -2018,19 +2013,14 @@ void ImageBlurGaussian(Image *image, int blurSize) { avgAlpha += pixelsCopy2[i*image->width + col].w; } - pixelsCopy1[col].x = (unsigned char) (avgR/convolutionSize); - pixelsCopy1[col].y = (unsigned char) (avgG/convolutionSize); - pixelsCopy1[col].z = (unsigned char) (avgB/convolutionSize); - pixelsCopy1[col].w = (unsigned char) (avgAlpha/convolutionSize); - - for (int y = 1; y < image->height; y++) + for (int y = 0; y < image->height; y++) { - if (y-blurSize >= 0) + if (y-blurSize-1 >= 0) { - avgR -= pixelsCopy2[(y-blurSize)*image->width + col].x; - avgG -= pixelsCopy2[(y-blurSize)*image->width + col].y; - avgB -= pixelsCopy2[(y-blurSize)*image->width + col].z; - avgAlpha -= pixelsCopy2[(y-blurSize)*image->width + col].w; + avgR -= pixelsCopy2[(y-blurSize-1)*image->width + col].x; + avgG -= pixelsCopy2[(y-blurSize-1)*image->width + col].y; + avgB -= pixelsCopy2[(y-blurSize-1)*image->width + col].z; + avgAlpha -= pixelsCopy2[(y-blurSize-1)*image->width + col].w; convolutionSize--; } if (y+blurSize < image->height)