summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2023-12-14 15:32:45 +0100
committerRay <[email protected]>2023-12-14 15:32:45 +0100
commitd29b36310ff155cebd9e8227752805106489943a (patch)
tree41293470cb61df7c96c83e8bbeb0f806206277d4
parent88db11fda4421c66a6043011b36a3f13494b98e5 (diff)
parentcec2261e968bfc554d7b1639dd4d55ab4e2235e6 (diff)
downloadraylib-d29b36310ff155cebd9e8227752805106489943a.tar.gz
raylib-d29b36310ff155cebd9e8227752805106489943a.zip
Merge branch 'master' of https://github.com/raysan5/raylib
-rw-r--r--.gitignore1
-rw-r--r--examples/audio/audio_stream_effects.c16
-rw-r--r--examples/core/core_vr_simulator.c1
-rw-r--r--src/raylib.h2
-rw-r--r--src/rcore.c4
-rw-r--r--src/rtext.c22
-rw-r--r--src/rtextures.c46
7 files changed, 54 insertions, 38 deletions
diff --git a/.gitignore b/.gitignore
index 559f9f0d..6ff0e234 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 21930505..2262d41f 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 <stdlib.h> // Required for: NULL
+#include <stdlib.h> // 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 fc2dee6b..9acea197 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 fd870c18..206b2657 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 a85b0971..8691be30 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 1ab45277..a919fa4a 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 a7632f3d..d42304c7 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)