8 Commits

Author SHA1 Message Date
Ray
e8ce00dc0b REVIEWED: LoadGLTF(), log warning about draco compression not supported #5567 2026-02-17 17:02:19 +01:00
Ray
872cfae7ca REVIEWED: LoadDirectoryFilesEx(), minor tweak #5569 2026-02-17 16:51:50 +01:00
Ray
1955516f54 Updated raygui for examples 2026-02-17 16:39:02 +01:00
Ray
95edeeccd2 REVIEWED: example: models_animation_bone_blending 2026-02-17 16:17:14 +01:00
4311df1e6d Add bone blending animation example (#5543)
- Demonstrates per-bone animation blending for smooth transitions
- Supports upper/lower body selective blending (walk + attack)
- Includes uniform blending mode for comparison
- Uses GPU skinning for performance
- Follows raylib example conventions
2026-02-17 15:43:46 +01:00
Ray
5bbb2fc1df REVIEWED: Wayland checks, using compilation flags when possible #5564 2026-02-17 13:22:11 +01:00
4678a544b6 [rcore][glfw] Fix window scaling on Wayland with GLFW 3.4+ (#5564)
* Fix window scaling on Wayland with GLFW 3.4+ display scaling

GLFW 3.4 defaults GLFW_SCALE_FRAMEBUFFER to TRUE on all platforms,
causing framebuffer/window size mismatch on Wayland with display
scaling (content renders in a subset of the window, mouse coordinates
are wrong).

Three fixes:
- Disable GLFW_SCALE_FRAMEBUFFER on Wayland when FLAG_WINDOW_HIGHDPI
  is not set, restoring 1:1 window-to-framebuffer mapping
- With FLAG_WINDOW_HIGHDPI, read actual framebuffer size from GLFW
  instead of resizing the window (which double-scales on Wayland
  where GLFW_SCALE_TO_MONITOR has no effect)
- Skip mouse coordinate scaling on Wayland since GLFW already reports
  coordinates in logical (window) space

Tested on NixOS/Niri with GLFW 3.4 at 1x, 1.5x, and 2x scaling.

Fixes #5504

* Fix fullscreen and borderless windowed scaling on Wayland with HiDPI

ToggleFullscreen and ToggleBorderlessWindowed exit paths manually
scale screen size by DPI before passing to glfwSetWindowMonitor,
which double-scales on Wayland where GLFW_SCALE_FRAMEBUFFER already
handles it. Skip the manual resize on Wayland.

Also fix FramebufferSizeCallback fullscreen branch: on Wayland with
GLFW_SCALE_FRAMEBUFFER the framebuffer is still scaled in fullscreen,
so use the logical window size as screen size and derive screenScale
from the framebuffer/window ratio.

Fixes #5504

* Apply style fixes from code review: remove duplicate screenScale assignment, collapse single-statement ifs to one line, remove trailing periods from comments
2026-02-17 12:43:52 +01:00
Ray
b871a556d7 Init framebuffer using render size (should be same as currentFbo) 2026-02-17 12:13:04 +01:00
10 changed files with 7100 additions and 522 deletions

View File

@ -37,10 +37,18 @@ int main(void)
char directory[MAX_FILEPATH_SIZE] = { 0 };
strcpy(directory, GetWorkingDirectory());
FilePathList files = LoadDirectoryFiles(directory);
// Load file-paths on current working directory
// NOTE: LoadDirectoryFiles() loads files and directories by default,
// use LoadDirectoryFilesEx() for custom filters and recursive directories loading
//FilePathList files = LoadDirectoryFiles(directory);
FilePathList files = LoadDirectoryFilesEx(directory, ".png;.c", false);
int btnBackPressed = false;
int listScrollIndex = 0;
int listItemActive = -1;
int listItemFocused = -1;
SetTargetFPS(60);
//--------------------------------------------------------------------------------------
@ -62,10 +70,18 @@ int main(void)
BeginDrawing();
ClearBackground(RAYWHITE);
DrawText(directory, 100, 40, 20, DARKGRAY);
btnBackPressed = GuiButton((Rectangle){ 40.0f, 10.0f, 48, 28 }, "<");
btnBackPressed = GuiButton((Rectangle){ 40.0f, 38.0f, 48, 24 }, "<");
GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetFont().baseSize*2);
GuiLabel((Rectangle){ 40 + 48 + 10, 10, 700, 28 }, directory);
GuiSetStyle(DEFAULT, TEXT_SIZE, GuiGetFont().baseSize);
GuiSetStyle(LISTVIEW, TEXT_ALIGNMENT, TEXT_ALIGN_LEFT);
GuiSetStyle(LISTVIEW, TEXT_PADDING, 40);
GuiListViewEx((Rectangle){ 0, 50, GetScreenWidth(), GetScreenHeight() - 50 },
files.paths, files.count, &listScrollIndex, &listItemActive, &listItemFocused);
/*
for (int i = 0; i < (int)files.count; i++)
{
Color color = Fade(LIGHTGRAY, 0.3f);
@ -84,6 +100,7 @@ int main(void)
DrawRectangle(0, 85 + 40*i, screenWidth, 40, color);
DrawText(GetFileName(files.paths[i]), 120, 100 + 40*i, 10, GRAY);
}
*/
EndDrawing();
//----------------------------------------------------------------------------------

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,296 @@
/*******************************************************************************************
*
* raylib [models] example - animation bone blending
*
* Example complexity rating: [★★★★] 4/4
*
* Example originally created with raylib 5.5, last time updated with raylib 5.5
*
* This example demonstrates per-bone animation blending, allowing smooth transitions
* between two animations by interpolating bone transforms. This is useful for:
* - Blending movement animations (walk/run) with action animations (jump/attack)
* - Creating smooth animation transitions
* - Layering animations (e.g., upper body attack while lower body walks)
*
* Example contributed by dmitrii-brand (@dmitrii-brand) and reviewed by Ramon Santamaria (@raysan5)
*
* NOTE: Due to limitations in the Apple OpenGL driver, this feature does not work on MacOS
*
* Example licensed under an unmodified zlib/libpng license, which is an OSI-certified,
* BSD-like license that allows static linking with closed source software
*
* Copyright (c) 2026 dmitrii-brand (@dmitrii-brand)
*
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#include <string.h> // Required for: memcpy()
#include <stdlib.h> // Required for: NULL
#if defined(PLATFORM_DESKTOP)
#define GLSL_VERSION 330
#else // PLATFORM_ANDROID, PLATFORM_WEB
#define GLSL_VERSION 100
#endif
//------------------------------------------------------------------------------------
// Module Functions Declaration
//------------------------------------------------------------------------------------
static bool IsUpperBodyBone(const char *boneName);
static void BlendModelAnimationsBones(Model *model, ModelAnimation *anim1, int frame1,
ModelAnimation *anim2, int frame2, float blendFactor, bool upperBodyBlend);
//------------------------------------------------------------------------------------
// Program main entry point
//------------------------------------------------------------------------------------
int main(void)
{
// Initialization
//--------------------------------------------------------------------------------------
const int screenWidth = 800;
const int screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib [models] example - animation bone blending");
// Define the camera to look into our 3d world
Camera camera = { 0 };
camera.position = (Vector3){ 5.0f, 5.0f, 5.0f }; // Camera position
camera.target = (Vector3){ 0.0f, 2.0f, 0.0f }; // Camera looking at point
camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; // Camera up vector (rotation towards target)
camera.fovy = 45.0f; // Camera field-of-view Y
camera.projection = CAMERA_PERSPECTIVE; // Camera projection type
// Load gltf model
Model characterModel = LoadModel("resources/models/gltf/greenman.glb");
// Load skinning shader
Shader skinningShader = LoadShader(TextFormat("resources/shaders/glsl%i/skinning.vs", GLSL_VERSION),
TextFormat("resources/shaders/glsl%i/skinning.fs", GLSL_VERSION));
characterModel.materials[1].shader = skinningShader;
// Load gltf model animations
int animsCount = 0;
ModelAnimation *modelAnimations = LoadModelAnimations("resources/models/gltf/greenman.glb", &animsCount);
// Log all available animations for debugging
TraceLog(LOG_INFO, "Found %d animations:", animsCount);
for (int i = 0; i < animsCount; i++)
{
TraceLog(LOG_INFO, " Animation %d: %s (%d frames)", i, modelAnimations[i].name, modelAnimations[i].frameCount);
}
// Use specific indices: walk/move = 2, attack = 3
unsigned int animIndex1 = 2; // Walk/Move animation (index 2)
unsigned int animIndex2 = 3; // Attack animation (index 3)
unsigned int animCurrentFrame1 = 0;
unsigned int animCurrentFrame2 = 0;
// Validate indices
if (animIndex1 >= animsCount) animIndex1 = 0;
if (animIndex2 >= animsCount) animIndex2 = (animsCount > 1) ? 1 : 0;
TraceLog(LOG_INFO, "Using Walk (index %d): %s", animIndex1, modelAnimations[animIndex1].name);
TraceLog(LOG_INFO, "Using Attack (index %d): %s", animIndex2, modelAnimations[animIndex2].name);
Vector3 position = { 0.0f, 0.0f, 0.0f }; // Set model position
bool upperBodyBlend = true; // Toggle: true = upper/lower body blending, false = uniform blending (50/50)
DisableCursor(); // Limit cursor to relative movement inside the window
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
UpdateCamera(&camera, CAMERA_THIRD_PERSON);
// Toggle upper/lower body blending mode (SPACE key)
if (IsKeyPressed(KEY_SPACE)) upperBodyBlend = !upperBodyBlend;
// Update animation frames
ModelAnimation anim1 = modelAnimations[animIndex1];
ModelAnimation anim2 = modelAnimations[animIndex2];
animCurrentFrame1 = (animCurrentFrame1 + 1)%anim1.frameCount;
animCurrentFrame2 = (animCurrentFrame2 + 1)%anim2.frameCount;
// Blend the two animations
characterModel.transform = MatrixTranslate(position.x, position.y, position.z);
// When upperBodyBlend is ON: upper body = attack (1.0), lower body = walk (0.0)
// When upperBodyBlend is OFF: uniform blend at 0.5 (50% walk, 50% attack)
float blendFactor = upperBodyBlend ? 1.0f : 0.5f;
BlendModelAnimationsBones(&characterModel, &anim1, animCurrentFrame1, &anim2, animCurrentFrame2, blendFactor, upperBodyBlend);
//----------------------------------------------------------------------------------
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
// Draw character mesh, pose calculation is done in shader (GPU skinning)
DrawMesh(characterModel.meshes[0], characterModel.materials[1], characterModel.transform);
DrawGrid(10, 1.0f);
EndMode3D();
// Draw UI
DrawText("BONE BLENDING EXAMPLE", 10, 10, 20, DARKGRAY);
DrawText(TextFormat("Walk (Animation 2): %s", anim1.name), 10, 35, 10, GRAY);
DrawText(TextFormat("Attack (Animation 3): %s", anim2.name), 10, 50, 10, GRAY);
DrawText(TextFormat("Mode: %s", upperBodyBlend ? "Upper/Lower Body Blending" : "Uniform Blending"), 10, 65, 10, GRAY);
DrawText("SPACE - Toggle blending mode", 10, GetScreenHeight() - 20, 10, DARKGRAY);
EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
UnloadModelAnimations(modelAnimations, animsCount); // Unload model animation
UnloadModel(characterModel); // Unload model and meshes/material
UnloadShader(skinningShader); // Unload GPU skinning shader
CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
return 0;
}
//----------------------------------------------------------------------------------
// Module Functions Definition
//----------------------------------------------------------------------------------
// Check if a bone is part of upper body (for selective blending)
static bool IsUpperBodyBone(const char *boneName)
{
// Common upper body bone names (adjust based on your model)
if (TextIsEqual(boneName, "spine") || TextIsEqual(boneName, "spine1") || TextIsEqual(boneName, "spine2") ||
TextIsEqual(boneName, "chest") || TextIsEqual(boneName, "upperChest") ||
TextIsEqual(boneName, "neck") || TextIsEqual(boneName, "head") ||
TextIsEqual(boneName, "shoulder") || TextIsEqual(boneName, "shoulder_L") || TextIsEqual(boneName, "shoulder_R") ||
TextIsEqual(boneName, "upperArm") || TextIsEqual(boneName, "upperArm_L") || TextIsEqual(boneName, "upperArm_R") ||
TextIsEqual(boneName, "lowerArm") || TextIsEqual(boneName, "lowerArm_L") || TextIsEqual(boneName, "lowerArm_R") ||
TextIsEqual(boneName, "hand") || TextIsEqual(boneName, "hand_L") || TextIsEqual(boneName, "hand_R") ||
TextIsEqual(boneName, "clavicle") || TextIsEqual(boneName, "clavicle_L") || TextIsEqual(boneName, "clavicle_R"))
{
return true;
}
// Check if bone name contains upper body keywords
if (strstr(boneName, "spine") != NULL || strstr(boneName, "chest") != NULL ||
strstr(boneName, "neck") != NULL || strstr(boneName, "head") != NULL ||
strstr(boneName, "shoulder") != NULL || strstr(boneName, "arm") != NULL ||
strstr(boneName, "hand") != NULL || strstr(boneName, "clavicle") != NULL)
{
return true;
}
return false;
}
// Blend two animations per-bone with selective upper/lower body blending
static void BlendModelAnimationsBones(Model *model, ModelAnimation *anim1, int frame1,
ModelAnimation *anim2, int frame2, float blendFactor, bool upperBodyBlend)
{
// Validate inputs
if (anim1->boneCount == 0 || anim1->framePoses == NULL ||
anim2->boneCount == 0 || anim2->framePoses == NULL ||
model->boneCount == 0 || model->bindPose == NULL)
{
return;
}
// Clamp blend factor to [0, 1]
blendFactor = fminf(1.0f, fmaxf(0.0f, blendFactor));
// Ensure frame indices are valid
if (frame1 >= anim1->frameCount) frame1 = anim1->frameCount - 1;
if (frame2 >= anim2->frameCount) frame2 = anim2->frameCount - 1;
if (frame1 < 0) frame1 = 0;
if (frame2 < 0) frame2 = 0;
// Find first mesh with bones
int firstMeshWithBones = -1;
for (int i = 0; i < model->meshCount; i++)
{
if (model->meshes[i].boneMatrices)
{
firstMeshWithBones = i;
break;
}
}
if (firstMeshWithBones == -1) return;
// Get bone count (use minimum of all to be safe)
int boneCount = model->boneCount;
if (anim1->boneCount < boneCount) boneCount = anim1->boneCount;
if (anim2->boneCount < boneCount) boneCount = anim2->boneCount;
// Blend each bone
for (int boneId = 0; boneId < boneCount; boneId++)
{
// Determine blend factor for this bone
float boneBlendFactor = blendFactor;
// If upper body blending is enabled, use different blend factors for upper vs lower body
if (upperBodyBlend)
{
const char *boneName = model->bones[boneId].name;
bool isUpperBody = IsUpperBodyBone(boneName);
// Upper body: use anim2 (attack), Lower body: use anim1 (walk)
// blendFactor = 0.0 means full anim1 (walk), 1.0 means full anim2 (attack)
if (isUpperBody) boneBlendFactor = blendFactor; // Upper body: blend towards anim2 (attack)
else boneBlendFactor = 1.0f - blendFactor; // Lower body: blend towards anim1 (walk) - invert the blend
}
// Get transforms from both animations
Transform *bindTransform = &model->bindPose[boneId];
Transform *anim1Transform = &anim1->framePoses[frame1][boneId];
Transform *anim2Transform = &anim2->framePoses[frame2][boneId];
// Blend the transforms
Transform blended;
blended.translation = Vector3Lerp(anim1Transform->translation, anim2Transform->translation, boneBlendFactor);
blended.rotation = QuaternionSlerp(anim1Transform->rotation, anim2Transform->rotation, boneBlendFactor);
blended.scale = Vector3Lerp(anim1Transform->scale, anim2Transform->scale, boneBlendFactor);
// Convert bind pose to matrix
Matrix bindMatrix = MatrixMultiply(MatrixMultiply(
MatrixScale(bindTransform->scale.x, bindTransform->scale.y, bindTransform->scale.z),
QuaternionToMatrix(bindTransform->rotation)),
MatrixTranslate(bindTransform->translation.x, bindTransform->translation.y, bindTransform->translation.z));
// Convert blended transform to matrix
Matrix blendedMatrix = MatrixMultiply(MatrixMultiply(
MatrixScale(blended.scale.x, blended.scale.y, blended.scale.z),
QuaternionToMatrix(blended.rotation)),
MatrixTranslate(blended.translation.x, blended.translation.y, blended.translation.z));
// Calculate final bone matrix (similar to UpdateModelAnimationBones)
model->meshes[firstMeshWithBones].boneMatrices[boneId] = MatrixMultiply(MatrixInvert(bindMatrix), blendedMatrix);
}
// Copy bone matrices to remaining meshes
for (int i = firstMeshWithBones + 1; i < model->meshCount; i++)
{
if (model->meshes[i].boneMatrices)
{
memcpy(model->meshes[i].boneMatrices,
model->meshes[firstMeshWithBones].boneMatrices,
model->meshes[i].boneCount*sizeof(model->meshes[i].boneMatrices[0]));
}
}
}

View File

@ -17,7 +17,9 @@
********************************************************************************************/
#include "raylib.h"
#include "raymath.h"
#include <stdlib.h>
//------------------------------------------------------------------------------------

6043
examples/models/raygui.h Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -219,8 +219,9 @@ void ToggleFullscreen(void)
// and considered by GetWindowScaleDPI()
FLAG_CLEAR(CORE.Window.flags, FLAG_FULLSCREEN_MODE);
#if !defined(__APPLE__)
#if !defined(__APPLE__) && !defined(_GLFW_WAYLAND)
// Make sure to restore render size considering HighDPI scaling
// NOTE: On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling, skip manual resize
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
Vector2 scaleDpi = GetWindowScaleDPI();
@ -298,8 +299,9 @@ void ToggleBorderlessWindowed(void)
glfwSetWindowAttrib(platform.handle, GLFW_DECORATED, GLFW_TRUE);
FLAG_CLEAR(CORE.Window.flags, FLAG_WINDOW_UNDECORATED);
#if !defined(__APPLE__)
#if !defined(__APPLE__) && !defined(_GLFW_WAYLAND)
// Make sure to restore size considering HighDPI scaling
// NOTE: On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling, skip manual resize
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
Vector2 scaleDpi = GetWindowScaleDPI();
@ -1464,6 +1466,11 @@ int InitPlatform(void)
glfwWindowHint(GLFW_SCALE_TO_MONITOR, GLFW_FALSE);
#if defined(__APPLE__)
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
#endif
#if defined(_GLFW_WAYLAND) && !defined(_GLFW_X11)
// GLFW 3.4+ defaults GLFW_SCALE_FRAMEBUFFER to TRUE,
// causing framebuffer/window size mismatch on Wayland with display scaling
glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_FALSE);
#endif
}
@ -1663,15 +1670,26 @@ int InitPlatform(void)
// NOTE: On APPLE platforms system manage window and input scaling
// Framebuffer scaling is activated with: glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_TRUE);
// Screen scaling matrix is required in case desired screen area is different from display area
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
#if !defined(__APPLE__)
// Mouse input scaling for the new screen size
SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
if (glfwGetPlatform() == GLFW_PLATFORM_WAYLAND)
{
// On Wayland, GLFW_SCALE_FRAMEBUFFER handles scaling; read actual framebuffer size
// instead of resizing the window (which would double-scale)
int fbWidth = 0;
int fbHeight = 0;
glfwGetFramebufferSize(platform.handle, &fbWidth, &fbHeight);
// Force window size (and framebuffer) refresh
glfwSetWindowSize(platform.handle, CORE.Window.render.width, CORE.Window.render.height);
CORE.Window.render.width = fbWidth;
CORE.Window.render.height = fbHeight;
}
else
{
// Mouse input scaling for the new screen size
SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
// Force window size (and framebuffer) refresh
glfwSetWindowSize(platform.handle, CORE.Window.render.width, CORE.Window.render.height);
}
#endif
}
else CORE.Window.render = CORE.Window.screen;
@ -1855,6 +1873,26 @@ static void FramebufferSizeCallback(GLFWwindow *window, int width, int height)
CORE.Window.screen.height = height;
CORE.Window.screenScale = MatrixScale(1.0f, 1.0f, 1.0f);
SetMouseScale(1.0f, 1.0f);
// On Wayland with GLFW_SCALE_FRAMEBUFFER, the framebuffer is still scaled in fullscreen, use logical window size as screen and apply screenScale
#if defined(_GLFW_WAYLAND) && !defined(_GLFW_X11)
if (FLAG_IS_SET(CORE.Window.flags, FLAG_WINDOW_HIGHDPI))
{
int winWidth = 0;
int winHeight = 0;
glfwGetWindowSize(platform.handle, &winWidth, &winHeight);
if ((winWidth != width) || (winHeight != height))
{
CORE.Window.screen.width = winWidth;
CORE.Window.screen.height = winHeight;
float scaleX = (float)width/winWidth;
float scaleY = (float)height/winHeight;
CORE.Window.screenScale = MatrixScale(scaleX, scaleY, 1.0f);
}
}
#endif
}
else // Window mode (including borderless window)
{
@ -1866,8 +1904,8 @@ static void FramebufferSizeCallback(GLFWwindow *window, int width, int height)
CORE.Window.screen.width = (int)((float)width/scaleDpi.x);
CORE.Window.screen.height = (int)((float)height/scaleDpi.y);
CORE.Window.screenScale = MatrixScale(scaleDpi.x, scaleDpi.y, 1.0f);
#if !defined(__APPLE__)
// Mouse input scaling for the new screen size
#if !defined(__APPLE__) && !defined(_GLFW_WAYLAND)
// On macOS and Linux-Wayland, mouse coords are already in logical space
SetMouseScale(1.0f/scaleDpi.x, 1.0f/scaleDpi.y);
#endif
}
@ -1896,8 +1934,8 @@ static void WindowContentScaleCallback(GLFWwindow *window, float scalex, float s
// Framebuffer scaling is activated with: glfwWindowHint(GLFW_SCALE_FRAMEBUFFER, GLFW_TRUE);
CORE.Window.screenScale = MatrixScale(scalex, scaley, 1.0f);
#if !defined(__APPLE__)
// Mouse input scaling for the new screen size
#if !defined(__APPLE__) && !defined(_GLFW_WAYLAND)
// On macOS and Linux-Wayland, mouse coords are already in logical space
SetMouseScale(1.0f/scalex, 1.0f/scaley);
#endif
}

View File

@ -682,8 +682,6 @@ void InitWindow(int width, int height, const char *title)
// Initialize window data
CORE.Window.screen.width = width;
CORE.Window.screen.height = height;
CORE.Window.currentFbo.width = CORE.Window.screen.width;
CORE.Window.currentFbo.height = CORE.Window.screen.height;
CORE.Window.eventWaiting = false;
CORE.Window.screenScale = MatrixIdentity(); // No draw scaling required by default
@ -709,10 +707,10 @@ void InitWindow(int width, int height, const char *title)
// Initialize rlgl default data (buffers and shaders)
// NOTE: Current fbo size stored as globals in rlgl for convenience
rlglInit(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height);
rlglInit(CORE.Window.render.width, CORE.Window.render.height);
// Setup default viewport
SetupViewport(CORE.Window.currentFbo.width, CORE.Window.currentFbo.height);
SetupViewport(CORE.Window.render.width, CORE.Window.render.height);
#if defined(SUPPORT_MODULE_RTEXT)
#if defined(SUPPORT_DEFAULT_FONT)
@ -2775,6 +2773,8 @@ FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool
if (DirectoryExists(basePath)) // It's a directory
{
if ((filter != NULL) && (filter[0] == '\0')) filter = NULL;
// SCAN 1: Count files
unsigned int fileCounter = GetDirectoryFileCountEx(basePath, filter, scanSubdirs);

View File

@ -5373,6 +5373,7 @@ static Model LoadGLTF(const char *fileName)
if (result != cgltf_result_success) TRACELOG(LOG_INFO, "MODEL: [%s] Failed to load mesh/material buffers", fileName);
int primitivesCount = 0;
bool dracoCompression = false;
// NOTE: We will load every primitive in the glTF as a separate raylib Mesh
// Determine total number of meshes needed from the node hierarchy
@ -5384,9 +5385,22 @@ static Model LoadGLTF(const char *fileName)
for (unsigned int p = 0; p < mesh->primitives_count; p++)
{
if (mesh->primitives[p].type == cgltf_primitive_type_triangles) primitivesCount++;
if (mesh->primitives[p].has_draco_mesh_compression)
{
dracoCompression = true;
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load mesh data, Draco compression not supported", fileName);
break;
}
else if (mesh->primitives[p].type == cgltf_primitive_type_triangles) primitivesCount++;
}
}
if (dracoCompression)
{
return model;
TRACELOG(LOG_WARNING, "MODEL: [%s] Failed to load glTF data", fileName);
}
TRACELOG(LOG_DEBUG, " > Primitives (triangles only) count based on hierarchy : %i", primitivesCount);
// Load our model data: meshes and materials