diff --git a/bindings.json b/bindings.json index 3b3a395..d6c98b7 100644 --- a/bindings.json +++ b/bindings.json @@ -887,10 +887,10 @@ "custom": false }, { - "name": "GetMouseRay", + "name": "GetScreenToWorldRay", "params": [ { - "name": "mousePosition", + "name": "position", "typ": "Vector2" }, { @@ -899,35 +899,51 @@ } ], "returnType": "Ray", - "description": "Get a ray trace from mouse position", + "description": "Get a ray trace from screen position (i.e mouse)", "custom": false }, { - "name": "GetCameraMatrix", + "name": "GetScreenToWorldRayEx", "params": [ + { + "name": "position", + "typ": "Vector2" + }, { "name": "camera", "typ": "Camera3D" + }, + { + "name": "width", + "typ": "f32" + }, + { + "name": "height", + "typ": "f32" } ], - "returnType": "Matrix", - "description": "Get camera transform matrix (view matrix)", + "returnType": "Ray", + "description": "Get a ray trace from screen position (i.e mouse) in a viewport", "custom": false }, { - "name": "GetCameraMatrix2D", + "name": "GetWorldToScreen", "params": [ + { + "name": "position", + "typ": "Vector3" + }, { "name": "camera", - "typ": "Camera2D" + "typ": "Camera3D" } ], - "returnType": "Matrix", - "description": "Get camera 2d transform matrix", + "returnType": "Vector2", + "description": "Get the screen space position for a 3d world space position", "custom": false }, { - "name": "GetWorldToScreen", + "name": "GetWorldToScreenEx", "params": [ { "name": "position", @@ -936,14 +952,22 @@ { "name": "camera", "typ": "Camera3D" + }, + { + "name": "width", + "typ": "i32" + }, + { + "name": "height", + "typ": "i32" } ], "returnType": "Vector2", - "description": "Get the screen space position for a 3d world space position", + "description": "Get size position for a 3d world space position", "custom": false }, { - "name": "GetScreenToWorld2D", + "name": "GetWorldToScreen2D", "params": [ { "name": "position", @@ -955,47 +979,47 @@ } ], "returnType": "Vector2", - "description": "Get the world space position for a 2d camera screen space position", + "description": "Get the screen space position for a 2d camera world space position", "custom": false }, { - "name": "GetWorldToScreenEx", + "name": "GetScreenToWorld2D", "params": [ { "name": "position", - "typ": "Vector3" + "typ": "Vector2" }, { "name": "camera", - "typ": "Camera3D" - }, - { - "name": "width", - "typ": "i32" - }, - { - "name": "height", - "typ": "i32" + "typ": "Camera2D" } ], "returnType": "Vector2", - "description": "Get size position for a 3d world space position", + "description": "Get the world space position for a 2d camera screen space position", "custom": false }, { - "name": "GetWorldToScreen2D", + "name": "GetCameraMatrix", "params": [ { - "name": "position", - "typ": "Vector2" - }, + "name": "camera", + "typ": "Camera3D" + } + ], + "returnType": "Matrix", + "description": "Get camera transform matrix (view matrix)", + "custom": false + }, + { + "name": "GetCameraMatrix2D", + "params": [ { "name": "camera", "typ": "Camera2D" } ], - "returnType": "Vector2", - "description": "Get the screen space position for a 2d camera world space position", + "returnType": "Matrix", + "description": "Get camera 2d transform matrix", "custom": false }, { @@ -2008,6 +2032,26 @@ "description": "Set internal gamepad mappings (SDL_GameControllerDB)", "custom": false }, + { + "name": "SetGamepadVibration", + "params": [ + { + "name": "gamepad", + "typ": "i32" + }, + { + "name": "leftMotor", + "typ": "f32" + }, + { + "name": "rightMotor", + "typ": "f32" + } + ], + "returnType": "void", + "description": "Set gamepad vibration for both motors", + "custom": false + }, { "name": "IsMouseButtonPressed", "params": [ @@ -5642,6 +5686,22 @@ "description": "Draws a texture (or part of it) that stretches or shrinks nicely", "custom": false }, + { + "name": "ColorIsEqual", + "params": [ + { + "name": "col1", + "typ": "Color" + }, + { + "name": "col2", + "typ": "Color" + } + ], + "returnType": "bool", + "description": "Check if two colors are equal", + "custom": false + }, { "name": "Fade", "params": [ @@ -5667,7 +5727,7 @@ } ], "returnType": "i32", - "description": "Get hexadecimal value for a Color", + "description": "Get hexadecimal value for a Color (0xRRGGBBAA)", "custom": false }, { @@ -9789,6 +9849,13 @@ "description": "Disable render texture (fbo), return to default framebuffer", "custom": false }, + { + "name": "rlGetActiveFramebuffer", + "params": [], + "returnType": "u32", + "description": "Get the currently active render texture (fbo), 0 for default framebuffer", + "custom": false + }, { "name": "rlActiveDrawBuffers", "params": [ @@ -10829,16 +10896,7 @@ }, { "name": "rlLoadFramebuffer", - "params": [ - { - "name": "width", - "typ": "i32" - }, - { - "name": "height", - "typ": "i32" - } - ], + "params": [], "returnType": "u32", "description": "Load an empty framebuffer", "custom": false @@ -11800,6 +11858,38 @@ "description": "", "custom": false }, + { + "name": "Vector2Min", + "params": [ + { + "name": "v1", + "typ": "Vector2" + }, + { + "name": "v2", + "typ": "Vector2" + } + ], + "returnType": "Vector2", + "description": "", + "custom": false + }, + { + "name": "Vector2Max", + "params": [ + { + "name": "v1", + "typ": "Vector2" + }, + { + "name": "v2", + "typ": "Vector2" + } + ], + "returnType": "Vector2", + "description": "", + "custom": false + }, { "name": "Vector2Rotate", "params": [ @@ -11904,6 +11994,26 @@ "description": "", "custom": false }, + { + "name": "Vector2Refract", + "params": [ + { + "name": "v", + "typ": "Vector2" + }, + { + "name": "n", + "typ": "Vector2" + }, + { + "name": "r", + "typ": "f32" + } + ], + "returnType": "Vector2", + "description": "", + "custom": false + }, { "name": "Vector3Zero", "params": [], @@ -12270,6 +12380,26 @@ "description": "", "custom": false }, + { + "name": "Vector3MoveTowards", + "params": [ + { + "name": "v", + "typ": "Vector3" + }, + { + "name": "target", + "typ": "Vector3" + }, + { + "name": "maxDistance", + "typ": "f32" + } + ], + "returnType": "Vector3", + "description": "", + "custom": false + }, { "name": "Vector3Lerp", "params": [ @@ -12482,6 +12612,328 @@ "description": "", "custom": false }, + { + "name": "Vector4Zero", + "params": [], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4One", + "params": [], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Add", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4AddValue", + "params": [ + { + "name": "v", + "typ": "Vector4" + }, + { + "name": "add", + "typ": "f32" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Subtract", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4SubtractValue", + "params": [ + { + "name": "v", + "typ": "Vector4" + }, + { + "name": "add", + "typ": "f32" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Length", + "params": [ + { + "name": "v", + "typ": "Vector4" + } + ], + "returnType": "f32", + "description": "", + "custom": false + }, + { + "name": "Vector4LengthSqr", + "params": [ + { + "name": "v", + "typ": "Vector4" + } + ], + "returnType": "f32", + "description": "", + "custom": false + }, + { + "name": "Vector4DotProduct", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "f32", + "description": "", + "custom": false + }, + { + "name": "Vector4Distance", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "f32", + "description": "", + "custom": false + }, + { + "name": "Vector4DistanceSqr", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "f32", + "description": "", + "custom": false + }, + { + "name": "Vector4Scale", + "params": [ + { + "name": "v", + "typ": "Vector4" + }, + { + "name": "scale", + "typ": "f32" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Multiply", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Negate", + "params": [ + { + "name": "v", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Divide", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Normalize", + "params": [ + { + "name": "v", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Min", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Max", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Lerp", + "params": [ + { + "name": "v1", + "typ": "Vector4" + }, + { + "name": "v2", + "typ": "Vector4" + }, + { + "name": "amount", + "typ": "f32" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4MoveTowards", + "params": [ + { + "name": "v", + "typ": "Vector4" + }, + { + "name": "target", + "typ": "Vector4" + }, + { + "name": "maxDistance", + "typ": "f32" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Invert", + "params": [ + { + "name": "v", + "typ": "Vector4" + } + ], + "returnType": "Vector4", + "description": "", + "custom": false + }, + { + "name": "Vector4Equals", + "params": [ + { + "name": "p", + "typ": "Vector4" + }, + { + "name": "q", + "typ": "Vector4" + } + ], + "returnType": "i32", + "description": "", + "custom": false + }, { "name": "MatrixDeterminant", "params": [ @@ -14024,7 +14476,7 @@ { "name": "GAMEPAD_BUTTON_RIGHT_FACE_RIGHT", "value": 6, - "description": "Gamepad right button right (i.e. PS3: Square, Xbox: X)" + "description": "Gamepad right button right (i.e. PS3: Circle, Xbox: B)" }, { "name": "GAMEPAD_BUTTON_RIGHT_FACE_DOWN", @@ -14034,7 +14486,7 @@ { "name": "GAMEPAD_BUTTON_RIGHT_FACE_LEFT", "value": 8, - "description": "Gamepad right button left (i.e. PS3: Circle, Xbox: B)" + "description": "Gamepad right button left (i.e. PS3: Square, Xbox: X)" }, { "name": "GAMEPAD_BUTTON_LEFT_TRIGGER_1", @@ -16869,7 +17321,7 @@ { "name": "PI", "typ": "f32", - "value": "3.14159265358979323846", + "value": "3.141592653589793e0", "description": "", "custom": false }, @@ -17107,14 +17559,14 @@ { "name": "RL_CULL_DISTANCE_NEAR", "typ": "f64", - "value": "0.01", + "value": "1e-2", "description": "Default near cull distance", "custom": false }, { "name": "RL_CULL_DISTANCE_FAR", "typ": "f64", - "value": "1000.0", + "value": "1e3", "description": "Default far cull distance", "custom": false }, @@ -17678,6 +18130,20 @@ "description": "", "custom": false }, + { + "name": "GL_PROGRAM_POINT_SIZE", + "typ": "i32", + "value": "34370", + "description": "", + "custom": false + }, + { + "name": "GL_LINE_WIDTH", + "typ": "i32", + "value": "2849", + "description": "", + "custom": false + }, { "name": "GL_UNSIGNED_SHORT_5_6_5", "typ": "i32", @@ -17821,7 +18287,7 @@ { "name": "EPSILON", "typ": "f32", - "value": "0.000001", + "value": "1e-6", "description": "", "custom": false } diff --git a/build.zig b/build.zig index 8eb0cca..a1228df 100644 --- a/build.zig +++ b/build.zig @@ -10,7 +10,7 @@ pub fn build(b: *std.Build) !void { const jsons = b.step("parse", "parse raylib headers and generate raylib jsons"); const raylib_parser_build = b.addExecutable(.{ .name = "raylib_parser", - .root_source_file = std.build.FileSource.relative("raylib_parser.zig"), + .root_source_file = std.Build.LazyPath.relative("raylib_parser.zig"), .target = target, .optimize = .ReleaseFast, }); @@ -51,7 +51,7 @@ pub fn build(b: *std.Build) !void { const intermediate = b.step("intermediate", "generate intermediate representation of the results from 'zig build parse' (keep custom=true)"); var intermediateZigStep = b.addRunArtifact(b.addExecutable(.{ .name = "intermediate", - .root_source_file = std.build.FileSource.relative("intermediate.zig"), + .root_source_file = std.Build.LazyPath.relative("intermediate.zig"), .target = target, })); intermediate.dependOn(&intermediateZigStep.step); @@ -60,7 +60,7 @@ pub fn build(b: *std.Build) !void { const bindings = b.step("bindings", "generate bindings in from bindings.json"); var generateZigStep = b.addRunArtifact(b.addExecutable(.{ .name = "generate", - .root_source_file = std.build.FileSource.relative("generate.zig"), + .root_source_file = std.Build.LazyPath.relative("generate.zig"), .target = target, })); const fmt = b.addFmt(.{ .paths = &.{generate.outputFile} }); @@ -87,27 +87,37 @@ const dir_raylib = cwd ++ sep ++ "raylib" ++ sep ++ "src"; const raylib_build = @import("raylib/src/build.zig"); fn linkThisLibrary(b: *std.Build, target: std.Target.Query, optimize: std.builtin.Mode) *std.Build.Step.Compile { - const lib = b.addStaticLibrary(.{ .name = "raylib.zig", .target = b.resolveTargetQuery(target), .optimize = optimize }); + const lib = b.addStaticLibrary( + .{ + .name = "raylib.zig", + .target = b.resolveTargetQuery(target), + .optimize = optimize, + .root_source_file = .{ .path = cwd ++ sep ++ "raylib.zig" }, + }, + ); + lib.linkLibC(); lib.addIncludePath(.{ .path = dir_raylib }); lib.addIncludePath(.{ .path = cwd }); - lib.linkLibC(); lib.addCSourceFile(.{ .file = .{ .path = cwd ++ sep ++ "marshal.c" }, .flags = &.{} }); - std.log.info("include '{s}' to {s}", .{ dir_raylib, lib.name }); - std.log.info("include '{s}' to {s}", .{ cwd, lib.name }); + std.log.debug("include '{s}' to {s}", .{ dir_raylib, lib.name }); + std.log.debug("include '{s}' to {s}", .{ cwd, lib.name }); return lib; } /// add this package to exe pub fn addTo(b: *std.Build, exe: *std.Build.Step.Compile, target: std.Target.Query, optimize: std.builtin.Mode, raylibOptions: raylib_build.Options) void { - exe.root_module.addAnonymousImport("raylib", .{ .root_source_file = .{ .path = cwd ++ sep ++ "raylib.zig" } }); - std.log.info("include '{s}' to {s}", .{ dir_raylib, exe.name }); - std.log.info("include '{s}' to {s}", .{ cwd, exe.name }); - exe.addIncludePath(.{ .path = dir_raylib }); - exe.addIncludePath(.{ .path = cwd }); + const lib_raylib = raylib_build.addRaylib( + b, + b.resolveTargetQuery(target), + optimize, + raylibOptions, + ) catch |err| std.debug.panic("addRaylib: {any}", .{err}); + const lib = linkThisLibrary(b, target, optimize); - const lib_raylib = raylib_build.addRaylib(b, b.resolveTargetQuery(target), optimize, raylibOptions) catch |err| std.debug.panic("addRaylib: {any}", .{err}); + + exe.root_module.addImport("raylib", &lib.root_module); + exe.linkLibrary(lib_raylib); - exe.linkLibrary(lib); std.log.info("linked raylib.zig", .{}); } diff --git a/generate.zig b/generate.zig index 3071531..c3c45ea 100644 --- a/generate.zig +++ b/generate.zig @@ -176,7 +176,7 @@ fn writeFunctions( //--- body ------------------------------ if (isPointer(func.returnType)) { - try file.writeAll(try allocPrint(allocator, "return @ptrCast({s},\n", .{func.returnType})); + try file.writeAll(try allocPrint(allocator, "return @as({s},@ptrCast(\n", .{func.returnType})); } else if (isPrimitiveOrPointer(func.returnType)) { try file.writeAll("return "); } else if (!returnTypeIsVoid) { @@ -186,9 +186,9 @@ fn writeFunctions( if (!isPrimitiveOrPointer(func.returnType)) { if (bindings.containsStruct(stripType(func.returnType))) { - try file.writeAll(try allocPrint(allocator, "@ptrCast([*c]raylib.{s}, &out),\n", .{func.returnType})); + try file.writeAll(try allocPrint(allocator, "@as([*c]raylib.{s}, @ptrCast(&out)),\n", .{func.returnType})); } else if (!returnTypeIsVoid) { - try file.writeAll(try allocPrint(allocator, "@ptrCast([*c]{s}, &out),\n", .{func.returnType})); + try file.writeAll(try allocPrint(allocator, "@as([*c]{s}, @ptrCast(&out)),\n", .{func.returnType})); } } @@ -196,18 +196,18 @@ fn writeFunctions( if (isFunctionPointer(param.typ)) { try file.writeAll(try allocPrint(allocator, "@ptrCast({s}),\n", .{param.name})); } else if (bindings.containsStruct(stripType(param.typ)) and isPointer(param.typ)) { - try file.writeAll(try allocPrint(allocator, "@intToPtr([*c]raylib.{s}, @ptrToInt({s})),\n", .{ stripType(param.typ), param.name })); + try file.writeAll(try allocPrint(allocator, "@as([*c]raylib.{s}, @ptrFromInt(@intFromPtr({s}))),\n", .{ stripType(param.typ), param.name })); } else if (bindings.containsEnum(param.typ)) { - try file.writeAll(try allocPrint(allocator, "@enumToInt({s}),\n", .{param.name})); + try file.writeAll(try allocPrint(allocator, "@intFromEnum({s}),\n", .{param.name})); } else if (bindings.containsStruct(stripType(param.typ))) { - try file.writeAll(try allocPrint(allocator, "@intToPtr([*c]raylib.{s}, @ptrToInt(&{s})),\n", .{ stripType(param.typ), param.name })); + try file.writeAll(try allocPrint(allocator, "@as([*c]raylib.{s}, @ptrFromInt(@intFromPtr(&{s}))),\n", .{ stripType(param.typ), param.name })); } else if (isPointer(param.typ)) { if (std.mem.endsWith(u8, param.typ, "anyopaque")) { try file.writeAll(try allocPrint(allocator, "{s},\n", .{param.name})); } else if (isConst(param.typ)) { - try file.writeAll(try allocPrint(allocator, "@intToPtr([*c]const {s}, @ptrToInt({s})),\n", .{ stripType(param.typ), param.name })); + try file.writeAll(try allocPrint(allocator, "@as([*c]const {s}, @ptrFromInt(@intFromPtr({s}))),\n", .{ stripType(param.typ), param.name })); } else { - try file.writeAll(try allocPrint(allocator, "@ptrCast([*c]{s}, {s}),\n", .{ stripType(param.typ), param.name })); + try file.writeAll(try allocPrint(allocator, "@as([*c]{s}, @ptrCast({s})),\n", .{ stripType(param.typ), param.name })); } } else { try file.writeAll(try allocPrint(allocator, "{s},\n", .{param.name})); @@ -215,7 +215,7 @@ fn writeFunctions( } if (isPointer(func.returnType)) { - try file.writeAll("),\n);\n"); + try file.writeAll("),\n));\n"); } else { try file.writeAll(");\n"); } diff --git a/marshal.c b/marshal.c index 3894598..113a496 100644 --- a/marshal.c +++ b/marshal.c @@ -413,24 +413,29 @@ void mUnloadShader(Shader *shader) UnloadShader(*shader); } -void mGetMouseRay(Ray *out, Vector2 *mousePosition, Camera3D *camera) +void mGetScreenToWorldRay(Ray *out, Vector2 *position, Camera3D *camera) { - *out = GetMouseRay(*mousePosition, *camera); + *out = GetScreenToWorldRay(*position, *camera); } -void mGetCameraMatrix(Matrix *out, Camera3D *camera) +void mGetScreenToWorldRayEx(Ray *out, Vector2 *position, Camera3D *camera, float width, float height) { - *out = GetCameraMatrix(*camera); + *out = GetScreenToWorldRayEx(*position, *camera, width, height); } -void mGetCameraMatrix2D(Matrix *out, Camera2D *camera) +void mGetWorldToScreen(Vector2 *out, Vector3 *position, Camera3D *camera) { - *out = GetCameraMatrix2D(*camera); + *out = GetWorldToScreen(*position, *camera); } -void mGetWorldToScreen(Vector2 *out, Vector3 *position, Camera3D *camera) +void mGetWorldToScreenEx(Vector2 *out, Vector3 *position, Camera3D *camera, int width, int height) { - *out = GetWorldToScreen(*position, *camera); + *out = GetWorldToScreenEx(*position, *camera, width, height); +} + +void mGetWorldToScreen2D(Vector2 *out, Vector2 *position, Camera2D *camera) +{ + *out = GetWorldToScreen2D(*position, *camera); } void mGetScreenToWorld2D(Vector2 *out, Vector2 *position, Camera2D *camera) @@ -438,14 +443,14 @@ void mGetScreenToWorld2D(Vector2 *out, Vector2 *position, Camera2D *camera) *out = GetScreenToWorld2D(*position, *camera); } -void mGetWorldToScreenEx(Vector2 *out, Vector3 *position, Camera3D *camera, int width, int height) +void mGetCameraMatrix(Matrix *out, Camera3D *camera) { - *out = GetWorldToScreenEx(*position, *camera, width, height); + *out = GetCameraMatrix(*camera); } -void mGetWorldToScreen2D(Vector2 *out, Vector2 *position, Camera2D *camera) +void mGetCameraMatrix2D(Matrix *out, Camera2D *camera) { - *out = GetWorldToScreen2D(*position, *camera); + *out = GetCameraMatrix2D(*camera); } void mSetTargetFPS(int fps) @@ -808,6 +813,11 @@ int mSetGamepadMappings(const char * mappings) return SetGamepadMappings(mappings); } +void mSetGamepadVibration(int gamepad, float leftMotor, float rightMotor) +{ + SetGamepadVibration(gamepad, leftMotor, rightMotor); +} + bool mIsMouseButtonPressed(int button) { return IsMouseButtonPressed(button); @@ -1733,6 +1743,11 @@ void mDrawTextureNPatch(Texture2D *texture, NPatchInfo *nPatchInfo, Rectangle *d DrawTextureNPatch(*texture, *nPatchInfo, *dest, *origin, rotation, *tint); } +bool mColorIsEqual(Color *col1, Color *col2) +{ + return ColorIsEqual(*col1, *col2); +} + void mFade(Color *out, Color *color, float alpha) { *out = Fade(*color, alpha); @@ -2918,6 +2933,11 @@ void mrlDisableFramebuffer(void) rlDisableFramebuffer(); } +unsigned int mrlGetActiveFramebuffer(void) +{ + return rlGetActiveFramebuffer(); +} + void mrlActiveDrawBuffers(int count) { rlActiveDrawBuffers(count); @@ -3288,9 +3308,9 @@ unsigned char * mrlReadScreenPixels(int width, int height) return rlReadScreenPixels(width, height); } -unsigned int mrlLoadFramebuffer(int width, int height) +unsigned int mrlLoadFramebuffer(void) { - return rlLoadFramebuffer(width, height); + return rlLoadFramebuffer(); } void mrlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel) @@ -3598,6 +3618,16 @@ void mVector2Reflect(Vector2 *out, Vector2 *v, Vector2 *normal) *out = Vector2Reflect(*v, *normal); } +void mVector2Min(Vector2 *out, Vector2 *v1, Vector2 *v2) +{ + *out = Vector2Min(*v1, *v2); +} + +void mVector2Max(Vector2 *out, Vector2 *v1, Vector2 *v2) +{ + *out = Vector2Max(*v1, *v2); +} + void mVector2Rotate(Vector2 *out, Vector2 *v, float angle) { *out = Vector2Rotate(*v, angle); @@ -3628,6 +3658,11 @@ int mVector2Equals(Vector2 *p, Vector2 *q) return Vector2Equals(*p, *q); } +void mVector2Refract(Vector2 *out, Vector2 *v, Vector2 *n, float r) +{ + *out = Vector2Refract(*v, *n, r); +} + void mVector3Zero(Vector3 *out) { *out = Vector3Zero(); @@ -3753,6 +3788,11 @@ void mVector3RotateByAxisAngle(Vector3 *out, Vector3 *v, Vector3 *axis, float an *out = Vector3RotateByAxisAngle(*v, *axis, angle); } +void mVector3MoveTowards(Vector3 *out, Vector3 *v, Vector3 *target, float maxDistance) +{ + *out = Vector3MoveTowards(*v, *target, maxDistance); +} + void mVector3Lerp(Vector3 *out, Vector3 *v1, Vector3 *v2, float amount) { *out = Vector3Lerp(*v1, *v2, amount); @@ -3813,6 +3853,116 @@ void mVector3Refract(Vector3 *out, Vector3 *v, Vector3 *n, float r) *out = Vector3Refract(*v, *n, r); } +void mVector4Zero(Vector4 *out) +{ + *out = Vector4Zero(); +} + +void mVector4One(Vector4 *out) +{ + *out = Vector4One(); +} + +void mVector4Add(Vector4 *out, Vector4 *v1, Vector4 *v2) +{ + *out = Vector4Add(*v1, *v2); +} + +void mVector4AddValue(Vector4 *out, Vector4 *v, float add) +{ + *out = Vector4AddValue(*v, add); +} + +void mVector4Subtract(Vector4 *out, Vector4 *v1, Vector4 *v2) +{ + *out = Vector4Subtract(*v1, *v2); +} + +void mVector4SubtractValue(Vector4 *out, Vector4 *v, float add) +{ + *out = Vector4SubtractValue(*v, add); +} + +float mVector4Length(Vector4 *v) +{ + return Vector4Length(*v); +} + +float mVector4LengthSqr(Vector4 *v) +{ + return Vector4LengthSqr(*v); +} + +float mVector4DotProduct(Vector4 *v1, Vector4 *v2) +{ + return Vector4DotProduct(*v1, *v2); +} + +float mVector4Distance(Vector4 *v1, Vector4 *v2) +{ + return Vector4Distance(*v1, *v2); +} + +float mVector4DistanceSqr(Vector4 *v1, Vector4 *v2) +{ + return Vector4DistanceSqr(*v1, *v2); +} + +void mVector4Scale(Vector4 *out, Vector4 *v, float scale) +{ + *out = Vector4Scale(*v, scale); +} + +void mVector4Multiply(Vector4 *out, Vector4 *v1, Vector4 *v2) +{ + *out = Vector4Multiply(*v1, *v2); +} + +void mVector4Negate(Vector4 *out, Vector4 *v) +{ + *out = Vector4Negate(*v); +} + +void mVector4Divide(Vector4 *out, Vector4 *v1, Vector4 *v2) +{ + *out = Vector4Divide(*v1, *v2); +} + +void mVector4Normalize(Vector4 *out, Vector4 *v) +{ + *out = Vector4Normalize(*v); +} + +void mVector4Min(Vector4 *out, Vector4 *v1, Vector4 *v2) +{ + *out = Vector4Min(*v1, *v2); +} + +void mVector4Max(Vector4 *out, Vector4 *v1, Vector4 *v2) +{ + *out = Vector4Max(*v1, *v2); +} + +void mVector4Lerp(Vector4 *out, Vector4 *v1, Vector4 *v2, float amount) +{ + *out = Vector4Lerp(*v1, *v2, amount); +} + +void mVector4MoveTowards(Vector4 *out, Vector4 *v, Vector4 *target, float maxDistance) +{ + *out = Vector4MoveTowards(*v, *target, maxDistance); +} + +void mVector4Invert(Vector4 *out, Vector4 *v) +{ + *out = Vector4Invert(*v); +} + +int mVector4Equals(Vector4 *p, Vector4 *q) +{ + return Vector4Equals(*p, *q); +} + float mMatrixDeterminant(Matrix *mat) { return MatrixDeterminant(*mat); diff --git a/marshal.h b/marshal.h index 5efb6ef..4bac687 100644 --- a/marshal.h +++ b/marshal.h @@ -255,27 +255,30 @@ void mSetShaderValueTexture(Shader *shader, int locIndex, Texture2D *texture); // Unload shader from GPU memory (VRAM) void mUnloadShader(Shader *shader); -// Get a ray trace from mouse position -void mGetMouseRay(Ray *out, Vector2 *mousePosition, Camera3D *camera); +// Get a ray trace from screen position (i.e mouse) +void mGetScreenToWorldRay(Ray *out, Vector2 *position, Camera3D *camera); -// Get camera transform matrix (view matrix) -void mGetCameraMatrix(Matrix *out, Camera3D *camera); - -// Get camera 2d transform matrix -void mGetCameraMatrix2D(Matrix *out, Camera2D *camera); +// Get a ray trace from screen position (i.e mouse) in a viewport +void mGetScreenToWorldRayEx(Ray *out, Vector2 *position, Camera3D *camera, float width, float height); // Get the screen space position for a 3d world space position void mGetWorldToScreen(Vector2 *out, Vector3 *position, Camera3D *camera); -// Get the world space position for a 2d camera screen space position -void mGetScreenToWorld2D(Vector2 *out, Vector2 *position, Camera2D *camera); - // Get size position for a 3d world space position void mGetWorldToScreenEx(Vector2 *out, Vector3 *position, Camera3D *camera, int width, int height); // Get the screen space position for a 2d camera world space position void mGetWorldToScreen2D(Vector2 *out, Vector2 *position, Camera2D *camera); +// Get the world space position for a 2d camera screen space position +void mGetScreenToWorld2D(Vector2 *out, Vector2 *position, Camera2D *camera); + +// Get camera transform matrix (view matrix) +void mGetCameraMatrix(Matrix *out, Camera3D *camera); + +// Get camera 2d transform matrix +void mGetCameraMatrix2D(Matrix *out, Camera2D *camera); + // Set target FPS (maximum) void mSetTargetFPS(int fps); @@ -492,6 +495,9 @@ float mGetGamepadAxisMovement(int gamepad, int axis); // Set internal gamepad mappings (SDL_GameControllerDB) int mSetGamepadMappings(const char * mappings); +// Set gamepad vibration for both motors +void mSetGamepadVibration(int gamepad, float leftMotor, float rightMotor); + // Check if a mouse button has been pressed once bool mIsMouseButtonPressed(int button); @@ -1047,10 +1053,13 @@ void mDrawTexturePro(Texture2D *texture, Rectangle *source, Rectangle *dest, Vec // Draws a texture (or part of it) that stretches or shrinks nicely void mDrawTextureNPatch(Texture2D *texture, NPatchInfo *nPatchInfo, Rectangle *dest, Vector2 *origin, float rotation, Color *tint); +// Check if two colors are equal +bool mColorIsEqual(Color *col1, Color *col2); + // Get color with alpha applied, alpha goes from 0.0f to 1.0f void mFade(Color *out, Color *color, float alpha); -// Get hexadecimal value for a Color +// Get hexadecimal value for a Color (0xRRGGBBAA) int mColorToInt(Color *color); // Get Color normalized as float [0..1] @@ -1758,6 +1767,9 @@ void mrlEnableFramebuffer(unsigned int id); // Disable render texture (fbo), return to default framebuffer void mrlDisableFramebuffer(void); +// Get the currently active render texture (fbo), 0 for default framebuffer +unsigned int mrlGetActiveFramebuffer(void); + // Activate multiple draw color buffers void mrlActiveDrawBuffers(int count); @@ -1981,7 +1993,7 @@ void * mrlReadTexturePixels(unsigned int id, int width, int height, int format); unsigned char * mrlReadScreenPixels(int width, int height); // Load an empty framebuffer -unsigned int mrlLoadFramebuffer(int width, int height); +unsigned int mrlLoadFramebuffer(void); // Attach texture/renderbuffer to a framebuffer void mrlFramebufferAttach(unsigned int fboId, unsigned int texId, int attachType, int texType, int mipLevel); @@ -2166,6 +2178,12 @@ void mVector2Lerp(Vector2 *out, Vector2 *v1, Vector2 *v2, float amount); // void mVector2Reflect(Vector2 *out, Vector2 *v, Vector2 *normal); +// +void mVector2Min(Vector2 *out, Vector2 *v1, Vector2 *v2); + +// +void mVector2Max(Vector2 *out, Vector2 *v1, Vector2 *v2); + // void mVector2Rotate(Vector2 *out, Vector2 *v, float angle); @@ -2184,6 +2202,9 @@ void mVector2ClampValue(Vector2 *out, Vector2 *v, float min, float max); // int mVector2Equals(Vector2 *p, Vector2 *q); +// +void mVector2Refract(Vector2 *out, Vector2 *v, Vector2 *n, float r); + // void mVector3Zero(Vector3 *out); @@ -2259,6 +2280,9 @@ void mVector3RotateByQuaternion(Vector3 *out, Vector3 *v, Vector4 *q); // void mVector3RotateByAxisAngle(Vector3 *out, Vector3 *v, Vector3 *axis, float angle); +// +void mVector3MoveTowards(Vector3 *out, Vector3 *v, Vector3 *target, float maxDistance); + // void mVector3Lerp(Vector3 *out, Vector3 *v1, Vector3 *v2, float amount); @@ -2295,6 +2319,72 @@ int mVector3Equals(Vector3 *p, Vector3 *q); // void mVector3Refract(Vector3 *out, Vector3 *v, Vector3 *n, float r); +// +void mVector4Zero(Vector4 *out); + +// +void mVector4One(Vector4 *out); + +// +void mVector4Add(Vector4 *out, Vector4 *v1, Vector4 *v2); + +// +void mVector4AddValue(Vector4 *out, Vector4 *v, float add); + +// +void mVector4Subtract(Vector4 *out, Vector4 *v1, Vector4 *v2); + +// +void mVector4SubtractValue(Vector4 *out, Vector4 *v, float add); + +// +float mVector4Length(Vector4 *v); + +// +float mVector4LengthSqr(Vector4 *v); + +// +float mVector4DotProduct(Vector4 *v1, Vector4 *v2); + +// +float mVector4Distance(Vector4 *v1, Vector4 *v2); + +// +float mVector4DistanceSqr(Vector4 *v1, Vector4 *v2); + +// +void mVector4Scale(Vector4 *out, Vector4 *v, float scale); + +// +void mVector4Multiply(Vector4 *out, Vector4 *v1, Vector4 *v2); + +// +void mVector4Negate(Vector4 *out, Vector4 *v); + +// +void mVector4Divide(Vector4 *out, Vector4 *v1, Vector4 *v2); + +// +void mVector4Normalize(Vector4 *out, Vector4 *v); + +// +void mVector4Min(Vector4 *out, Vector4 *v1, Vector4 *v2); + +// +void mVector4Max(Vector4 *out, Vector4 *v1, Vector4 *v2); + +// +void mVector4Lerp(Vector4 *out, Vector4 *v1, Vector4 *v2, float amount); + +// +void mVector4MoveTowards(Vector4 *out, Vector4 *v, Vector4 *target, float maxDistance); + +// +void mVector4Invert(Vector4 *out, Vector4 *v); + +// +int mVector4Equals(Vector4 *p, Vector4 *q); + // float mMatrixDeterminant(Matrix *mat); diff --git a/raylib b/raylib index 40f3df5..d374457 160000 --- a/raylib +++ b/raylib @@ -1 +1 @@ -Subproject commit 40f3df5b865eee0cd87a9e4e1347cb04c87841f8 +Subproject commit d3744570405976e33e2a6cfd7aceda3a30c5e000 diff --git a/raylib.json b/raylib.json index fd9bbac..ab12a43 100644 --- a/raylib.json +++ b/raylib.json @@ -9,19 +9,19 @@ { "name": "RAYLIB_VERSION_MAJOR", "type": "INT", - "value": "5", + "value": 5, "description": "" }, { "name": "RAYLIB_VERSION_MINOR", "type": "INT", - "value": "1", + "value": 1, "description": "" }, { "name": "RAYLIB_VERSION_PATCH", "type": "INT", - "value": "0", + "value": 0, "description": "" }, { @@ -45,7 +45,7 @@ { "name": "PI", "type": "FLOAT", - "value": "3.14159265358979323846", + "value": 3.14159265358979323846, "description": "" }, { @@ -335,6 +335,12 @@ "type": "UNKNOWN", "value": "SHADER_LOC_MAP_METALNESS", "description": "" + }, + { + "name": "GetMouseRay", + "type": "UNKNOWN", + "value": "GetScreenToWorldRay", + "description": "Compatibility hack for previous raylib versions" } ], "structs": [ @@ -2069,7 +2075,7 @@ }, { "name": "KEY_MENU", - "value": 82, + "value": 5, "description": "Key: Android menu button" }, { @@ -2223,7 +2229,7 @@ { "name": "GAMEPAD_BUTTON_RIGHT_FACE_RIGHT", "value": 6, - "description": "Gamepad right button right (i.e. PS3: Square, Xbox: X)" + "description": "Gamepad right button right (i.e. PS3: Circle, Xbox: B)" }, { "name": "GAMEPAD_BUTTON_RIGHT_FACE_DOWN", @@ -2233,7 +2239,7 @@ { "name": "GAMEPAD_BUTTON_RIGHT_FACE_LEFT", "value": 8, - "description": "Gamepad right button left (i.e. PS3: Circle, Xbox: B)" + "description": "Gamepad right button left (i.e. PS3: Square, Xbox: X)" }, { "name": "GAMEPAD_BUTTON_LEFT_TRIGGER_1", @@ -3872,13 +3878,13 @@ ] }, { - "name": "GetMouseRay", - "description": "Get a ray trace from mouse position", + "name": "GetScreenToWorldRay", + "description": "Get a ray trace from screen position (i.e mouse)", "returnType": "Ray", "params": [ { "type": "Vector2", - "name": "mousePosition" + "name": "position" }, { "type": "Camera", @@ -3887,24 +3893,25 @@ ] }, { - "name": "GetCameraMatrix", - "description": "Get camera transform matrix (view matrix)", - "returnType": "Matrix", + "name": "GetScreenToWorldRayEx", + "description": "Get a ray trace from screen position (i.e mouse) in a viewport", + "returnType": "Ray", "params": [ + { + "type": "Vector2", + "name": "position" + }, { "type": "Camera", "name": "camera" - } - ] - }, - { - "name": "GetCameraMatrix2D", - "description": "Get camera 2d transform matrix", - "returnType": "Matrix", - "params": [ + }, { - "type": "Camera2D", - "name": "camera" + "type": "float", + "name": "width" + }, + { + "type": "float", + "name": "height" } ] }, @@ -3923,21 +3930,6 @@ } ] }, - { - "name": "GetScreenToWorld2D", - "description": "Get the world space position for a 2d camera screen space position", - "returnType": "Vector2", - "params": [ - { - "type": "Vector2", - "name": "position" - }, - { - "type": "Camera2D", - "name": "camera" - } - ] - }, { "name": "GetWorldToScreenEx", "description": "Get size position for a 3d world space position", @@ -3976,6 +3968,43 @@ } ] }, + { + "name": "GetScreenToWorld2D", + "description": "Get the world space position for a 2d camera screen space position", + "returnType": "Vector2", + "params": [ + { + "type": "Vector2", + "name": "position" + }, + { + "type": "Camera2D", + "name": "camera" + } + ] + }, + { + "name": "GetCameraMatrix", + "description": "Get camera transform matrix (view matrix)", + "returnType": "Matrix", + "params": [ + { + "type": "Camera", + "name": "camera" + } + ] + }, + { + "name": "GetCameraMatrix2D", + "description": "Get camera 2d transform matrix", + "returnType": "Matrix", + "params": [ + { + "type": "Camera2D", + "name": "camera" + } + ] + }, { "name": "SetTargetFPS", "description": "Set target FPS (maximum)", @@ -4895,6 +4924,25 @@ } ] }, + { + "name": "SetGamepadVibration", + "description": "Set gamepad vibration for both motors", + "returnType": "void", + "params": [ + { + "type": "int", + "name": "gamepad" + }, + { + "type": "float", + "name": "leftMotor" + }, + { + "type": "float", + "name": "rightMotor" + } + ] + }, { "name": "IsMouseButtonPressed", "description": "Check if a mouse button has been pressed once", @@ -8326,6 +8374,21 @@ } ] }, + { + "name": "ColorIsEqual", + "description": "Check if two colors are equal", + "returnType": "bool", + "params": [ + { + "type": "Color", + "name": "col1" + }, + { + "type": "Color", + "name": "col2" + } + ] + }, { "name": "Fade", "description": "Get color with alpha applied, alpha goes from 0.0f to 1.0f", @@ -8343,7 +8406,7 @@ }, { "name": "ColorToInt", - "description": "Get hexadecimal value for a Color", + "description": "Get hexadecimal value for a Color (0xRRGGBBAA)", "returnType": "int", "params": [ { diff --git a/raylib.zig b/raylib.zig index 5623096..9fc0391 100644 --- a/raylib.zig +++ b/raylib.zig @@ -1313,12 +1313,11 @@ pub fn GetWindowScaleDPI() Vector2 { pub fn GetMonitorName( monitor: i32, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetMonitorName( + return @as([*:0]const u8, @ptrCast( + raylib.mGetMonitorName( monitor, - )), - ); + ), + )); } /// Set clipboard text content @@ -1332,10 +1331,9 @@ pub fn SetClipboardText( /// Get clipboard text content pub fn GetClipboardText() [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetClipboardText()), - ); + return @as([*:0]const u8, @ptrCast( + raylib.mGetClipboardText(), + )); } /// Enable waiting for events on EndDrawing(), no automatic event polling @@ -1648,40 +1646,34 @@ pub fn UnloadShader( ); } -/// Get a ray trace from mouse position -pub fn GetMouseRay( - mousePosition: Vector2, +/// Get a ray trace from screen position (i.e mouse) +pub fn GetScreenToWorldRay( + position: Vector2, camera: Camera3D, ) Ray { var out: Ray = undefined; - raylib.mGetMouseRay( + raylib.mGetScreenToWorldRay( @as([*c]raylib.Ray, @ptrCast(&out)), - @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&mousePosition))), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&position))), @as([*c]raylib.Camera3D, @ptrFromInt(@intFromPtr(&camera))), ); return out; } -/// Get camera transform matrix (view matrix) -pub fn GetCameraMatrix( +/// Get a ray trace from screen position (i.e mouse) in a viewport +pub fn GetScreenToWorldRayEx( + position: Vector2, camera: Camera3D, -) Matrix { - var out: Matrix = undefined; - raylib.mGetCameraMatrix( - @as([*c]raylib.Matrix, @ptrCast(&out)), + width: f32, + height: f32, +) Ray { + var out: Ray = undefined; + raylib.mGetScreenToWorldRayEx( + @as([*c]raylib.Ray, @ptrCast(&out)), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&position))), @as([*c]raylib.Camera3D, @ptrFromInt(@intFromPtr(&camera))), - ); - return out; -} - -/// Get camera 2d transform matrix -pub fn GetCameraMatrix2D( - camera: Camera2D, -) Matrix { - var out: Matrix = undefined; - raylib.mGetCameraMatrix2D( - @as([*c]raylib.Matrix, @ptrCast(&out)), - @as([*c]raylib.Camera2D, @ptrFromInt(@intFromPtr(&camera))), + width, + height, ); return out; } @@ -1700,20 +1692,6 @@ pub fn GetWorldToScreen( return out; } -/// Get the world space position for a 2d camera screen space position -pub fn GetScreenToWorld2D( - position: Vector2, - camera: Camera2D, -) Vector2 { - var out: Vector2 = undefined; - raylib.mGetScreenToWorld2D( - @as([*c]raylib.Vector2, @ptrCast(&out)), - @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&position))), - @as([*c]raylib.Camera2D, @ptrFromInt(@intFromPtr(&camera))), - ); - return out; -} - /// Get size position for a 3d world space position pub fn GetWorldToScreenEx( position: Vector3, @@ -1746,6 +1724,44 @@ pub fn GetWorldToScreen2D( return out; } +/// Get the world space position for a 2d camera screen space position +pub fn GetScreenToWorld2D( + position: Vector2, + camera: Camera2D, +) Vector2 { + var out: Vector2 = undefined; + raylib.mGetScreenToWorld2D( + @as([*c]raylib.Vector2, @ptrCast(&out)), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&position))), + @as([*c]raylib.Camera2D, @ptrFromInt(@intFromPtr(&camera))), + ); + return out; +} + +/// Get camera transform matrix (view matrix) +pub fn GetCameraMatrix( + camera: Camera3D, +) Matrix { + var out: Matrix = undefined; + raylib.mGetCameraMatrix( + @as([*c]raylib.Matrix, @ptrCast(&out)), + @as([*c]raylib.Camera3D, @ptrFromInt(@intFromPtr(&camera))), + ); + return out; +} + +/// Get camera 2d transform matrix +pub fn GetCameraMatrix2D( + camera: Camera2D, +) Matrix { + var out: Matrix = undefined; + raylib.mGetCameraMatrix2D( + @as([*c]raylib.Matrix, @ptrCast(&out)), + @as([*c]raylib.Camera2D, @ptrFromInt(@intFromPtr(&camera))), + ); + return out; +} + /// Set target FPS (maximum) pub fn SetTargetFPS( fps: i32, @@ -1815,14 +1831,13 @@ pub fn LoadRandomSequence( min: i32, max: i32, ) ?[*]i32 { - return @as( - ?[*]i32, - @ptrCast(raylib.mLoadRandomSequence( + return @as(?[*]i32, @ptrCast( + raylib.mLoadRandomSequence( count, min, max, - )), - ); + ), + )); } /// Unload random values sequence @@ -1927,12 +1942,11 @@ pub fn ExportDataAsCode( pub fn LoadFileText( fileName: [*:0]const u8, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mLoadFileText( + return @as(?[*]u8, @ptrCast( + raylib.mLoadFileText( @as([*c]const u8, @ptrFromInt(@intFromPtr(fileName))), - )), - ); + ), + )); } /// Unload file text data allocated by LoadFileText() @@ -1997,76 +2011,69 @@ pub fn GetFileLength( pub fn GetFileExtension( fileName: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetFileExtension( + return @as([*:0]const u8, @ptrCast( + raylib.mGetFileExtension( @as([*c]const u8, @ptrFromInt(@intFromPtr(fileName))), - )), - ); + ), + )); } /// Get pointer to filename for a path string pub fn GetFileName( filePath: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetFileName( + return @as([*:0]const u8, @ptrCast( + raylib.mGetFileName( @as([*c]const u8, @ptrFromInt(@intFromPtr(filePath))), - )), - ); + ), + )); } /// Get filename string without extension (uses static string) pub fn GetFileNameWithoutExt( filePath: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetFileNameWithoutExt( + return @as([*:0]const u8, @ptrCast( + raylib.mGetFileNameWithoutExt( @as([*c]const u8, @ptrFromInt(@intFromPtr(filePath))), - )), - ); + ), + )); } /// Get full path for a given fileName with path (uses static string) pub fn GetDirectoryPath( filePath: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetDirectoryPath( + return @as([*:0]const u8, @ptrCast( + raylib.mGetDirectoryPath( @as([*c]const u8, @ptrFromInt(@intFromPtr(filePath))), - )), - ); + ), + )); } /// Get previous directory path for a given path (uses static string) pub fn GetPrevDirectoryPath( dirPath: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetPrevDirectoryPath( + return @as([*:0]const u8, @ptrCast( + raylib.mGetPrevDirectoryPath( @as([*c]const u8, @ptrFromInt(@intFromPtr(dirPath))), - )), - ); + ), + )); } /// Get current working directory (uses static string) pub fn GetWorkingDirectory() [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetWorkingDirectory()), - ); + return @as([*:0]const u8, @ptrCast( + raylib.mGetWorkingDirectory(), + )); } /// Get the directory of the running application (uses static string) pub fn GetApplicationDirectory() [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetApplicationDirectory()), - ); + return @as([*:0]const u8, @ptrCast( + raylib.mGetApplicationDirectory(), + )); } /// Change working directory, return true on success @@ -2162,14 +2169,13 @@ pub fn CompressData( dataSize: i32, compDataSize: ?[*]i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mCompressData( + return @as(?[*]u8, @ptrCast( + raylib.mCompressData( @as([*c]const u8, @ptrFromInt(@intFromPtr(data))), dataSize, @as([*c]i32, @ptrCast(compDataSize)), - )), - ); + ), + )); } /// Decompress data (DEFLATE algorithm), memory must be MemFree() @@ -2178,14 +2184,13 @@ pub fn DecompressData( compDataSize: i32, dataSize: ?[*]i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mDecompressData( + return @as(?[*]u8, @ptrCast( + raylib.mDecompressData( @as([*c]const u8, @ptrFromInt(@intFromPtr(compData))), compDataSize, @as([*c]i32, @ptrCast(dataSize)), - )), - ); + ), + )); } /// Encode data to Base64 string, memory must be MemFree() @@ -2194,14 +2199,13 @@ pub fn EncodeDataBase64( dataSize: i32, outputSize: ?[*]i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mEncodeDataBase64( + return @as(?[*]u8, @ptrCast( + raylib.mEncodeDataBase64( @as([*c]const u8, @ptrFromInt(@intFromPtr(data))), dataSize, @as([*c]i32, @ptrCast(outputSize)), - )), - ); + ), + )); } /// Decode Base64 string data, memory must be MemFree() @@ -2209,13 +2213,12 @@ pub fn DecodeDataBase64( data: [*:0]const u8, outputSize: ?[*]i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mDecodeDataBase64( + return @as(?[*]u8, @ptrCast( + raylib.mDecodeDataBase64( @as([*c]const u8, @ptrFromInt(@intFromPtr(data))), @as([*c]i32, @ptrCast(outputSize)), - )), - ); + ), + )); } /// Load automation events list from file, NULL for empty list, capacity = MAX_AUTOMATION_EVENTS @@ -2364,12 +2367,11 @@ pub fn IsGamepadAvailable( pub fn GetGamepadName( gamepad: i32, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mGetGamepadName( + return @as([*:0]const u8, @ptrCast( + raylib.mGetGamepadName( gamepad, - )), - ); + ), + )); } /// Check if a gamepad button has been pressed once @@ -2445,6 +2447,19 @@ pub fn SetGamepadMappings( ); } +/// Set gamepad vibration for both motors +pub fn SetGamepadVibration( + gamepad: i32, + leftMotor: f32, + rightMotor: f32, +) void { + raylib.mSetGamepadVibration( + gamepad, + leftMotor, + rightMotor, + ); +} + /// Check if a mouse button has been pressed once pub fn IsMouseButtonPressed( button: MouseButton, @@ -3825,14 +3840,13 @@ pub fn ExportImageToMemory( fileType: [*:0]const u8, fileSize: ?[*]i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mExportImageToMemory( + return @as(?[*]u8, @ptrCast( + raylib.mExportImageToMemory( @as([*c]raylib.Image, @ptrFromInt(@intFromPtr(&image))), @as([*c]const u8, @ptrFromInt(@intFromPtr(fileType))), @as([*c]i32, @ptrCast(fileSize)), - )), - ); + ), + )); } /// Export image as code file defining an array of bytes, returns true on success @@ -4361,12 +4375,11 @@ pub fn ImageColorReplace( pub fn LoadImageColors( image: Image, ) ?[*]Color { - return @as( - ?[*]Color, - @ptrCast(raylib.mLoadImageColors( + return @as(?[*]Color, @ptrCast( + raylib.mLoadImageColors( @as([*c]raylib.Image, @ptrFromInt(@intFromPtr(&image))), - )), - ); + ), + )); } /// Load colors palette from image as a Color array (RGBA - 32bit) @@ -4375,14 +4388,13 @@ pub fn LoadImagePalette( maxPaletteSize: i32, colorCount: ?[*]i32, ) ?[*]Color { - return @as( - ?[*]Color, - @ptrCast(raylib.mLoadImagePalette( + return @as(?[*]Color, @ptrCast( + raylib.mLoadImagePalette( @as([*c]raylib.Image, @ptrFromInt(@intFromPtr(&image))), maxPaletteSize, @as([*c]i32, @ptrCast(colorCount)), - )), - ); + ), + )); } /// Unload color data loaded with LoadImageColors() @@ -4921,6 +4933,17 @@ pub fn DrawTextureNPatch( ); } +/// Check if two colors are equal +pub fn ColorIsEqual( + col1: Color, + col2: Color, +) bool { + return raylib.mColorIsEqual( + @as([*c]raylib.Color, @ptrFromInt(@intFromPtr(&col1))), + @as([*c]raylib.Color, @ptrFromInt(@intFromPtr(&col2))), + ); +} + /// Get color with alpha applied, alpha goes from 0.0f to 1.0f pub fn Fade( color: Color, @@ -4935,7 +4958,7 @@ pub fn Fade( return out; } -/// Get hexadecimal value for a Color +/// Get hexadecimal value for a Color (0xRRGGBBAA) pub fn ColorToInt( color: Color, ) i32 { @@ -5427,13 +5450,12 @@ pub fn LoadUTF8( codepoints: ?[*]const i32, length: i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mLoadUTF8( + return @as(?[*]u8, @ptrCast( + raylib.mLoadUTF8( @as([*c]const i32, @ptrFromInt(@intFromPtr(codepoints))), length, - )), - ); + ), + )); } /// Unload UTF-8 text encoded from codepoints array @@ -5450,13 +5472,12 @@ pub fn LoadCodepoints( text: [*:0]const u8, count: ?[*]i32, ) ?[*]i32 { - return @as( - ?[*]i32, - @ptrCast(raylib.mLoadCodepoints( + return @as(?[*]i32, @ptrCast( + raylib.mLoadCodepoints( @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), @as([*c]i32, @ptrCast(count)), - )), - ); + ), + )); } /// Unload codepoints data from memory @@ -5515,13 +5536,12 @@ pub fn CodepointToUTF8( codepoint: i32, utf8Size: ?[*]i32, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mCodepointToUTF8( + return @as([*:0]const u8, @ptrCast( + raylib.mCodepointToUTF8( codepoint, @as([*c]i32, @ptrCast(utf8Size)), - )), - ); + ), + )); } /// Copy one string to another, returns bytes copied @@ -5570,14 +5590,13 @@ pub fn TextSubtext( position: i32, length: i32, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mTextSubtext( + return @as([*:0]const u8, @ptrCast( + raylib.mTextSubtext( @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), position, length, - )), - ); + ), + )); } /// Replace text string (WARNING: memory must be freed!) @@ -5586,14 +5605,13 @@ pub fn TextReplace( replace: [*:0]const u8, by: [*:0]const u8, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mTextReplace( + return @as(?[*]u8, @ptrCast( + raylib.mTextReplace( @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), @as([*c]const u8, @ptrFromInt(@intFromPtr(replace))), @as([*c]const u8, @ptrFromInt(@intFromPtr(by))), - )), - ); + ), + )); } /// Insert text in a position (WARNING: memory must be freed!) @@ -5602,14 +5620,13 @@ pub fn TextInsert( insert: [*:0]const u8, position: i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mTextInsert( + return @as(?[*]u8, @ptrCast( + raylib.mTextInsert( @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), @as([*c]const u8, @ptrFromInt(@intFromPtr(insert))), position, - )), - ); + ), + )); } /// Load font data for further use @@ -5621,17 +5638,16 @@ pub fn LoadFontData( glyphCount: i32, typ: i32, ) [*]GlyphInfo { - return @as( - [*]GlyphInfo, - @ptrCast(raylib.mLoadFontData( + return @as([*]GlyphInfo, @ptrCast( + raylib.mLoadFontData( @as([*c]const u8, @ptrFromInt(@intFromPtr(fileData))), dataSize, fontSize, @as([*c]i32, @ptrCast(fontChars)), glyphCount, typ, - )), - ); + ), + )); } /// @@ -5668,36 +5684,33 @@ pub fn TextFindIndex( pub fn TextToUpper( text: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mTextToUpper( + return @as([*:0]const u8, @ptrCast( + raylib.mTextToUpper( @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), - )), - ); + ), + )); } /// Get lower case version of provided string pub fn TextToLower( text: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mTextToLower( + return @as([*:0]const u8, @ptrCast( + raylib.mTextToLower( @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), - )), - ); + ), + )); } /// Get Pascal case notation version of provided string pub fn TextToPascal( text: [*:0]const u8, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mTextToPascal( + return @as([*:0]const u8, @ptrCast( + raylib.mTextToPascal( @as([*c]const u8, @ptrFromInt(@intFromPtr(text))), - )), - ); + ), + )); } /// Get integer value from text (negative values not supported) @@ -6526,13 +6539,12 @@ pub fn LoadMaterials( fileName: [*:0]const u8, materialCount: ?[*]i32, ) ?[*]Material { - return @as( - ?[*]Material, - @ptrCast(raylib.mLoadMaterials( + return @as(?[*]Material, @ptrCast( + raylib.mLoadMaterials( @as([*c]const u8, @ptrFromInt(@intFromPtr(fileName))), @as([*c]i32, @ptrCast(materialCount)), - )), - ); + ), + )); } /// Load default material (Supports: DIFFUSE, SPECULAR, NORMAL maps) @@ -6593,13 +6605,12 @@ pub fn LoadModelAnimations( fileName: [*:0]const u8, animCount: ?[*]i32, ) ?[*]ModelAnimation { - return @as( - ?[*]ModelAnimation, - @ptrCast(raylib.mLoadModelAnimations( + return @as(?[*]ModelAnimation, @ptrCast( + raylib.mLoadModelAnimations( @as([*c]const u8, @ptrFromInt(@intFromPtr(fileName))), @as([*c]i32, @ptrCast(animCount)), - )), - ); + ), + )); } /// Update model animation pose @@ -7064,12 +7075,11 @@ pub fn WaveFormat( pub fn LoadWaveSamples( wave: Wave, ) ?[*]f32 { - return @as( - ?[*]f32, - @ptrCast(raylib.mLoadWaveSamples( + return @as(?[*]f32, @ptrCast( + raylib.mLoadWaveSamples( @as([*c]raylib.Wave, @ptrFromInt(@intFromPtr(&wave))), - )), - ); + ), + )); } /// Unload samples data loaded with LoadWaveSamples() @@ -7831,6 +7841,11 @@ pub fn rlDisableFramebuffer() void { raylib.mrlDisableFramebuffer(); } +/// Get the currently active render texture (fbo), 0 for default framebuffer +pub fn rlGetActiveFramebuffer() u32 { + return raylib.mrlGetActiveFramebuffer(); +} + /// Activate multiple draw color buffers pub fn rlActiveDrawBuffers( count: i32, @@ -8155,10 +8170,9 @@ pub fn rlGetShaderIdDefault() u32 { /// Get default shader locations pub fn rlGetShaderLocsDefault() ?[*]i32 { - return @as( - ?[*]i32, - @ptrCast(raylib.mrlGetShaderLocsDefault()), - ); + return @as(?[*]i32, @ptrCast( + raylib.mrlGetShaderLocsDefault(), + )); } /// Load a render batch system @@ -8476,12 +8490,11 @@ pub fn rlGetGlTextureFormats( pub fn rlGetPixelFormatName( format: u32, ) [*:0]const u8 { - return @as( - [*:0]const u8, - @ptrCast(raylib.mrlGetPixelFormatName( + return @as([*:0]const u8, @ptrCast( + raylib.mrlGetPixelFormatName( format, - )), - ); + ), + )); } /// Unload texture from GPU memory @@ -8517,15 +8530,14 @@ pub fn rlReadTexturePixels( height: i32, format: i32, ) *anyopaque { - return @as( - *anyopaque, - @ptrCast(raylib.mrlReadTexturePixels( + return @as(*anyopaque, @ptrCast( + raylib.mrlReadTexturePixels( id, width, height, format, - )), - ); + ), + )); } /// Read screen pixel data (color buffer) @@ -8533,24 +8545,17 @@ pub fn rlReadScreenPixels( width: i32, height: i32, ) [*:0]const u8 { - return @as( - ?[*]u8, - @ptrCast(raylib.mrlReadScreenPixels( + return @as(?[*]u8, @ptrCast( + raylib.mrlReadScreenPixels( width, height, - )), - ); + ), + )); } /// Load an empty framebuffer -pub fn rlLoadFramebuffer( - width: i32, - height: i32, -) u32 { - return raylib.mrlLoadFramebuffer( - width, - height, - ); +pub fn rlLoadFramebuffer() u32 { + return raylib.mrlLoadFramebuffer(); } /// Attach texture/renderbuffer to a framebuffer @@ -9253,6 +9258,34 @@ pub fn Vector2Reflect( return out; } +/// +pub fn Vector2Min( + v1: Vector2, + v2: Vector2, +) Vector2 { + var out: Vector2 = undefined; + raylib.mVector2Min( + @as([*c]raylib.Vector2, @ptrCast(&out)), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + +/// +pub fn Vector2Max( + v1: Vector2, + v2: Vector2, +) Vector2 { + var out: Vector2 = undefined; + raylib.mVector2Max( + @as([*c]raylib.Vector2, @ptrCast(&out)), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + /// pub fn Vector2Rotate( v: Vector2, @@ -9338,6 +9371,22 @@ pub fn Vector2Equals( ); } +/// +pub fn Vector2Refract( + v: Vector2, + n: Vector2, + r: f32, +) Vector2 { + var out: Vector2 = undefined; + raylib.mVector2Refract( + @as([*c]raylib.Vector2, @ptrCast(&out)), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&v))), + @as([*c]raylib.Vector2, @ptrFromInt(@intFromPtr(&n))), + r, + ); + return out; +} + /// pub fn Vector3Zero() Vector3 { var out: Vector3 = undefined; @@ -9649,6 +9698,22 @@ pub fn Vector3RotateByAxisAngle( return out; } +/// +pub fn Vector3MoveTowards( + v: Vector3, + target: Vector3, + maxDistance: f32, +) Vector3 { + var out: Vector3 = undefined; + raylib.mVector3MoveTowards( + @as([*c]raylib.Vector3, @ptrCast(&out)), + @as([*c]raylib.Vector3, @ptrFromInt(@intFromPtr(&v))), + @as([*c]raylib.Vector3, @ptrFromInt(@intFromPtr(&target))), + maxDistance, + ); + return out; +} + /// pub fn Vector3Lerp( v1: Vector3, @@ -9824,6 +9889,280 @@ pub fn Vector3Refract( return out; } +/// +pub fn Vector4Zero() Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Zero( + @as([*c]raylib.Vector4, @ptrCast(&out)), + ); + return out; +} + +/// +pub fn Vector4One() Vector4 { + var out: Vector4 = undefined; + raylib.mVector4One( + @as([*c]raylib.Vector4, @ptrCast(&out)), + ); + return out; +} + +/// +pub fn Vector4Add( + v1: Vector4, + v2: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Add( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + +/// +pub fn Vector4AddValue( + v: Vector4, + add: f32, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4AddValue( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + add, + ); + return out; +} + +/// +pub fn Vector4Subtract( + v1: Vector4, + v2: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Subtract( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + +/// +pub fn Vector4SubtractValue( + v: Vector4, + add: f32, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4SubtractValue( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + add, + ); + return out; +} + +/// +pub fn Vector4Length( + v: Vector4, +) f32 { + return raylib.mVector4Length( + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + ); +} + +/// +pub fn Vector4LengthSqr( + v: Vector4, +) f32 { + return raylib.mVector4LengthSqr( + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + ); +} + +/// +pub fn Vector4DotProduct( + v1: Vector4, + v2: Vector4, +) f32 { + return raylib.mVector4DotProduct( + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); +} + +/// +pub fn Vector4Distance( + v1: Vector4, + v2: Vector4, +) f32 { + return raylib.mVector4Distance( + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); +} + +/// +pub fn Vector4DistanceSqr( + v1: Vector4, + v2: Vector4, +) f32 { + return raylib.mVector4DistanceSqr( + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); +} + +/// +pub fn Vector4Scale( + v: Vector4, + scale: f32, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Scale( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + scale, + ); + return out; +} + +/// +pub fn Vector4Multiply( + v1: Vector4, + v2: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Multiply( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + +/// +pub fn Vector4Negate( + v: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Negate( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + ); + return out; +} + +/// +pub fn Vector4Divide( + v1: Vector4, + v2: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Divide( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + +/// +pub fn Vector4Normalize( + v: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Normalize( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + ); + return out; +} + +/// +pub fn Vector4Min( + v1: Vector4, + v2: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Min( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + +/// +pub fn Vector4Max( + v1: Vector4, + v2: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Max( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + ); + return out; +} + +/// +pub fn Vector4Lerp( + v1: Vector4, + v2: Vector4, + amount: f32, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Lerp( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v1))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v2))), + amount, + ); + return out; +} + +/// +pub fn Vector4MoveTowards( + v: Vector4, + target: Vector4, + maxDistance: f32, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4MoveTowards( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&target))), + maxDistance, + ); + return out; +} + +/// +pub fn Vector4Invert( + v: Vector4, +) Vector4 { + var out: Vector4 = undefined; + raylib.mVector4Invert( + @as([*c]raylib.Vector4, @ptrCast(&out)), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&v))), + ); + return out; +} + +/// +pub fn Vector4Equals( + p: Vector4, + q: Vector4, +) i32 { + return raylib.mVector4Equals( + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&p))), + @as([*c]raylib.Vector4, @ptrFromInt(@intFromPtr(&q))), + ); +} + /// pub fn MatrixDeterminant( mat: Matrix, @@ -11131,11 +11470,11 @@ pub const GamepadButton = enum(i32) { GAMEPAD_BUTTON_LEFT_FACE_LEFT = 4, /// Gamepad right button up (i.e. PS3: Triangle, Xbox: Y) GAMEPAD_BUTTON_RIGHT_FACE_UP = 5, - /// Gamepad right button right (i.e. PS3: Square, Xbox: X) + /// Gamepad right button right (i.e. PS3: Circle, Xbox: B) GAMEPAD_BUTTON_RIGHT_FACE_RIGHT = 6, /// Gamepad right button down (i.e. PS3: Cross, Xbox: A) GAMEPAD_BUTTON_RIGHT_FACE_DOWN = 7, - /// Gamepad right button left (i.e. PS3: Circle, Xbox: B) + /// Gamepad right button left (i.e. PS3: Square, Xbox: X) GAMEPAD_BUTTON_RIGHT_FACE_LEFT = 8, /// Gamepad top/back trigger left (first), it could be a trailing button GAMEPAD_BUTTON_LEFT_TRIGGER_1 = 9, @@ -11760,7 +12099,7 @@ pub const RAYLIB_VERSION_PATCH: i32 = 0; pub const RAYLIB_VERSION: []const u8 = "5.1-dev"; /// -pub const PI: f32 = 3.14159265358979323846; +pub const PI: f32 = 3.141592653589793e0; /// Light Gray pub const LIGHTGRAY: Color = .{ .r = 200, .g = 200, .b = 200, .a = 255 }; @@ -11862,10 +12201,10 @@ pub const RL_MAX_MATRIX_STACK_SIZE: i32 = 32; pub const RL_MAX_SHADER_LOCATIONS: i32 = 32; /// Default near cull distance -pub const RL_CULL_DISTANCE_NEAR: f64 = 0.01; +pub const RL_CULL_DISTANCE_NEAR: f64 = 1e-2; /// Default far cull distance -pub const RL_CULL_DISTANCE_FAR: f64 = 1000.0; +pub const RL_CULL_DISTANCE_FAR: f64 = 1e3; /// GL_TEXTURE_WRAP_S pub const RL_TEXTURE_WRAP_S: i32 = 10242; @@ -12107,6 +12446,12 @@ pub const GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT: i32 = 34047; /// pub const GL_TEXTURE_MAX_ANISOTROPY_EXT: i32 = 34046; +/// +pub const GL_PROGRAM_POINT_SIZE: i32 = 34370; + +/// +pub const GL_LINE_WIDTH: i32 = 2849; + /// pub const GL_UNSIGNED_SHORT_5_6_5: i32 = 33635; @@ -12168,4 +12513,4 @@ pub const RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE1: []const u8 = "texture1"; pub const RL_DEFAULT_SHADER_SAMPLER2D_NAME_TEXTURE2: []const u8 = "texture2"; /// -pub const EPSILON: f32 = 0.000001; +pub const EPSILON: f32 = 1e-6; diff --git a/raymath.json b/raymath.json index 997d27a..38d280f 100644 --- a/raymath.json +++ b/raymath.json @@ -15,13 +15,13 @@ { "name": "PI", "type": "FLOAT", - "value": "3.14159265358979323846", + "value": 3.14159265358979323846, "description": "" }, { "name": "EPSILON", "type": "FLOAT", - "value": "0.000001", + "value": 0.000001, "description": "" }, { @@ -665,6 +665,36 @@ } ] }, + { + "name": "Vector2Min", + "description": "", + "returnType": "Vector2", + "params": [ + { + "type": "Vector2", + "name": "v1" + }, + { + "type": "Vector2", + "name": "v2" + } + ] + }, + { + "name": "Vector2Max", + "description": "", + "returnType": "Vector2", + "params": [ + { + "type": "Vector2", + "name": "v1" + }, + { + "type": "Vector2", + "name": "v2" + } + ] + }, { "name": "Vector2Rotate", "description": "", @@ -763,6 +793,25 @@ } ] }, + { + "name": "Vector2Refract", + "description": "", + "returnType": "Vector2", + "params": [ + { + "type": "Vector2", + "name": "v" + }, + { + "type": "Vector2", + "name": "n" + }, + { + "type": "float", + "name": "r" + } + ] + }, { "name": "Vector3Zero", "description": "", @@ -1102,6 +1151,25 @@ } ] }, + { + "name": "Vector3MoveTowards", + "description": "", + "returnType": "Vector3", + "params": [ + { + "type": "Vector3", + "name": "v" + }, + { + "type": "Vector3", + "name": "target" + }, + { + "type": "float", + "name": "maxDistance" + } + ] + }, { "name": "Vector3Lerp", "description": "", @@ -1302,6 +1370,304 @@ } ] }, + { + "name": "Vector4Zero", + "description": "", + "returnType": "Vector4" + }, + { + "name": "Vector4One", + "description": "", + "returnType": "Vector4" + }, + { + "name": "Vector4Add", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4AddValue", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v" + }, + { + "type": "float", + "name": "add" + } + ] + }, + { + "name": "Vector4Subtract", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4SubtractValue", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v" + }, + { + "type": "float", + "name": "add" + } + ] + }, + { + "name": "Vector4Length", + "description": "", + "returnType": "float", + "params": [ + { + "type": "Vector4", + "name": "v" + } + ] + }, + { + "name": "Vector4LengthSqr", + "description": "", + "returnType": "float", + "params": [ + { + "type": "Vector4", + "name": "v" + } + ] + }, + { + "name": "Vector4DotProduct", + "description": "", + "returnType": "float", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4Distance", + "description": "", + "returnType": "float", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4DistanceSqr", + "description": "", + "returnType": "float", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4Scale", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v" + }, + { + "type": "float", + "name": "scale" + } + ] + }, + { + "name": "Vector4Multiply", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4Negate", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v" + } + ] + }, + { + "name": "Vector4Divide", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4Normalize", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v" + } + ] + }, + { + "name": "Vector4Min", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4Max", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + } + ] + }, + { + "name": "Vector4Lerp", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v1" + }, + { + "type": "Vector4", + "name": "v2" + }, + { + "type": "float", + "name": "amount" + } + ] + }, + { + "name": "Vector4MoveTowards", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v" + }, + { + "type": "Vector4", + "name": "target" + }, + { + "type": "float", + "name": "maxDistance" + } + ] + }, + { + "name": "Vector4Invert", + "description": "", + "returnType": "Vector4", + "params": [ + { + "type": "Vector4", + "name": "v" + } + ] + }, + { + "name": "Vector4Equals", + "description": "", + "returnType": "int", + "params": [ + { + "type": "Vector4", + "name": "p" + }, + { + "type": "Vector4", + "name": "q" + } + ] + }, { "name": "MatrixDeterminant", "description": "", diff --git a/rlgl.json b/rlgl.json index 0f29ffb..96d0805 100644 --- a/rlgl.json +++ b/rlgl.json @@ -75,445 +75,445 @@ { "name": "RL_DEFAULT_BATCH_BUFFER_ELEMENTS", "type": "INT", - "value": "8192", + "value": 8192, "description": "" }, { "name": "RL_DEFAULT_BATCH_BUFFERS", "type": "INT", - "value": "1", + "value": 1, "description": "Default number of batch buffers (multi-buffering)" }, { "name": "RL_DEFAULT_BATCH_DRAWCALLS", "type": "INT", - "value": "256", + "value": 256, "description": "Default number of batch draw calls (by state changes: mode, texture)" }, { "name": "RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS", "type": "INT", - "value": "4", + "value": 4, "description": "Maximum number of textures units that can be activated on batch drawing (SetShaderValueTexture())" }, { "name": "RL_MAX_MATRIX_STACK_SIZE", "type": "INT", - "value": "32", + "value": 32, "description": "Maximum size of Matrix stack" }, { "name": "RL_MAX_SHADER_LOCATIONS", "type": "INT", - "value": "32", + "value": 32, "description": "Maximum number of shader locations supported" }, { "name": "RL_CULL_DISTANCE_NEAR", "type": "DOUBLE", - "value": "0.01", + "value": 0.01, "description": "Default near cull distance" }, { "name": "RL_CULL_DISTANCE_FAR", "type": "DOUBLE", - "value": "1000.0", + "value": 1000.0, "description": "Default far cull distance" }, { "name": "RL_TEXTURE_WRAP_S", "type": "INT", - "value": "10242", + "value": 10242, "description": "GL_TEXTURE_WRAP_S" }, { "name": "RL_TEXTURE_WRAP_T", "type": "INT", - "value": "10243", + "value": 10243, "description": "GL_TEXTURE_WRAP_T" }, { "name": "RL_TEXTURE_MAG_FILTER", "type": "INT", - "value": "10240", + "value": 10240, "description": "GL_TEXTURE_MAG_FILTER" }, { "name": "RL_TEXTURE_MIN_FILTER", "type": "INT", - "value": "10241", + "value": 10241, "description": "GL_TEXTURE_MIN_FILTER" }, { "name": "RL_TEXTURE_FILTER_NEAREST", "type": "INT", - "value": "9728", + "value": 9728, "description": "GL_NEAREST" }, { "name": "RL_TEXTURE_FILTER_LINEAR", "type": "INT", - "value": "9729", + "value": 9729, "description": "GL_LINEAR" }, { "name": "RL_TEXTURE_FILTER_MIP_NEAREST", "type": "INT", - "value": "9984", + "value": 9984, "description": "GL_NEAREST_MIPMAP_NEAREST" }, { "name": "RL_TEXTURE_FILTER_NEAREST_MIP_LINEAR", "type": "INT", - "value": "9986", + "value": 9986, "description": "GL_NEAREST_MIPMAP_LINEAR" }, { "name": "RL_TEXTURE_FILTER_LINEAR_MIP_NEAREST", "type": "INT", - "value": "9985", + "value": 9985, "description": "GL_LINEAR_MIPMAP_NEAREST" }, { "name": "RL_TEXTURE_FILTER_MIP_LINEAR", "type": "INT", - "value": "9987", + "value": 9987, "description": "GL_LINEAR_MIPMAP_LINEAR" }, { "name": "RL_TEXTURE_FILTER_ANISOTROPIC", "type": "INT", - "value": "12288", + "value": 12288, "description": "Anisotropic filter (custom identifier)" }, { "name": "RL_TEXTURE_MIPMAP_BIAS_RATIO", "type": "INT", - "value": "16384", + "value": 16384, "description": "Texture mipmap bias, percentage ratio (custom identifier)" }, { "name": "RL_TEXTURE_WRAP_REPEAT", "type": "INT", - "value": "10497", + "value": 10497, "description": "GL_REPEAT" }, { "name": "RL_TEXTURE_WRAP_CLAMP", "type": "INT", - "value": "33071", + "value": 33071, "description": "GL_CLAMP_TO_EDGE" }, { "name": "RL_TEXTURE_WRAP_MIRROR_REPEAT", "type": "INT", - "value": "33648", + "value": 33648, "description": "GL_MIRRORED_REPEAT" }, { "name": "RL_TEXTURE_WRAP_MIRROR_CLAMP", "type": "INT", - "value": "34626", + "value": 34626, "description": "GL_MIRROR_CLAMP_EXT" }, { "name": "RL_MODELVIEW", "type": "INT", - "value": "5888", + "value": 5888, "description": "GL_MODELVIEW" }, { "name": "RL_PROJECTION", "type": "INT", - "value": "5889", + "value": 5889, "description": "GL_PROJECTION" }, { "name": "RL_TEXTURE", "type": "INT", - "value": "5890", + "value": 5890, "description": "GL_TEXTURE" }, { "name": "RL_LINES", "type": "INT", - "value": "1", + "value": 1, "description": "GL_LINES" }, { "name": "RL_TRIANGLES", "type": "INT", - "value": "4", + "value": 4, "description": "GL_TRIANGLES" }, { "name": "RL_QUADS", "type": "INT", - "value": "7", + "value": 7, "description": "GL_QUADS" }, { "name": "RL_UNSIGNED_BYTE", "type": "INT", - "value": "5121", + "value": 5121, "description": "GL_UNSIGNED_BYTE" }, { "name": "RL_FLOAT", "type": "INT", - "value": "5126", + "value": 5126, "description": "GL_FLOAT" }, { "name": "RL_STREAM_DRAW", "type": "INT", - "value": "35040", + "value": 35040, "description": "GL_STREAM_DRAW" }, { "name": "RL_STREAM_READ", "type": "INT", - "value": "35041", + "value": 35041, "description": "GL_STREAM_READ" }, { "name": "RL_STREAM_COPY", "type": "INT", - "value": "35042", + "value": 35042, "description": "GL_STREAM_COPY" }, { "name": "RL_STATIC_DRAW", "type": "INT", - "value": "35044", + "value": 35044, "description": "GL_STATIC_DRAW" }, { "name": "RL_STATIC_READ", "type": "INT", - "value": "35045", + "value": 35045, "description": "GL_STATIC_READ" }, { "name": "RL_STATIC_COPY", "type": "INT", - "value": "35046", + "value": 35046, "description": "GL_STATIC_COPY" }, { "name": "RL_DYNAMIC_DRAW", "type": "INT", - "value": "35048", + "value": 35048, "description": "GL_DYNAMIC_DRAW" }, { "name": "RL_DYNAMIC_READ", "type": "INT", - "value": "35049", + "value": 35049, "description": "GL_DYNAMIC_READ" }, { "name": "RL_DYNAMIC_COPY", "type": "INT", - "value": "35050", + "value": 35050, "description": "GL_DYNAMIC_COPY" }, { "name": "RL_FRAGMENT_SHADER", "type": "INT", - "value": "35632", + "value": 35632, "description": "GL_FRAGMENT_SHADER" }, { "name": "RL_VERTEX_SHADER", "type": "INT", - "value": "35633", + "value": 35633, "description": "GL_VERTEX_SHADER" }, { "name": "RL_COMPUTE_SHADER", "type": "INT", - "value": "37305", + "value": 37305, "description": "GL_COMPUTE_SHADER" }, { "name": "RL_ZERO", "type": "INT", - "value": "0", + "value": 0, "description": "GL_ZERO" }, { "name": "RL_ONE", "type": "INT", - "value": "1", + "value": 1, "description": "GL_ONE" }, { "name": "RL_SRC_COLOR", "type": "INT", - "value": "768", + "value": 768, "description": "GL_SRC_COLOR" }, { "name": "RL_ONE_MINUS_SRC_COLOR", "type": "INT", - "value": "769", + "value": 769, "description": "GL_ONE_MINUS_SRC_COLOR" }, { "name": "RL_SRC_ALPHA", "type": "INT", - "value": "770", + "value": 770, "description": "GL_SRC_ALPHA" }, { "name": "RL_ONE_MINUS_SRC_ALPHA", "type": "INT", - "value": "771", + "value": 771, "description": "GL_ONE_MINUS_SRC_ALPHA" }, { "name": "RL_DST_ALPHA", "type": "INT", - "value": "772", + "value": 772, "description": "GL_DST_ALPHA" }, { "name": "RL_ONE_MINUS_DST_ALPHA", "type": "INT", - "value": "773", + "value": 773, "description": "GL_ONE_MINUS_DST_ALPHA" }, { "name": "RL_DST_COLOR", "type": "INT", - "value": "774", + "value": 774, "description": "GL_DST_COLOR" }, { "name": "RL_ONE_MINUS_DST_COLOR", "type": "INT", - "value": "775", + "value": 775, "description": "GL_ONE_MINUS_DST_COLOR" }, { "name": "RL_SRC_ALPHA_SATURATE", "type": "INT", - "value": "776", + "value": 776, "description": "GL_SRC_ALPHA_SATURATE" }, { "name": "RL_CONSTANT_COLOR", "type": "INT", - "value": "32769", + "value": 32769, "description": "GL_CONSTANT_COLOR" }, { "name": "RL_ONE_MINUS_CONSTANT_COLOR", "type": "INT", - "value": "32770", + "value": 32770, "description": "GL_ONE_MINUS_CONSTANT_COLOR" }, { "name": "RL_CONSTANT_ALPHA", "type": "INT", - "value": "32771", + "value": 32771, "description": "GL_CONSTANT_ALPHA" }, { "name": "RL_ONE_MINUS_CONSTANT_ALPHA", "type": "INT", - "value": "32772", + "value": 32772, "description": "GL_ONE_MINUS_CONSTANT_ALPHA" }, { "name": "RL_FUNC_ADD", "type": "INT", - "value": "32774", + "value": 32774, "description": "GL_FUNC_ADD" }, { "name": "RL_MIN", "type": "INT", - "value": "32775", + "value": 32775, "description": "GL_MIN" }, { "name": "RL_MAX", "type": "INT", - "value": "32776", + "value": 32776, "description": "GL_MAX" }, { "name": "RL_FUNC_SUBTRACT", "type": "INT", - "value": "32778", + "value": 32778, "description": "GL_FUNC_SUBTRACT" }, { "name": "RL_FUNC_REVERSE_SUBTRACT", "type": "INT", - "value": "32779", + "value": 32779, "description": "GL_FUNC_REVERSE_SUBTRACT" }, { "name": "RL_BLEND_EQUATION", "type": "INT", - "value": "32777", + "value": 32777, "description": "GL_BLEND_EQUATION" }, { "name": "RL_BLEND_EQUATION_RGB", "type": "INT", - "value": "32777", + "value": 32777, "description": "GL_BLEND_EQUATION_RGB // (Same as BLEND_EQUATION)" }, { "name": "RL_BLEND_EQUATION_ALPHA", "type": "INT", - "value": "34877", + "value": 34877, "description": "GL_BLEND_EQUATION_ALPHA" }, { "name": "RL_BLEND_DST_RGB", "type": "INT", - "value": "32968", + "value": 32968, "description": "GL_BLEND_DST_RGB" }, { "name": "RL_BLEND_SRC_RGB", "type": "INT", - "value": "32969", + "value": 32969, "description": "GL_BLEND_SRC_RGB" }, { "name": "RL_BLEND_DST_ALPHA", "type": "INT", - "value": "32970", + "value": 32970, "description": "GL_BLEND_DST_ALPHA" }, { "name": "RL_BLEND_SRC_ALPHA", "type": "INT", - "value": "32971", + "value": 32971, "description": "GL_BLEND_SRC_ALPHA" }, { "name": "RL_BLEND_COLOR", "type": "INT", - "value": "32773", + "value": 32773, "description": "GL_BLEND_COLOR" }, { "name": "RL_READ_FRAMEBUFFER", "type": "INT", - "value": "36008", + "value": 36008, "description": "GL_READ_FRAMEBUFFER" }, { "name": "RL_DRAW_FRAMEBUFFER", "type": "INT", - "value": "36009", + "value": 36009, "description": "GL_DRAW_FRAMEBUFFER" }, { @@ -591,7 +591,7 @@ { "name": "PI", "type": "FLOAT", - "value": "3.14159265358979323846", + "value": 3.14159265358979323846, "description": "" }, { @@ -609,115 +609,127 @@ { "name": "GL_SHADING_LANGUAGE_VERSION", "type": "INT", - "value": "35724", + "value": 35724, "description": "" }, { "name": "GL_COMPRESSED_RGB_S3TC_DXT1_EXT", "type": "INT", - "value": "33776", + "value": 33776, "description": "" }, { "name": "GL_COMPRESSED_RGBA_S3TC_DXT1_EXT", "type": "INT", - "value": "33777", + "value": 33777, "description": "" }, { "name": "GL_COMPRESSED_RGBA_S3TC_DXT3_EXT", "type": "INT", - "value": "33778", + "value": 33778, "description": "" }, { "name": "GL_COMPRESSED_RGBA_S3TC_DXT5_EXT", "type": "INT", - "value": "33779", + "value": 33779, "description": "" }, { "name": "GL_ETC1_RGB8_OES", "type": "INT", - "value": "36196", + "value": 36196, "description": "" }, { "name": "GL_COMPRESSED_RGB8_ETC2", "type": "INT", - "value": "37492", + "value": 37492, "description": "" }, { "name": "GL_COMPRESSED_RGBA8_ETC2_EAC", "type": "INT", - "value": "37496", + "value": 37496, "description": "" }, { "name": "GL_COMPRESSED_RGB_PVRTC_4BPPV1_IMG", "type": "INT", - "value": "35840", + "value": 35840, "description": "" }, { "name": "GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG", "type": "INT", - "value": "35842", + "value": 35842, "description": "" }, { "name": "GL_COMPRESSED_RGBA_ASTC_4x4_KHR", "type": "INT", - "value": "37808", + "value": 37808, "description": "" }, { "name": "GL_COMPRESSED_RGBA_ASTC_8x8_KHR", "type": "INT", - "value": "37815", + "value": 37815, "description": "" }, { "name": "GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT", "type": "INT", - "value": "34047", + "value": 34047, "description": "" }, { "name": "GL_TEXTURE_MAX_ANISOTROPY_EXT", "type": "INT", - "value": "34046", + "value": 34046, + "description": "" + }, + { + "name": "GL_PROGRAM_POINT_SIZE", + "type": "INT", + "value": 34370, + "description": "" + }, + { + "name": "GL_LINE_WIDTH", + "type": "INT", + "value": 2849, "description": "" }, { "name": "GL_UNSIGNED_SHORT_5_6_5", "type": "INT", - "value": "33635", + "value": 33635, "description": "" }, { "name": "GL_UNSIGNED_SHORT_5_5_5_1", "type": "INT", - "value": "32820", + "value": 32820, "description": "" }, { "name": "GL_UNSIGNED_SHORT_4_4_4_4", "type": "INT", - "value": "32819", + "value": 32819, "description": "" }, { "name": "GL_LUMINANCE", "type": "INT", - "value": "6409", + "value": 6409, "description": "" }, { "name": "GL_LUMINANCE_ALPHA", "type": "INT", - "value": "6410", + "value": 6410, "description": "" }, { @@ -952,11 +964,36 @@ "name": "colors", "description": "Vertex colors (RGBA - 4 components per vertex) (shader-location = 3)" }, + { + "type": "#if defined(GRAPHICS_API_OPENGL_11) || defined(GRAPHICS_API_OPENunsigned int *", + "name": "indices", + "description": "Vertex indices (in case vertex data comes indexed) (6 indices per quad)" + }, { "type": "unsigned int *", "name": "indices", "description": "Vertex indices (in case vertex data comes indexed) (6 indices per quad)" }, + { + "type": "#endif", + "name": "indices", + "description": "Vertex indices (in case vertex data comes indexed) (6 indices per quad)" + }, + { + "type": "#if defined(GRAPHICS_API_OPENGL_ES2)", + "name": "indices", + "description": "Vertex indices (in case vertex data comes indexed) (6 indices per quad)" + }, + { + "type": "unsigned short *", + "name": "indices", + "description": "Vertex indices (in case vertex data comes indexed) (6 indices per quad)" + }, + { + "type": "#endif", + "name": "vaoId", + "description": "OpenGL Vertex Array Object id" + }, { "type": "unsigned int", "name": "vaoId", @@ -2453,6 +2490,11 @@ "description": "Disable render texture (fbo), return to default framebuffer", "returnType": "void" }, + { + "name": "rlGetActiveFramebuffer", + "description": "Get the currently active render texture (fbo), 0 for default framebuffer", + "returnType": "unsigned int" + }, { "name": "rlActiveDrawBuffers", "description": "Activate multiple draw color buffers", @@ -3406,17 +3448,7 @@ { "name": "rlLoadFramebuffer", "description": "Load an empty framebuffer", - "returnType": "unsigned int", - "params": [ - { - "type": "int", - "name": "width" - }, - { - "type": "int", - "name": "height" - } - ] + "returnType": "unsigned int" }, { "name": "rlFramebufferAttach", diff --git a/samples/hello-world/build.zig b/samples/hello-world/build.zig new file mode 100644 index 0000000..96a337f --- /dev/null +++ b/samples/hello-world/build.zig @@ -0,0 +1,69 @@ +const std = @import("std"); +const raylib = @import("ext/raylib.zig/build.zig"); + +// Although this function looks imperative, note that its job is to +// declaratively construct a build graph that will be executed by an external +// runner. +pub fn build(b: *std.Build) void { + // Standard target options allows the person running `zig build` to choose + // what target to build for. Here we do not override the defaults, which + // means any target is allowed, and the default is native. Other options + // for restricting supported target set are available. + const target = b.standardTargetOptions(.{}); + + // Standard optimization options allow the person running `zig build` to select + // between Debug, ReleaseSafe, ReleaseFast, and ReleaseSmall. Here we do not + // set a preferred release mode, allowing the user to decide how to optimize. + const optimize = b.standardOptimizeOption(.{}); + + const exe = b.addExecutable(.{ + .name = "hello-world", + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); + + raylib.addTo(b, exe, target.query, optimize, .{}); + + // This declares intent for the executable to be installed into the + // standard location when the user invokes the "install" step (the default + // step when running `zig build`). + b.installArtifact(exe); + + // This *creates* a Run step in the build graph, to be executed when another + // step is evaluated that depends on it. The next line below will establish + // such a dependency. + const run_cmd = b.addRunArtifact(exe); + + // By making the run step depend on the install step, it will be run from the + // installation directory rather than directly from within the cache directory. + // This is not necessary, however, if the application depends on other installed + // files, this ensures they will be present and in the expected location. + run_cmd.step.dependOn(b.getInstallStep()); + + // This allows the user to pass arguments to the application in the build + // command itself, like this: `zig build run -- arg1 arg2 etc` + if (b.args) |args| { + run_cmd.addArgs(args); + } + + // This creates a build step. It will be visible in the `zig build --help` menu, + // and can be selected like this: `zig build run` + // This will evaluate the `run` step rather than the default, which is "install". + const run_step = b.step("run", "Run the app"); + run_step.dependOn(&run_cmd.step); + + const exe_unit_tests = b.addTest(.{ + .root_source_file = .{ .path = "src/main.zig" }, + .target = target, + .optimize = optimize, + }); + + const run_exe_unit_tests = b.addRunArtifact(exe_unit_tests); + + // Similar to creating the run step earlier, this exposes a `test` step to + // the `zig build --help` menu, providing a way for the user to request + // running the unit tests. + const test_step = b.step("test", "Run unit tests"); + test_step.dependOn(&run_exe_unit_tests.step); +} diff --git a/samples/hello-world/build.zig.zon b/samples/hello-world/build.zig.zon new file mode 100644 index 0000000..aafc739 --- /dev/null +++ b/samples/hello-world/build.zig.zon @@ -0,0 +1,62 @@ +.{ + .name = "hello-world", + // This is a [Semantic Version](https://semver.org/). + // In a future version of Zig it will be used for package deduplication. + .version = "0.0.0", + + // This field is optional. + // This is currently advisory only; Zig does not yet do anything + // with this value. + //.minimum_zig_version = "0.11.0", + + // This field is optional. + // Each dependency must either provide a `url` and `hash`, or a `path`. + // `zig build --fetch` can be used to fetch all dependencies of a package, recursively. + // Once all dependencies are fetched, `zig build` no longer requires + // internet connectivity. + .dependencies = .{ + // See `zig fetch --save ` for a command-line interface for adding dependencies. + //.example = .{ + // // When updating this field to a new URL, be sure to delete the corresponding + // // `hash`, otherwise you are communicating that you expect to find the old hash at + // // the new URL. + // .url = "https://example.com/foo.tar.gz", + // + // // This is computed from the file contents of the directory of files that is + // // obtained after fetching `url` and applying the inclusion rules given by + // // `paths`. + // // + // // This field is the source of truth; packages do not come from a `url`; they + // // come from a `hash`. `url` is just one of many possible mirrors for how to + // // obtain a package matching this `hash`. + // // + // // Uses the [multihash](https://multiformats.io/multihash/) format. + // .hash = "...", + // + // // When this is provided, the package is found in a directory relative to the + // // build root. In this case the package's hash is irrelevant and therefore not + // // computed. This field and `url` are mutually exclusive. + // .path = "foo", + //}, + }, + + // Specifies the set of files and directories that are included in this package. + // Only files and directories listed here are included in the `hash` that + // is computed for this package. + // Paths are relative to the build root. Use the empty string (`""`) to refer to + // the build root itself. + // A directory listed here means that all files within, recursively, are included. + .paths = .{ + // This makes *all* files, recursively, included in this package. It is generally + // better to explicitly list the files and directories instead, to insure that + // fetching from tarballs, file system paths, and version control all result + // in the same contents hash. + // "", + // For example... + "build.zig", + "build.zig.zon", + "src", + //"LICENSE", + //"README.md", + }, +} diff --git a/samples/hello-world/ext/raylib.zig b/samples/hello-world/ext/raylib.zig new file mode 120000 index 0000000..1b20c9f --- /dev/null +++ b/samples/hello-world/ext/raylib.zig @@ -0,0 +1 @@ +../../../ \ No newline at end of file diff --git a/samples/hello-world/src/main.zig b/samples/hello-world/src/main.zig new file mode 100644 index 0000000..0217e34 --- /dev/null +++ b/samples/hello-world/src/main.zig @@ -0,0 +1,20 @@ +const std = @import("std"); +const raylib = @import("raylib"); + +pub fn main() void { + raylib.SetConfigFlags(raylib.ConfigFlags{ .FLAG_WINDOW_RESIZABLE = true }); + raylib.InitWindow(800, 800, "hello world!"); + raylib.SetTargetFPS(60); + + defer raylib.CloseWindow(); + + while (!raylib.WindowShouldClose()) { + raylib.BeginDrawing(); + defer raylib.EndDrawing(); + + raylib.ClearBackground(raylib.BLACK); + raylib.DrawFPS(10, 10); + + raylib.DrawText("hello world!", 100, 100, 20, raylib.YELLOW); + } +} diff --git a/samples/hello-world/zig-out/bin/hello-world b/samples/hello-world/zig-out/bin/hello-world new file mode 100755 index 0000000..47af3bf Binary files /dev/null and b/samples/hello-world/zig-out/bin/hello-world differ diff --git a/type_mapping.zig b/type_mapping.zig index 6131e59..81aedda 100644 --- a/type_mapping.zig +++ b/type_mapping.zig @@ -85,7 +85,7 @@ pub const Intermediate = struct { continue :outer; } } - const define = parseRaylibDefine(allocator, d) orelse continue :outer; + const define = try parseRaylibDefine(allocator, d) orelse continue :outer; if (i < defines.items.len) { try defines.insert(i, define); @@ -248,31 +248,38 @@ pub const Define = struct { custom: bool = false, }; -pub fn parseRaylibDefine(allocator: Allocator, s: RaylibDefine) ?Define { +pub fn parseRaylibDefine(allocator: Allocator, s: RaylibDefine) !?Define { var typ: []const u8 = undefined; var value: []const u8 = undefined; + const strValue = try jsonStringify(allocator, s.value); + defer allocator.free(strValue); if (eql("INT", s.type)) { typ = "i32"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("i32: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("LONG", s.type)) { typ = "i64"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("i64: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("FLOAT", s.type)) { typ = "f32"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("f32: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("DOUBLE", s.type)) { typ = "f64"; - value = std.fmt.allocPrint(allocator, "{s}", .{s.value}) catch return null; + std.debug.print("f64: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "{s}", .{strValue}) catch return null; } else if (eql("STRING", s.type)) { typ = "[]const u8"; - value = std.fmt.allocPrint(allocator, "\"{s}\"", .{s.value}) catch return null; + std.debug.print("[]const u8: {s}", .{strValue}); + value = std.fmt.allocPrint(allocator, "\"{s}\"", .{strValue}) catch return null; } else if (eql("COLOR", s.type)) { typ = "Color"; - std.debug.assert(startsWith(s.value, "CLITERAL(Color){")); - std.debug.assert(endsWith(s.value, "}")); + std.debug.assert(startsWith(strValue, "CLITERAL(Color){")); + std.debug.assert(endsWith(strValue, "}")); - const componentString = s.value["CLITERAL(Color){".len .. s.value.len - 1]; + const componentString = strValue["CLITERAL(Color){".len .. strValue.len - 1]; var spliterator = std.mem.split(u8, componentString, ","); var r = spliterator.next() orelse return null; r = std.mem.trim(u8, r, " \t\r\n"); @@ -651,7 +658,7 @@ pub const RaylibFunctionParam = struct { pub const RaylibDefine = struct { name: []const u8, type: []const u8, - value: []const u8, + value: std.json.Value, description: ?[]const u8 = null, }; @@ -689,3 +696,8 @@ fn startsWith(haystack: []const u8, needle: []const u8) bool { fn endsWith(haystack: []const u8, needle: []const u8) bool { return std.mem.endsWith(u8, haystack, needle); } + +fn jsonStringify(allocator: Allocator, value: std.json.Value) ![]const u8 { + const jsonString = try json.stringifyAlloc(allocator, value, .{}); + return std.mem.trim(u8, jsonString, "\""); +}