From 2554dcba9b9175781ba042b7d13c9a80d7d5fb6d Mon Sep 17 00:00:00 2001 From: Maicon Santana Date: Wed, 24 Sep 2025 09:22:03 +0100 Subject: [PATCH 1/5] fix rlSetTexture not overriding default mode (#5200) --- src/rlgl.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/rlgl.h b/src/rlgl.h index e58302ceb..7db05251d 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1067,6 +1067,7 @@ typedef struct rlglData { Matrix stack[RL_MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop int stackCounter; // Matrix stack counter + unsigned int currentTextureId; // Current texture id to be used on glBegin unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader) unsigned int activeTextureId[RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS]; // Active texture ids to be enabled on batch drawing (0 active by default) unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program) @@ -1485,8 +1486,8 @@ void rlBegin(int mode) if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch); RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode; - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0; - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.currentTextureId; + RLGL.State.currentTextureId = RLGL.State.defaultTextureId; } } @@ -1651,6 +1652,7 @@ void rlSetTexture(unsigned int id) { rlDrawRenderBatch(RLGL.currentBatch); } + RLGL.State.currentTextureId = RLGL.State.defaultTextureId; #endif } else @@ -1658,6 +1660,7 @@ void rlSetTexture(unsigned int id) #if defined(GRAPHICS_API_OPENGL_11) rlEnableTexture(id); #else + RLGL.State.currentTextureId = id; if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId != id) { if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0) @@ -1676,6 +1679,9 @@ void rlSetTexture(unsigned int id) RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; RLGL.currentBatch->drawCounter++; + + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 2].mode; + } } @@ -2257,6 +2263,7 @@ void rlglInit(int width, int height) // Init default white texture unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes) RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1); + RLGL.State.currentTextureId = RLGL.State.defaultTextureId; if (RLGL.State.defaultTextureId != 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture loaded successfully", RLGL.State.defaultTextureId); else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load default texture"); From 07033cff904ef3a46ffd12e8f8235e06bdb1096d Mon Sep 17 00:00:00 2001 From: Maicon Santana Date: Wed, 24 Sep 2025 19:44:15 +0100 Subject: [PATCH 2/5] Fix polygon drawing example for opengl 1.1 (#5202) --- examples/textures/textures_polygon_drawing.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/textures/textures_polygon_drawing.c b/examples/textures/textures_polygon_drawing.c index 8005ad1a1..ec1869d67 100644 --- a/examples/textures/textures_polygon_drawing.c +++ b/examples/textures/textures_polygon_drawing.c @@ -115,9 +115,9 @@ int main(void) // without crossing perimeter, points must be in anticlockwise order void DrawTexturePoly(Texture2D texture, Vector2 center, Vector2 *points, Vector2 *texcoords, int pointCount, Color tint) { + rlSetTexture(texture.id); rlBegin(RL_TRIANGLES); - rlSetTexture(texture.id); rlColor4ub(tint.r, tint.g, tint.b, tint.a); From 3f6d67c61c59affa4561de2ddf988e487093bc80 Mon Sep 17 00:00:00 2001 From: Keks137 Date: Wed, 24 Sep 2025 20:45:55 +0200 Subject: [PATCH 3/5] [rcore_android] implement GetCurrentMonitor() (#5204) --- src/platforms/rcore_android.c | 30 +++++++++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_android.c b/src/platforms/rcore_android.c index bfbdd30b3..6c67dc893 100644 --- a/src/platforms/rcore_android.c +++ b/src/platforms/rcore_android.c @@ -49,7 +49,7 @@ #include // Required for: android_app struct and activity management #include // Required for: AWINDOW_FLAG_FULLSCREEN definition and others //#include // Required for: Android sensors functions (accelerometer, gyroscope, light...) -#include // Required for: JNIEnv and JavaVM [Used in OpenURL()] +#include // Required for: JNIEnv and JavaVM [Used in OpenURL() and GetCurrentMonitor()] #include // Native platform windowing system interface @@ -446,8 +446,32 @@ int GetMonitorCount(void) // Get current monitor where window is placed int GetCurrentMonitor(void) { - TRACELOG(LOG_WARNING, "GetCurrentMonitor() not implemented on target platform"); - return 0; + int displayId = -1; + JNIEnv* env = NULL; + JavaVM* vm = platform.app->activity->vm; + (*vm)->AttachCurrentThread(vm, &env, NULL); + + jobject activity = platform.app->activity->clazz; + jclass activityClass = (*env)->GetObjectClass(env, activity); + + jmethodID getDisplayMethod = (*env)->GetMethodID(env, activityClass, "getDisplay", "()Landroid/view/Display;"); + + jobject display = (*env)->CallObjectMethod(env, activity, getDisplayMethod); + + if (display == NULL) { + TRACELOG(LOG_ERROR, "GetCurrentMonitor() couldn't get the display object"); + } else { + jclass displayClass = (*env)->FindClass(env, "android/view/Display"); + jmethodID getDisplayIdMethod = (*env)->GetMethodID(env, displayClass, "getDisplayId", "()I"); + displayId = (int) (*env)->CallIntMethod(env, display, getDisplayIdMethod); + (*env)->DeleteLocalRef(env, displayClass); + } + + (*env)->DeleteLocalRef(env, activityClass); + (*env)->DeleteLocalRef(env, display); + + (*vm)->DetachCurrentThread(vm); + return displayId; } // Get selected monitor position From 15d234b79d357faa070d5cd7d29b08daaa23a944 Mon Sep 17 00:00:00 2001 From: Arman Ommid <71801518+ArmanOmmid@users.noreply.github.com> Date: Fri, 26 Sep 2025 11:56:37 -0700 Subject: [PATCH 4/5] GLTF anim correctly inherits world transform (#5206) --- src/rmodels.c | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/rmodels.c b/src/rmodels.c index 128d5303b..06180cd5d 100644 --- a/src/rmodels.c +++ b/src/rmodels.c @@ -4261,9 +4261,10 @@ static void BuildPoseFromParentJoints(BoneInfo *bones, int boneCount, Transform continue; } transforms[i].rotation = QuaternionMultiply(transforms[bones[i].parent].rotation, transforms[i].rotation); + transforms[i].scale = Vector3Multiply(transforms[i].scale, transforms[bones[i].parent].scale); + transforms[i].translation = Vector3Multiply(transforms[i].translation, transforms[bones[i].parent].scale); transforms[i].translation = Vector3RotateByQuaternion(transforms[i].translation, transforms[bones[i].parent].rotation); transforms[i].translation = Vector3Add(transforms[i].translation, transforms[bones[i].parent].translation); - transforms[i].scale = Vector3Multiply(transforms[i].scale, transforms[bones[i].parent].scale); } } } @@ -6238,6 +6239,20 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo *animCount = (int)data->animations_count; animations = (ModelAnimation *)RL_CALLOC(data->animations_count, sizeof(ModelAnimation)); + Transform worldTransform; + { + cgltf_float cgltf_worldTransform[16]; + cgltf_node* node = skin.joints[0]; + cgltf_node_transform_world(node->parent, cgltf_worldTransform); + Matrix worldMatrix = { + cgltf_worldTransform[0], cgltf_worldTransform[4], cgltf_worldTransform[8], cgltf_worldTransform[12], + cgltf_worldTransform[1], cgltf_worldTransform[5], cgltf_worldTransform[9], cgltf_worldTransform[13], + cgltf_worldTransform[2], cgltf_worldTransform[6], cgltf_worldTransform[10], cgltf_worldTransform[14], + cgltf_worldTransform[3], cgltf_worldTransform[7], cgltf_worldTransform[11], cgltf_worldTransform[15] + }; + MatrixDecompose(worldMatrix, &(worldTransform.translation), &(worldTransform.rotation), &(worldTransform.scale)); + } + for (unsigned int i = 0; i < data->animations_count; i++) { animations[i].bones = LoadBoneInfoGLTF(skin, &animations[i].boneCount); @@ -6356,6 +6371,13 @@ static ModelAnimation *LoadModelAnimationsGLTF(const char *fileName, int *animCo }; } + Transform* root = &animations[i].framePoses[j][0]; + root->rotation = QuaternionMultiply(worldTransform.rotation, root->rotation); + root->scale = Vector3Multiply(root->scale, worldTransform.scale); + root->translation = Vector3Multiply(root->translation, worldTransform.scale); + root->translation = Vector3RotateByQuaternion(root->translation, worldTransform.rotation); + root->translation = Vector3Add(root->translation, worldTransform.translation); + BuildPoseFromParentJoints(animations[i].bones, animations[i].boneCount, animations[i].framePoses[j]); } From fe8c83b57d623e8343f09cd1a9e8b548defc4da0 Mon Sep 17 00:00:00 2001 From: Smallz3201 Date: Fri, 26 Sep 2025 14:56:54 -0400 Subject: [PATCH 5/5] Update palette_switch.fs (#5205) Removed unnecessary `a` in palette_switch.fs `note` comment --- examples/shaders/resources/shaders/glsl330/palette_switch.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/shaders/resources/shaders/glsl330/palette_switch.fs b/examples/shaders/resources/shaders/glsl330/palette_switch.fs index 6a82529b1..2db8880d1 100644 --- a/examples/shaders/resources/shaders/glsl330/palette_switch.fs +++ b/examples/shaders/resources/shaders/glsl330/palette_switch.fs @@ -17,7 +17,7 @@ out vec4 finalColor; void main() { // Texel color fetching from texture sampler - // NOTE: The texel is actually the a GRAYSCALE index color + // NOTE: The texel is actually the GRAYSCALE index color vec4 texelColor = texture(texture0, fragTexCoord)*fragColor; // Convert the (normalized) texel color RED component (GB would work, too)