Merge branch 'raysan5:master' into rlsw

This commit is contained in:
Le Juez Victor 2025-05-09 12:02:36 +02:00 committed by GitHub
commit 6059705a0d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 85 additions and 16 deletions

View File

@ -205,7 +205,7 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
raylib.root_module.addCMacro("PLATFORM_DRM", "");
raylib.root_module.addCMacro("EGL_NO_X11", "");
raylib.root_module.addCMacro("DEFAULT_BATCH_BUFFER_ELEMENT", "");
} else if (target.result.abi == .android) {
} else if (target.result.abi.isAndroid()) {
//these are the only tag options per https://developer.android.com/ndk/guides/other_build_systems
const hostTuple = switch (builtin.target.os.tag) {
@ -215,7 +215,14 @@ fn compileRaylib(b: *std.Build, target: std.Build.ResolvedTarget, optimize: std.
else => @panic("unsupported host OS"),
};
const androidTriple = try target.result.linuxTriple(b.allocator);
const androidTriple = switch (target.result.cpu.arch) {
.x86 => "i686-linux-android",
.x86_64 => "x86_64-linux-android",
.arm => "arm-linux-androideabi",
.aarch64 => "aarch64-linux-android",
.riscv64 => "riscv64-linux-android",
else => error.InvalidAndroidTarget,
} catch @panic("invalid android target!");
const androidNdkPathString: []const u8 = options.android_ndk;
if (androidNdkPathString.len < 1) @panic("no ndk path provided and ANDROID_NDK_HOME is not set");
const androidApiLevel: []const u8 = options.android_api_version;

View File

@ -90,7 +90,7 @@
#define RPRAND_FREE(ptr) free(ptr)
#endif
// Simple log system to avoid RPNG_LOG() calls if required
// Simple log system to avoid log calls if required
// NOTE: Avoiding those calls, also avoids const strings memory usage
#define RPRAND_SHOW_LOG_INFO
#if defined(RPNG_SHOW_LOG_INFO)

View File

@ -2314,9 +2314,12 @@ FilePathList LoadDirectoryFilesEx(const char *basePath, const char *filter, bool
// WARNING: files.count is not reseted to 0 after unloading
void UnloadDirectoryFiles(FilePathList files)
{
if (files.paths != NULL)
{
for (unsigned int i = 0; i < files.capacity; i++) RL_FREE(files.paths[i]);
RL_FREE(files.paths);
}
}
// Create directories (including full path requested), returns 0 on success
@ -3738,7 +3741,7 @@ static void ScanDirectoryFiles(const char *basePath, FilePathList *files, const
// Scan all files and directories recursively from a base path
static void ScanDirectoryFilesRecursively(const char *basePath, FilePathList *files, const char *filter)
{
char path[MAX_FILEPATH_LENGTH] = { 0 };
static char path[MAX_FILEPATH_LENGTH] = { 0 };
memset(path, 0, MAX_FILEPATH_LENGTH);
struct dirent *dp = NULL;

View File

@ -56,8 +56,8 @@
*
* #define RL_MAX_MATRIX_STACK_SIZE 32 // Maximum size of internal Matrix stack
* #define RL_MAX_SHADER_LOCATIONS 32 // Maximum number of shader locations supported
* #define RL_CULL_DISTANCE_NEAR 0.001 // Default projection matrix near cull distance
* #define RL_CULL_DISTANCE_FAR 10000.0 // Default projection matrix far cull distance
* #define RL_CULL_DISTANCE_NEAR 0.05 // Default projection matrix near cull distance
* #define RL_CULL_DISTANCE_FAR 4000.0 // Default projection matrix far cull distance
*
* When loading a shader, the following vertex attributes and uniform
* location names are tried to be set automatically:
@ -239,10 +239,10 @@
// Projection matrix culling
#ifndef RL_CULL_DISTANCE_NEAR
#define RL_CULL_DISTANCE_NEAR 0.001 // Default near cull distance
#define RL_CULL_DISTANCE_NEAR 0.05 // Default near cull distance
#endif
#ifndef RL_CULL_DISTANCE_FAR
#define RL_CULL_DISTANCE_FAR 10000.0 // Default far cull distance
#define RL_CULL_DISTANCE_FAR 4000.0 // Default far cull distance
#endif
// Texture parameters (equivalent to OpenGL defines)

View File

@ -496,12 +496,18 @@ void DrawSphereEx(Vector3 centerPos, float radius, int rings, int slices, Color
vertices[2] = (Vector3){ cosslice*vertices[2].x - sinslice*vertices[2].z, vertices[2].y, sinslice*vertices[2].x + cosslice*vertices[2].z }; // Rotation matrix around y axis
vertices[3] = (Vector3){ cosslice*vertices[3].x - sinslice*vertices[3].z, vertices[3].y, sinslice*vertices[3].x + cosslice*vertices[3].z };
rlNormal3f(vertices[0].x, vertices[0].y, vertices[0].z);
rlVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);
rlNormal3f(vertices[3].x, vertices[3].y, vertices[3].z);
rlVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);
rlNormal3f(vertices[1].x, vertices[1].y, vertices[1].z);
rlVertex3f(vertices[1].x, vertices[1].y, vertices[1].z);
rlNormal3f(vertices[0].x, vertices[0].y, vertices[0].z);
rlVertex3f(vertices[0].x, vertices[0].y, vertices[0].z);
rlNormal3f(vertices[2].x, vertices[2].y, vertices[2].z);
rlVertex3f(vertices[2].x, vertices[2].y, vertices[2].z);
rlNormal3f(vertices[3].x, vertices[3].y, vertices[3].z);
rlVertex3f(vertices[3].x, vertices[3].y, vertices[3].z);
}
@ -1423,9 +1429,17 @@ void DrawMesh(Mesh mesh, Material material, Matrix transform)
rlEnableTexture(material.maps[MATERIAL_MAP_DIFFUSE].texture.id);
if (mesh.animVertices)
rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.animVertices);
else
rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.vertices);
rlEnableStatePointer(GL_TEXTURE_COORD_ARRAY, mesh.texcoords);
if (mesh.normals)
rlEnableStatePointer(GL_VERTEX_ARRAY, mesh.animNormalss);
else
rlEnableStatePointer(GL_NORMAL_ARRAY, mesh.normals);
rlEnableStatePointer(GL_COLOR_ARRAY, mesh.colors);
rlPushMatrix();
@ -5815,15 +5829,17 @@ static Model LoadGLTF(const char *fileName)
for (unsigned int p = 0; p < mesh->primitives_count; p++)
{
bool hasJoints = false;
// NOTE: We only support primitives defined by triangles
if (mesh->primitives[p].type != cgltf_primitive_type_triangles) continue;
for (unsigned int j = 0; j < mesh->primitives[p].attributes_count; j++)
{
// NOTE: JOINTS_1 + WEIGHT_1 will be used for +4 joints influencing a vertex -> Not supported by raylib
if (mesh->primitives[p].attributes[j].type == cgltf_attribute_type_joints) // JOINTS_n (vec4: 4 bones max per vertex / u8, u16)
{
hasJoints = true;
cgltf_accessor *attribute = mesh->primitives[p].attributes[j].data;
// NOTE: JOINTS_n can only be vec4 and u8/u16
@ -5924,6 +5940,34 @@ static Model LoadGLTF(const char *fileName)
}
}
// check if we are animated, and the mesh was not given any bone assignments, but is the child of a bone node
// in this case we need to fully attach all the verts to the parent bone so it will animate with the bone.
if (data->skins_count > 0 && !hasJoints && node->parent != NULL && node->parent->mesh == NULL)
{
int parentBoneId = -1;
for (int joint = 0; joint < model.boneCount; joint++)
{
if (data->skins[0].joints[joint] == node->parent)
{
parentBoneId = joint;
break;
}
}
if (parentBoneId >= 0)
{
model.meshes[meshIndex].boneIds = RL_CALLOC(model.meshes[meshIndex].vertexCount * 4, sizeof(unsigned char));
model.meshes[meshIndex].boneWeights = RL_CALLOC(model.meshes[meshIndex].vertexCount * 4, sizeof(float));
for (int vertexIndex = 0; vertexIndex < model.meshes[meshIndex].vertexCount * 4; vertexIndex += 4)
{
model.meshes[meshIndex].boneIds[vertexIndex] = (unsigned char)parentBoneId;
model.meshes[meshIndex].boneWeights[vertexIndex] = 1.0f;
}
}
}
// Animated vertex data
model.meshes[meshIndex].animVertices = RL_CALLOC(model.meshes[meshIndex].vertexCount*3, sizeof(float));
memcpy(model.meshes[meshIndex].animVertices, model.meshes[meshIndex].vertices, model.meshes[meshIndex].vertexCount*3*sizeof(float));

View File

@ -161,6 +161,10 @@ extern void LoadFontDefault(void)
{
#define BIT_CHECK(a,b) ((a) & (1u << (b)))
// check to see if we have allready allocated the font for an image, and if we don't need to upload, then just return
if (defaultFont.glyphs != NULL && !isGpuReady)
return;
// NOTE: Using UTF-8 encoding table for Unicode U+0000..U+00FF Basic Latin + Latin-1 Supplement
// Ref: http://www.utf8-chartable.de/unicode-utf8-table.pl
@ -257,7 +261,18 @@ extern void LoadFontDefault(void)
counter++;
}
if (isGpuReady) defaultFont.texture = LoadTextureFromImage(imFont);
if (isGpuReady)
{
defaultFont.texture = LoadTextureFromImage(imFont);
// we have already loaded the font glyph data an image, and the GPU is ready, we are done
// if we don't do this, we will leak memory by reallocating the glyphs and rects
if (defaultFont.glyphs != NULL)
{
UnloadImage(imFont);
return;
}
}
// Reconstruct charSet using charsWidth[], charsHeight, charsDivisor, glyphCount
//------------------------------------------------------------------------------
@ -282,7 +297,7 @@ extern void LoadFontDefault(void)
testPosX += (int)(defaultFont.recs[i].width + (float)charsDivisor);
if (testPosX >= defaultFont.texture.width)
if (testPosX >= imFont.width)
{
currentLine++;
currentPosX = 2*charsDivisor + charsWidth[i];