Skip to content

Commit

Permalink
Update upstream
Browse files Browse the repository at this point in the history
  • Loading branch information
planetis-m committed Oct 26, 2024
1 parent 0289d22 commit 7205a2a
Show file tree
Hide file tree
Showing 13 changed files with 516 additions and 354 deletions.
22 changes: 11 additions & 11 deletions mangle_names.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,24 @@ when defined(nimPreviewSlimSystem):

const NonWordChars = {'\1'..'\xff'} - IdentChars

func identifier(name: string): Peg =
func ident(name: string): Peg =
let wordBoundary = charSet(NonWordChars) / startAnchor() / endAnchor()
result = sequence(capture(wordBoundary), term(name), capture(wordBoundary))
sequence(capture(wordBoundary), term(name), capture(wordBoundary))

let replacements = [
# Match identifier when surrounded by non-word chars, but only capture the identifier
(identifier("Rectangle"), "$1rlRectangle$2"),
(identifier("CloseWindow"), "$1rlCloseWindow$2"),
(identifier("ShowCursor"), "$1rlShowCursor$2"),
(identifier("LoadImage"), "$1rlLoadImage$2"),
(identifier("DrawText"), "$1rlDrawText$2"),
(identifier("DrawTextEx"), "$1rlDrawTextEx$2")
# Match identifier when surrounded by non-word chars.
(ident"Rectangle", "$1rlRectangle$2"),
(ident"CloseWindow", "$1rlCloseWindow$2"),
(ident"ShowCursor", "$1rlShowCursor$2"),
(ident"LoadImage", "$1rlLoadImage$2"),
(ident"DrawText", "$1rlDrawText$2"),
(ident"DrawTextEx", "$1rlDrawTextEx$2")
]

proc processFile(path: Path, replacements: openArray[(Peg, string)]) =
echo "Processing: ", path
var content = readFile($path)
var newContent = content.parallelReplace(replacements)
let content = readFile($path)
let newContent = content.parallelReplace(replacements)

# Write back only if changes were made
if newContent != content:
Expand Down
2 changes: 1 addition & 1 deletion src/raylib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ endif
ifeq ($(TARGET_PLATFORM),PLATFORM_WEB)
# On HTML5 OpenGL ES 2.0 is used, emscripten translates it to WebGL 1.0
GRAPHICS = GRAPHICS_API_OPENGL_ES2
#GRAPHICS = GRAPHICS_API_OPENGL_ES3 # Uncomment to use ES3/WebGL2 (preliminary support)
#GRAPHICS = GRAPHICS_API_OPENGL_ES3
endif
ifeq ($(TARGET_PLATFORM),PLATFORM_ANDROID)
# By default use OpenGL ES 2.0 on Android
Expand Down
48 changes: 46 additions & 2 deletions src/raylib/external/cgltf.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/**
* cgltf - a single-file glTF 2.0 parser written in C99.
*
* Version: 1.13
* Version: 1.14
*
* Website: https://github.com/jkuhlmann/cgltf
*
Expand Down Expand Up @@ -395,6 +395,8 @@ typedef struct cgltf_texture
cgltf_sampler* sampler;
cgltf_bool has_basisu;
cgltf_image* basisu_image;
cgltf_bool has_webp;
cgltf_image* webp_image;
cgltf_extras extras;
cgltf_size extensions_count;
cgltf_extension* extensions;
Expand Down Expand Up @@ -1697,7 +1699,20 @@ cgltf_result cgltf_validate(cgltf_data* data)
{
if (data->nodes[i].weights && data->nodes[i].mesh)
{
CGLTF_ASSERT_IF (data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
CGLTF_ASSERT_IF(data->nodes[i].mesh->primitives_count && data->nodes[i].mesh->primitives[0].targets_count != data->nodes[i].weights_count, cgltf_result_invalid_gltf);
}

if (data->nodes[i].has_mesh_gpu_instancing)
{
CGLTF_ASSERT_IF(data->nodes[i].mesh == NULL, cgltf_result_invalid_gltf);
CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes_count == 0, cgltf_result_invalid_gltf);

cgltf_accessor* first = data->nodes[i].mesh_gpu_instancing.attributes[0].data;

for (cgltf_size k = 0; k < data->nodes[i].mesh_gpu_instancing.attributes_count; ++k)
{
CGLTF_ASSERT_IF(data->nodes[i].mesh_gpu_instancing.attributes[k].data->count != first->count, cgltf_result_invalid_gltf);
}
}
}

Expand Down Expand Up @@ -4538,6 +4553,34 @@ static int cgltf_parse_json_texture(cgltf_options* options, jsmntok_t const* tok
}
}
}
else if (cgltf_json_strcmp(tokens + i, json_chunk, "EXT_texture_webp") == 0)
{
out_texture->has_webp = 1;
++i;
CGLTF_CHECK_TOKTYPE(tokens[i], JSMN_OBJECT);
int num_properties = tokens[i].size;
++i;

for (int t = 0; t < num_properties; ++t)
{
CGLTF_CHECK_KEY(tokens[i]);

if (cgltf_json_strcmp(tokens + i, json_chunk, "source") == 0)
{
++i;
out_texture->webp_image = CGLTF_PTRINDEX(cgltf_image, cgltf_json_to_int(tokens + i, json_chunk));
++i;
}
else
{
i = cgltf_skip_json(tokens, i + 1);
}
if (i < 0)
{
return i;
}
}
}
else
{
i = cgltf_parse_json_unprocessed_extension(options, tokens, i, json_chunk, &(out_texture->extensions[out_texture->extensions_count++]));
Expand Down Expand Up @@ -6548,6 +6591,7 @@ static int cgltf_fixup_pointers(cgltf_data* data)
{
CGLTF_PTRFIXUP(data->textures[i].image, data->images, data->images_count);
CGLTF_PTRFIXUP(data->textures[i].basisu_image, data->images, data->images_count);
CGLTF_PTRFIXUP(data->textures[i].webp_image, data->images, data->images_count);
CGLTF_PTRFIXUP(data->textures[i].sampler, data->samplers, data->samplers_count);
}

Expand Down
15 changes: 9 additions & 6 deletions src/raylib/external/dr_mp3.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
MP3 audio decoder. Choice of public domain or MIT-0. See license statements at the end of this file.
dr_mp3 - v0.6.38 - 2023-11-02
dr_mp3 - v0.6.39 - 2024-02-27
David Reid - mackron@gmail.com
Expand Down Expand Up @@ -95,7 +95,7 @@ extern "C" {

#define DRMP3_VERSION_MAJOR 0
#define DRMP3_VERSION_MINOR 6
#define DRMP3_VERSION_REVISION 38
#define DRMP3_VERSION_REVISION 39
#define DRMP3_VERSION_STRING DRMP3_XSTRINGIFY(DRMP3_VERSION_MAJOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_MINOR) "." DRMP3_XSTRINGIFY(DRMP3_VERSION_REVISION)

#include <stddef.h> /* For size_t. */
Expand Down Expand Up @@ -1985,8 +1985,8 @@ static drmp3_int16 drmp3d_scale_pcm(float sample)
s32 -= (s32 < 0);
s = (drmp3_int16)drmp3_clip_int16_arm(s32);
#else
if (sample >= 32766.5) return (drmp3_int16) 32767;
if (sample <= -32767.5) return (drmp3_int16)-32768;
if (sample >= 32766.5f) return (drmp3_int16) 32767;
if (sample <= -32767.5f) return (drmp3_int16)-32768;
s = (drmp3_int16)(sample + .5f);
s -= (s < 0); /* away from zero, to be compliant */
#endif
Expand Down Expand Up @@ -2404,9 +2404,9 @@ DRMP3_API void drmp3dec_f32_to_s16(const float *in, drmp3_int16 *out, size_t num
for(; i < num_samples; i++)
{
float sample = in[i] * 32768.0f;
if (sample >= 32766.5)
if (sample >= 32766.5f)
out[i] = (drmp3_int16) 32767;
else if (sample <= -32767.5)
else if (sample <= -32767.5f)
out[i] = (drmp3_int16)-32768;
else
{
Expand Down Expand Up @@ -4495,6 +4495,9 @@ counts rather than sample counts.
/*
REVISION HISTORY
================
v0.6.39 - 2024-02-27
- Fix a Wdouble-promotion warning.
v0.6.38 - 2023-11-02
- Fix build for ARMv6-M.
Expand Down
28 changes: 20 additions & 8 deletions src/raylib/external/dr_wav.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
WAV audio loader and writer. Choice of public domain or MIT-0. See license statements at the end of this file.
dr_wav - v0.13.13 - 2023-11-02
dr_wav - v0.13.16 - 2024-02-27
David Reid - mackron@gmail.com
Expand Down Expand Up @@ -147,7 +147,7 @@ extern "C" {

#define DRWAV_VERSION_MAJOR 0
#define DRWAV_VERSION_MINOR 13
#define DRWAV_VERSION_REVISION 13
#define DRWAV_VERSION_REVISION 16
#define DRWAV_VERSION_STRING DRWAV_XSTRINGIFY(DRWAV_VERSION_MAJOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_MINOR) "." DRWAV_XSTRINGIFY(DRWAV_VERSION_REVISION)

#include <stddef.h> /* For size_t. */
Expand Down Expand Up @@ -3075,7 +3075,13 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on

if (pWav->container == drwav_container_riff || pWav->container == drwav_container_rifx) {
if (drwav_bytes_to_u32_ex(chunkSizeBytes, pWav->container) < 36) {
return DRWAV_FALSE; /* Chunk size should always be at least 36 bytes. */
/*
I've had a report of a WAV file failing to load when the size of the WAVE chunk is not encoded
and is instead just set to 0. I'm going to relax the validation here to allow these files to
load. Considering the chunk size isn't actually used this should be safe. With this change my
test suite still passes.
*/
/*return DRWAV_FALSE;*/ /* Chunk size should always be at least 36 bytes. */
}
} else if (pWav->container == drwav_container_rf64) {
if (drwav_bytes_to_u32_le(chunkSizeBytes) != 0xFFFFFFFF) {
Expand Down Expand Up @@ -3554,10 +3560,7 @@ DRWAV_PRIVATE drwav_bool32 drwav_init__internal(drwav* pWav, drwav_chunk_proc on

/* Getting here means it's not a chunk that we care about internally, but might need to be handled as metadata by the caller. */
if (isProcessingMetadata) {
drwav_uint64 metadataBytesRead;

metadataBytesRead = drwav__metadata_process_chunk(&metadataParser, &header, drwav_metadata_type_all_including_unknown);
DRWAV_ASSERT(metadataBytesRead <= header.sizeInBytes);
drwav__metadata_process_chunk(&metadataParser, &header, drwav_metadata_type_all_including_unknown);

/* Go back to the start of the chunk so we can normalize the position of the cursor. */
if (drwav__seek_from_start(pWav->onSeek, cursor, pWav->pUserData) == DRWAV_FALSE) {
Expand Down Expand Up @@ -7830,7 +7833,7 @@ DRWAV_API void drwav_f32_to_s32(drwav_int32* pOut, const float* pIn, size_t samp
}

for (i = 0; i < sampleCount; ++i) {
*pOut++ = (drwav_int32)(2147483648.0 * pIn[i]);
*pOut++ = (drwav_int32)(2147483648.0f * pIn[i]);
}
}

Expand Down Expand Up @@ -8347,6 +8350,15 @@ DRWAV_API drwav_bool32 drwav_fourcc_equal(const drwav_uint8* a, const char* b)
/*
REVISION HISTORY
================
v0.13.16 - 2024-02-27
- Fix a Wdouble-promotion warning.
v0.13.15 - 2024-01-23
- Relax some unnecessary validation that prevented some files from loading.
v0.13.14 - 2023-12-02
- Fix a warning about an unused variable.
v0.13.13 - 2023-11-02
- Fix a warning when compiling with Clang.
Expand Down
Loading

0 comments on commit 7205a2a

Please sign in to comment.