From c1d01c193f6bcfb974df1a65d6a6cb2d23d3bf20 Mon Sep 17 00:00:00 2001 From: Not-Nik Date: Sat, 9 May 2020 21:01:28 +1000 Subject: [PATCH] Function bindings are completely automated now --- .gitignore | 4 +- build.zig | 2 +- lib/generate_functions.py | 188 +++++ lib/raylib-wa.zig | 1062 ++++++++++++++++++++++++ lib/raylib-zig-math.zig | 150 ++-- lib/raylib-zig.zig | 702 +--------------- lib/workaround.c | 720 ++++++++++++++++ lib/workaround/cfunctions | 44 - lib/workaround/generate_c_functions.py | 138 --- lib/workaround/workaround.c | 219 ----- lib/workaround/workaround.zig | 259 ------ projectSetup.sh | 13 +- raylib-headers/math-funcs.py | 61 -- tests/draw_sphere.zig | 2 +- 14 files changed, 2064 insertions(+), 1500 deletions(-) create mode 100644 lib/generate_functions.py create mode 100644 lib/raylib-wa.zig create mode 100644 lib/workaround.c delete mode 100644 lib/workaround/cfunctions delete mode 100644 lib/workaround/generate_c_functions.py delete mode 100644 lib/workaround/workaround.c delete mode 100644 lib/workaround/workaround.zig delete mode 100644 raylib-headers/math-funcs.py diff --git a/.gitignore b/.gitignore index e441bdb..0776e83 100755 --- a/.gitignore +++ b/.gitignore @@ -1,9 +1,9 @@ zig-cache/ .idea/ Project/* -raylib-headers/raylib.h -raylib-headers/raymath.h +**/raylib.h +**/raymath.h **/.DS_Store **/CMakeLists.txt **/cmake-build-debug diff --git a/build.zig b/build.zig index 703d180..117bdb7 100755 --- a/build.zig +++ b/build.zig @@ -15,7 +15,7 @@ pub fn createExe(b: *Builder, name: []const u8, source: []const u8, desc: []cons var exe = b.addExecutable(name, source); exe.setBuildMode(mode); exe.linkSystemLibrary("raylib"); - exe.addCSourceFile("lib/workaround/workaround.c", &[_][]const u8{}); + exe.addCSourceFile("lib/workaround.c", &[_][]const u8{}); exe.addPackagePath("raylib", "lib/raylib-zig.zig"); exe.addPackagePath("raylib-math", "lib/raylib-zig-math.zig"); diff --git a/lib/generate_functions.py b/lib/generate_functions.py new file mode 100644 index 0000000..c30028e --- /dev/null +++ b/lib/generate_functions.py @@ -0,0 +1,188 @@ +import re +import sys + +""" +Automatic utility for generating functions, including workaround functions +to fix Zig's issue with C ABI struct parameters. Simply put raylib.h in the +working directory of this script and execute. You'll get a workaround.c and +workaround.zig. The first has to be added as a C source and the latter has +to be included in raylib-zig.zig. Tested with raylib version 3.0.0 +""" + + +# Some c types have a different size on different systems +# and zig knows that so we tell it to get the system specific size for us +def c_to_zig_type(t: str) -> str: + t = t.replace("const ", "") + if t == "float": + t = "f32" + if t == "int": + t = "c_int" + if t == "unsigned int": + t = "c_uint" + if t == "long": + t = "c_long" + if t == "char": + t = "u8" + if t == "unsigned char": + t = "u8" + return t + + +def fix_pointer(name: str, t: str): + t = t.replace("const ", "") + pre = "" + while name.startswith("*"): + name = name[1:] + pre += "[*c]" + if len(pre) != 0: + t = pre + "const " + t + return name, t + + +small_structs = ["Vector2", "Vector3", "Vector4", "Quaternion", "Color", "Rectangle", "Shader"] +c_functions = [] + + +def parse_header(header_name: str, output_file: str, prefix: str): + header = open(header_name, mode="r") + zig_functions = [] + zig_heads = [] + + for line in header.readlines(): + if not line.startswith(prefix): + continue + + line = line.split(";", 1)[0] + # each (.*) is some variable value + result = re.search(prefix + "(.*) (.*)start_arg(.*)end_arg(.*)", line.replace("(", "start_arg").replace(")", "end_arg")) + + # get whats in the (.*)'s + return_type = result.group(1) + func_name = result.group(2) + arguments = result.group(3) + + if "..." in arguments or return_type in small_structs or return_type == "float3" or return_type == "float16": + continue + + for struct in small_structs: + if struct in arguments: + break + else: # we found a completely normal function + return_type = c_to_zig_type(return_type) + func_name, return_type = fix_pointer(func_name, return_type) + + zig_arguments = [] + for arg in arguments.split(", "): + if arg == "void": + break + arg_type = " ".join(arg.split(" ")[0:-1]) # everything but the last element (for stuff like "const Vector3") + arg_type = arg_type.replace("const ", "") # zig doesn't like const in function arguments that aren't pointer and really we don't need const + arg_name = arg.split(" ")[-1] # last element should be the name + + arg_type = c_to_zig_type(arg_type) + arg_name, arg_type = fix_pointer(arg_name, arg_type) + zig_arguments.append(arg_name + ": " + arg_type) # put everything together + zig_arguments = ", ".join(zig_arguments) + zig_heads.append("pub extern fn " + func_name + "(" + zig_arguments + ") " + return_type + ";") + continue + + zig_arguments_w = [] # arguments for the workaround function head on the zig side + zig_arguments = [] # arguments that are passed to the copied raylib function + zig_pass = [] # arguments that are passed to the workaround function on the zig side + c_arguments = [] # arguments for the workaround function head on the c side + c_pass = [] # arguments that are passed to the actual raylib function + + for arg in arguments.split(", "): + if arg == "void": break + arg_type = " ".join(arg.split(" ")[0:-1]).replace("const ", "") # everything but the last element (for stuff like "const Vector3"), but discarding const + arg_name = arg.split(" ")[-1] # last element should be the name + depoint = False # set to true if we need to dereference a pointer to a small struct in the c workaround + if arg_type in small_structs: + if not arg_name.startswith("*"): + depoint = True + + if depoint: + arg_name = "*" + arg_name # dereference the arguments + + c_arguments.append(arg_type + " " + arg_name) + if arg_name.startswith("*") and not depoint: # That's in case of an actual array + c_name = arg_name + while c_name.startswith("*"): + c_name = c_name[1:] + c_pass.append(c_name) # We don't want to dereference the array + else: + c_pass.append(arg_name) + + # zig conversions + zig_type = c_to_zig_type(arg_type) + zig_name = arg_name + + if depoint and zig_name.startswith("*"): # These are the arguments without pointers + zig_name = zig_name[1:] + zig_pass_name = "&" + zig_name + elif zig_name.startswith("*") and not depoint: # That's in case of an actual array + zig_name = zig_name[1:] + if zig_name.startswith("*"): + zig_name = zig_name[1:] + zig_type = "[*c][]const " + zig_type + else: + zig_type = "[]const " + zig_type + zig_pass_name = "&" + zig_name + "[0]" + else: # Normal argument i.e. float, int, etc. + zig_pass_name = zig_name + zig_arguments.append(zig_name + ": " + zig_type) # put everything together + zig_pass.append(zig_pass_name) + + # These are the arguments for the extern workaround functions with pointers + arg_type = c_to_zig_type(arg_type) + arg_name, arg_type = fix_pointer(arg_name, arg_type) + zig_arguments_w.append(arg_name + ": " + arg_type) # put everything together + + # Workaround function head in zig + zig_arguments_w = ", ".join(zig_arguments_w) + zig_ret_type = c_to_zig_type(return_type) + zig_func_name, zig_ret_type = fix_pointer(func_name, zig_ret_type) + zig_heads.append("pub extern fn W" + func_name + "(" + zig_arguments_w + ") " + return_type + ";") + + # Create the function to call the workaround + zig_arguments = ", ".join(zig_arguments) + zig_pass = ", ".join(zig_pass) + function = "pub fn " + func_name + "(" + zig_arguments + ") " + return_type + "\n" + function += "{\n" + if return_type != "void": + function += " return W" + func_name + "(" + zig_pass + ");\n" + else: + function += " W" + func_name + "(" + zig_pass + ");\n" + function += "}\n" + zig_functions.append(function) + + # Create workaround function + c_arguments = ", ".join(c_arguments) + c_pass = ", ".join(c_pass) + function = return_type + " W" + func_name + "(" + c_arguments + ")\n" + function += "{\n" + if return_type != "void": + function += " return " + func_name + "(" + c_pass + ");\n" + else: + function += " " + func_name + "(" + c_pass + ");\n" + function += "}\n" + c_functions.append(function) + + zigheader = open(output_file, mode="w") + print("usingnamespace @import(\"raylib-zig.zig\");\n", file=zigheader) + + print("\n".join(zig_heads), file=zigheader) + print("", file=zigheader) + print("\n".join(zig_functions), file=zigheader) + + +parse_header("raylib.h", "raylib-wa.zig", "RLAPI ") +parse_header("raymath.h", "raylib-zig-math.zig", "RMDEF ") + +workaround = open("workaround.c", mode="w") +print("// raylib-zig (c) Nikolas Wipper 2020\n", file=workaround) +print("#include ", file=workaround) +print("#include \n", file=workaround) + +print("\n".join(c_functions), file=workaround) diff --git a/lib/raylib-wa.zig b/lib/raylib-wa.zig new file mode 100644 index 0000000..eacd3bc --- /dev/null +++ b/lib/raylib-wa.zig @@ -0,0 +1,1062 @@ +usingnamespace @import("raylib-zig.zig"); + +pub extern fn InitWindow(width: c_int, height: c_int, title: [*c]const u8) void; +pub extern fn WindowShouldClose() bool; +pub extern fn CloseWindow() void; +pub extern fn IsWindowReady() bool; +pub extern fn IsWindowMinimized() bool; +pub extern fn IsWindowResized() bool; +pub extern fn IsWindowHidden() bool; +pub extern fn IsWindowFullscreen() bool; +pub extern fn ToggleFullscreen() void; +pub extern fn UnhideWindow() void; +pub extern fn HideWindow() void; +pub extern fn SetWindowIcon(image: Image) void; +pub extern fn SetWindowTitle(title: [*c]const u8) void; +pub extern fn SetWindowPosition(x: c_int, y: c_int) void; +pub extern fn SetWindowMonitor(monitor: c_int) void; +pub extern fn SetWindowMinSize(width: c_int, height: c_int) void; +pub extern fn SetWindowSize(width: c_int, height: c_int) void; +pub extern fn GetWindowHandle() [*c]const void; +pub extern fn GetScreenWidth() c_int; +pub extern fn GetScreenHeight() c_int; +pub extern fn GetMonitorCount() c_int; +pub extern fn GetMonitorWidth(monitor: c_int) c_int; +pub extern fn GetMonitorHeight(monitor: c_int) c_int; +pub extern fn GetMonitorPhysicalWidth(monitor: c_int) c_int; +pub extern fn GetMonitorPhysicalHeight(monitor: c_int) c_int; +pub extern fn GetMonitorName(monitor: c_int) [*c]const u8; +pub extern fn GetClipboardText() [*c]const u8; +pub extern fn SetClipboardText(text: [*c]const u8) void; +pub extern fn ShowCursor() void; +pub extern fn HideCursor() void; +pub extern fn IsCursorHidden() bool; +pub extern fn EnableCursor() void; +pub extern fn DisableCursor() void; +pub extern fn WClearBackground(color: [*c]const Color) void; +pub extern fn BeginDrawing() void; +pub extern fn EndDrawing() void; +pub extern fn BeginMode2D(camera: Camera2D) void; +pub extern fn EndMode2D() void; +pub extern fn BeginMode3D(camera: Camera3D) void; +pub extern fn EndMode3D() void; +pub extern fn BeginTextureMode(target: RenderTexture2D) void; +pub extern fn EndTextureMode() void; +pub extern fn BeginScissorMode(x: c_int, y: c_int, width: c_int, height: c_int) void; +pub extern fn EndScissorMode() void; +pub extern fn WGetMouseRay(mousePosition: [*c]const Vector2, camera: Camera) Ray; +pub extern fn GetCameraMatrix(camera: Camera) Matrix; +pub extern fn GetCameraMatrix2D(camera: Camera2D) Matrix; +pub extern fn SetTargetFPS(fps: c_int) void; +pub extern fn GetFPS() c_int; +pub extern fn GetFrameTime() f32; +pub extern fn GetTime() double; +pub extern fn WColorToInt(color: [*c]const Color) int; +pub extern fn SetConfigFlags(flags: c_uint) void; +pub extern fn SetTraceLogLevel(logType: c_int) void; +pub extern fn SetTraceLogExit(logType: c_int) void; +pub extern fn SetTraceLogCallback(callback: TraceLogCallback) void; +pub extern fn TakeScreenshot(fileName: [*c]const u8) void; +pub extern fn GetRandomValue(min: c_int, max: c_int) c_int; +pub extern fn LoadFileData(fileName: [*c]const u8, bytesRead: [*c]const c_uint) [*c]const u8; +pub extern fn SaveFileData(fileName: [*c]const u8, data: [*c]const void, bytesToWrite: c_uint) void; +pub extern fn LoadFileText(fileName: [*c]const u8) [*c]const u8; +pub extern fn SaveFileText(fileName: [*c]const u8, text: [*c]const u8) void; +pub extern fn FileExists(fileName: [*c]const u8) bool; +pub extern fn IsFileExtension(fileName: [*c]const u8, ext: [*c]const u8) bool; +pub extern fn DirectoryExists(dirPath: [*c]const u8) bool; +pub extern fn GetExtension(fileName: [*c]const u8) [*c]const u8; +pub extern fn GetFileName(filePath: [*c]const u8) [*c]const u8; +pub extern fn GetFileNameWithoutExt(filePath: [*c]const u8) [*c]const u8; +pub extern fn GetDirectoryPath(filePath: [*c]const u8) [*c]const u8; +pub extern fn GetPrevDirectoryPath(dirPath: [*c]const u8) [*c]const u8; +pub extern fn GetWorkingDirectory() [*c]const u8; +pub extern fn GetDirectoryFiles(dirPath: [*c]const u8, count: [*c]const c_int) [*c][*c]const u8; +pub extern fn ClearDirectoryFiles() void; +pub extern fn ChangeDirectory(dir: [*c]const u8) bool; +pub extern fn IsFileDropped() bool; +pub extern fn GetDroppedFiles(count: [*c]const c_int) [*c][*c]const u8; +pub extern fn ClearDroppedFiles() void; +pub extern fn GetFileModTime(fileName: [*c]const u8) c_long; +pub extern fn CompressData(data: [*c]const u8, dataLength: c_int, compDataLength: [*c]const c_int) [*c]const u8; +pub extern fn DecompressData(compData: [*c]const u8, compDataLength: c_int, dataLength: [*c]const c_int) [*c]const u8; +pub extern fn SaveStorageValue(position: c_uint, value: c_int) void; +pub extern fn LoadStorageValue(position: c_uint) c_int; +pub extern fn OpenURL(url: [*c]const u8) void; +pub extern fn IsKeyPressed(key: c_int) bool; +pub extern fn IsKeyDown(key: c_int) bool; +pub extern fn IsKeyReleased(key: c_int) bool; +pub extern fn IsKeyUp(key: c_int) bool; +pub extern fn SetExitKey(key: c_int) void; +pub extern fn GetKeyPressed() c_int; +pub extern fn IsGamepadAvailable(gamepad: c_int) bool; +pub extern fn IsGamepadName(gamepad: c_int, name: [*c]const u8) bool; +pub extern fn GetGamepadName(gamepad: c_int) [*c]const u8; +pub extern fn IsGamepadButtonPressed(gamepad: c_int, button: c_int) bool; +pub extern fn IsGamepadButtonDown(gamepad: c_int, button: c_int) bool; +pub extern fn IsGamepadButtonReleased(gamepad: c_int, button: c_int) bool; +pub extern fn IsGamepadButtonUp(gamepad: c_int, button: c_int) bool; +pub extern fn GetGamepadButtonPressed() c_int; +pub extern fn GetGamepadAxisCount(gamepad: c_int) c_int; +pub extern fn GetGamepadAxisMovement(gamepad: c_int, axis: c_int) f32; +pub extern fn IsMouseButtonPressed(button: c_int) bool; +pub extern fn IsMouseButtonDown(button: c_int) bool; +pub extern fn IsMouseButtonReleased(button: c_int) bool; +pub extern fn IsMouseButtonUp(button: c_int) bool; +pub extern fn GetMouseX() c_int; +pub extern fn GetMouseY() c_int; +pub extern fn SetMousePosition(x: c_int, y: c_int) void; +pub extern fn SetMouseOffset(offsetX: c_int, offsetY: c_int) void; +pub extern fn SetMouseScale(scaleX: f32, scaleY: f32) void; +pub extern fn GetMouseWheelMove() c_int; +pub extern fn GetTouchX() c_int; +pub extern fn GetTouchY() c_int; +pub extern fn SetGesturesEnabled(gestureFlags: c_uint) void; +pub extern fn IsGestureDetected(gesture: c_int) bool; +pub extern fn GetGestureDetected() c_int; +pub extern fn GetTouchPointsCount() c_int; +pub extern fn GetGestureHoldDuration() f32; +pub extern fn GetGestureDragAngle() f32; +pub extern fn GetGesturePinchAngle() f32; +pub extern fn SetCameraMode(camera: Camera, mode: c_int) void; +pub extern fn UpdateCamera(camera: [*c]const Camera) void; +pub extern fn SetCameraPanControl(panKey: c_int) void; +pub extern fn SetCameraAltControl(altKey: c_int) void; +pub extern fn SetCameraSmoothZoomControl(szKey: c_int) void; +pub extern fn SetCameraMoveControls(frontKey: c_int, backKey: c_int, rightKey: c_int, leftKey: c_int, upKey: c_int, downKey: c_int) void; +pub extern fn WDrawPixel(posX: c_int, posY: c_int, color: [*c]const Color) void; +pub extern fn WDrawPixelV(position: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WDrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: [*c]const Color) void; +pub extern fn WDrawLineV(startPos: [*c]const Vector2, endPos: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WDrawLineEx(startPos: [*c]const Vector2, endPos: [*c]const Vector2, thick: f32, color: [*c]const Color) void; +pub extern fn WDrawLineBezier(startPos: [*c]const Vector2, endPos: [*c]const Vector2, thick: f32, color: [*c]const Color) void; +pub extern fn WDrawLineStrip(points: [*c]const Vector2, numPoints: c_int, color: [*c]const Color) void; +pub extern fn WDrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: [*c]const Color) void; +pub extern fn WDrawCircleSector(center: [*c]const Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; +pub extern fn WDrawCircleSectorLines(center: [*c]const Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; +pub extern fn WDrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: [*c]const Color, color2: [*c]const Color) void; +pub extern fn WDrawCircleV(center: [*c]const Vector2, radius: f32, color: [*c]const Color) void; +pub extern fn WDrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: [*c]const Color) void; +pub extern fn WDrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: [*c]const Color) void; +pub extern fn WDrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: [*c]const Color) void; +pub extern fn WDrawRing(center: [*c]const Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; +pub extern fn WDrawRingLines(center: [*c]const Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; +pub extern fn WDrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: [*c]const Color) void; +pub extern fn WDrawRectangleV(position: [*c]const Vector2, size: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WDrawRectangleRec(rec: [*c]const Rectangle, color: [*c]const Color) void; +pub extern fn WDrawRectanglePro(rec: [*c]const Rectangle, origin: [*c]const Vector2, rotation: f32, color: [*c]const Color) void; +pub extern fn WDrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: [*c]const Color, color2: [*c]const Color) void; +pub extern fn WDrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: [*c]const Color, color2: [*c]const Color) void; +pub extern fn WDrawRectangleGradientEx(rec: [*c]const Rectangle, col1: [*c]const Color, col2: [*c]const Color, col3: [*c]const Color, col4: [*c]const Color) void; +pub extern fn WDrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: [*c]const Color) void; +pub extern fn WDrawRectangleLinesEx(rec: [*c]const Rectangle, lineThick: c_int, color: [*c]const Color) void; +pub extern fn WDrawRectangleRounded(rec: [*c]const Rectangle, roundness: f32, segments: c_int, color: [*c]const Color) void; +pub extern fn WDrawRectangleRoundedLines(rec: [*c]const Rectangle, roundness: f32, segments: c_int, lineThick: c_int, color: [*c]const Color) void; +pub extern fn WDrawTriangle(v1: [*c]const Vector2, v2: [*c]const Vector2, v3: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WDrawTriangleLines(v1: [*c]const Vector2, v2: [*c]const Vector2, v3: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WDrawTriangleFan(points: [*c]const Vector2, numPoints: c_int, color: [*c]const Color) void; +pub extern fn WDrawTriangleStrip(points: [*c]const Vector2, pointsCount: c_int, color: [*c]const Color) void; +pub extern fn WDrawPoly(center: [*c]const Vector2, sides: c_int, radius: f32, rotation: f32, color: [*c]const Color) void; +pub extern fn WDrawPolyLines(center: [*c]const Vector2, sides: c_int, radius: f32, rotation: f32, color: [*c]const Color) void; +pub extern fn WCheckCollisionRecs(rec1: [*c]const Rectangle, rec2: [*c]const Rectangle) bool; +pub extern fn WCheckCollisionCircles(center1: [*c]const Vector2, radius1: f32, center2: [*c]const Vector2, radius2: f32) bool; +pub extern fn WCheckCollisionCircleRec(center: [*c]const Vector2, radius: f32, rec: [*c]const Rectangle) bool; +pub extern fn WCheckCollisionPointRec(point: [*c]const Vector2, rec: [*c]const Rectangle) bool; +pub extern fn WCheckCollisionPointCircle(point: [*c]const Vector2, center: [*c]const Vector2, radius: f32) bool; +pub extern fn WCheckCollisionPointTriangle(point: [*c]const Vector2, p1: [*c]const Vector2, p2: [*c]const Vector2, p3: [*c]const Vector2) bool; +pub extern fn LoadImage(fileName: [*c]const u8) Image; +pub extern fn WLoadImageEx(pixels: [*c]const Color, width: c_int, height: c_int) Image; +pub extern fn LoadImagePro(data: [*c]const void, width: c_int, height: c_int, format: c_int) Image; +pub extern fn LoadImageRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: c_int, headerSize: c_int) Image; +pub extern fn UnloadImage(image: Image) void; +pub extern fn ExportImage(image: Image, fileName: [*c]const u8) void; +pub extern fn ExportImageAsCode(image: Image, fileName: [*c]const u8) void; +pub extern fn WGenImageColor(width: c_int, height: c_int, color: [*c]const Color) Image; +pub extern fn WGenImageGradientV(width: c_int, height: c_int, top: [*c]const Color, bottom: [*c]const Color) Image; +pub extern fn WGenImageGradientH(width: c_int, height: c_int, left: [*c]const Color, right: [*c]const Color) Image; +pub extern fn WGenImageGradientRadial(width: c_int, height: c_int, density: f32, inner: [*c]const Color, outer: [*c]const Color) Image; +pub extern fn WGenImageChecked(width: c_int, height: c_int, checksX: c_int, checksY: c_int, col1: [*c]const Color, col2: [*c]const Color) Image; +pub extern fn GenImageWhiteNoise(width: c_int, height: c_int, factor: f32) Image; +pub extern fn GenImagePerlinNoise(width: c_int, height: c_int, offsetX: c_int, offsetY: c_int, scale: f32) Image; +pub extern fn GenImageCellular(width: c_int, height: c_int, tileSize: c_int) Image; +pub extern fn ImageCopy(image: Image) Image; +pub extern fn WImageFromImage(image: Image, rec: [*c]const Rectangle) Image; +pub extern fn WImageText(text: [*c]const u8, fontSize: c_int, color: [*c]const Color) Image; +pub extern fn WImageTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32, tint: [*c]const Color) Image; +pub extern fn WImageToPOT(image: [*c]const Image, fillColor: [*c]const Color) void; +pub extern fn ImageFormat(image: [*c]const Image, newFormat: c_int) void; +pub extern fn ImageAlphaMask(image: [*c]const Image, alphaMask: Image) void; +pub extern fn WImageAlphaClear(image: [*c]const Image, color: [*c]const Color, threshold: f32) void; +pub extern fn ImageAlphaCrop(image: [*c]const Image, threshold: f32) void; +pub extern fn ImageAlphaPremultiply(image: [*c]const Image) void; +pub extern fn WImageCrop(image: [*c]const Image, crop: [*c]const Rectangle) void; +pub extern fn ImageResize(image: [*c]const Image, newWidth: c_int, newHeight: c_int) void; +pub extern fn ImageResizeNN(image: [*c]const Image, newWidth: c_int, newHeight: c_int) void; +pub extern fn WImageResizeCanvas(image: [*c]const Image, newWidth: c_int, newHeight: c_int, offsetX: c_int, offsetY: c_int, color: [*c]const Color) void; +pub extern fn ImageMipmaps(image: [*c]const Image) void; +pub extern fn ImageDither(image: [*c]const Image, rBpp: c_int, gBpp: c_int, bBpp: c_int, aBpp: c_int) void; +pub extern fn ImageFlipVertical(image: [*c]const Image) void; +pub extern fn ImageFlipHorizontal(image: [*c]const Image) void; +pub extern fn ImageRotateCW(image: [*c]const Image) void; +pub extern fn ImageRotateCCW(image: [*c]const Image) void; +pub extern fn WImageColorTint(image: [*c]const Image, color: [*c]const Color) void; +pub extern fn ImageColorInvert(image: [*c]const Image) void; +pub extern fn ImageColorGrayscale(image: [*c]const Image) void; +pub extern fn ImageColorContrast(image: [*c]const Image, contrast: f32) void; +pub extern fn ImageColorBrightness(image: [*c]const Image, brightness: c_int) void; +pub extern fn WImageColorReplace(image: [*c]const Image, color: [*c]const Color, replace: [*c]const Color) void; +pub extern fn WImageClearBackground(dst: [*c]const Image, color: [*c]const Color) void; +pub extern fn WImageDrawPixel(dst: [*c]const Image, posX: c_int, posY: c_int, color: [*c]const Color) void; +pub extern fn WImageDrawPixelV(dst: [*c]const Image, position: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WImageDrawLine(dst: [*c]const Image, startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: [*c]const Color) void; +pub extern fn WImageDrawLineV(dst: [*c]const Image, start: [*c]const Vector2, end: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WImageDrawCircle(dst: [*c]const Image, centerX: c_int, centerY: c_int, radius: c_int, color: [*c]const Color) void; +pub extern fn WImageDrawCircleV(dst: [*c]const Image, center: [*c]const Vector2, radius: c_int, color: [*c]const Color) void; +pub extern fn WImageDrawRectangle(dst: [*c]const Image, posX: c_int, posY: c_int, width: c_int, height: c_int, color: [*c]const Color) void; +pub extern fn WImageDrawRectangleV(dst: [*c]const Image, position: [*c]const Vector2, size: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WImageDrawRectangleRec(dst: [*c]const Image, rec: [*c]const Rectangle, color: [*c]const Color) void; +pub extern fn WImageDrawRectangleLines(dst: [*c]const Image, rec: [*c]const Rectangle, thick: c_int, color: [*c]const Color) void; +pub extern fn WImageDraw(dst: [*c]const Image, src: Image, srcRec: [*c]const Rectangle, dstRec: [*c]const Rectangle, tint: [*c]const Color) void; +pub extern fn WImageDrawText(dst: [*c]const Image, position: [*c]const Vector2, text: [*c]const u8, fontSize: c_int, color: [*c]const Color) void; +pub extern fn WImageDrawTextEx(dst: [*c]const Image, position: [*c]const Vector2, font: Font, text: [*c]const u8, fontSize: f32, spacing: f32, color: [*c]const Color) void; +pub extern fn LoadTexture(fileName: [*c]const u8) Texture2D; +pub extern fn LoadTextureFromImage(image: Image) Texture2D; +pub extern fn LoadTextureCubemap(image: Image, layoutType: c_int) TextureCubemap; +pub extern fn LoadRenderTexture(width: c_int, height: c_int) RenderTexture2D; +pub extern fn UnloadTexture(texture: Texture2D) void; +pub extern fn UnloadRenderTexture(target: RenderTexture2D) void; +pub extern fn UpdateTexture(texture: Texture2D, pixels: [*c]const void) void; +pub extern fn GetTextureData(texture: Texture2D) Image; +pub extern fn GetScreenData() Image; +pub extern fn GenTextureMipmaps(texture: [*c]const Texture2D) void; +pub extern fn SetTextureFilter(texture: Texture2D, filterMode: c_int) void; +pub extern fn SetTextureWrap(texture: Texture2D, wrapMode: c_int) void; +pub extern fn WDrawTexture(texture: Texture2D, posX: c_int, posY: c_int, tint: [*c]const Color) void; +pub extern fn WDrawTextureV(texture: Texture2D, position: [*c]const Vector2, tint: [*c]const Color) void; +pub extern fn WDrawTextureEx(texture: Texture2D, position: [*c]const Vector2, rotation: f32, scale: f32, tint: [*c]const Color) void; +pub extern fn WDrawTextureRec(texture: Texture2D, sourceRec: [*c]const Rectangle, position: [*c]const Vector2, tint: [*c]const Color) void; +pub extern fn WDrawTextureQuad(texture: Texture2D, tiling: [*c]const Vector2, offset: [*c]const Vector2, quad: [*c]const Rectangle, tint: [*c]const Color) void; +pub extern fn WDrawTexturePro(texture: Texture2D, sourceRec: [*c]const Rectangle, destRec: [*c]const Rectangle, origin: [*c]const Vector2, rotation: f32, tint: [*c]const Color) void; +pub extern fn WDrawTextureNPatch(texture: Texture2D, nPatchInfo: NPatchInfo, destRec: [*c]const Rectangle, origin: [*c]const Vector2, rotation: f32, tint: [*c]const Color) void; +pub extern fn GetPixelDataSize(width: c_int, height: c_int, format: c_int) c_int; +pub extern fn GetFontDefault() Font; +pub extern fn LoadFont(fileName: [*c]const u8) Font; +pub extern fn LoadFontEx(fileName: [*c]const u8, fontSize: c_int, fontChars: [*c]const c_int, charsCount: c_int) Font; +pub extern fn WLoadFontFromImage(image: Image, key: [*c]const Color, firstChar: c_int) Font; +pub extern fn LoadFontData(fileName: [*c]const u8, fontSize: c_int, fontChars: [*c]const c_int, charsCount: c_int, type: c_int) [*c]const CharInfo; +pub extern fn WGenImageFontAtlas(chars: [*c]const CharInfo, recs: [*c][*c]const Rectangle, charsCount: c_int, fontSize: c_int, padding: c_int, packMethod: c_int) Image; +pub extern fn UnloadFont(font: Font) void; +pub extern fn DrawFPS(posX: c_int, posY: c_int) void; +pub extern fn WDrawText(text: [*c]const u8, posX: c_int, posY: c_int, fontSize: c_int, color: [*c]const Color) void; +pub extern fn WDrawTextEx(font: Font, text: [*c]const u8, position: [*c]const Vector2, fontSize: f32, spacing: f32, tint: [*c]const Color) void; +pub extern fn WDrawTextRec(font: Font, text: [*c]const u8, rec: [*c]const Rectangle, fontSize: f32, spacing: f32, wordWrap: bool, tint: [*c]const Color) void; +pub extern fn WDrawTextRecEx(font: Font, text: [*c]const u8, rec: [*c]const Rectangle, fontSize: f32, spacing: f32, wordWrap: bool, tint: [*c]const Color, selectStart: c_int, selectLength: c_int, selectTint: [*c]const Color, selectBackTint: [*c]const Color) void; +pub extern fn WDrawTextCodepoint(font: Font, codepoint: c_int, position: [*c]const Vector2, scale: f32, tint: [*c]const Color) void; +pub extern fn MeasureText(text: [*c]const u8, fontSize: c_int) c_int; +pub extern fn GetGlyphIndex(font: Font, codepoint: c_int) c_int; +pub extern fn TextCopy(dst: [*c]const u8, src: [*c]const u8) c_int; +pub extern fn TextIsEqual(text1: [*c]const u8, text2: [*c]const u8) bool; +pub extern fn TextLength(text: [*c]const u8) c_uint; +pub extern fn TextSubtext(text: [*c]const u8, position: c_int, length: c_int) [*c]const u8; +pub extern fn TextReplace(text: [*c]const u8, replace: [*c]const u8, by: [*c]const u8) [*c]const u8; +pub extern fn TextInsert(text: [*c]const u8, insert: [*c]const u8, position: c_int) [*c]const u8; +pub extern fn TextJoin(textList: [*c][*c]const u8, count: c_int, delimiter: [*c]const u8) [*c]const u8; +pub extern fn TextSplit(text: [*c]const u8, delimiter: u8, count: [*c]const c_int) [*c][*c]const u8; +pub extern fn TextAppend(text: [*c]const u8, append: [*c]const u8, position: [*c]const c_int) void; +pub extern fn TextFindIndex(text: [*c]const u8, find: [*c]const u8) c_int; +pub extern fn TextToUpper(text: [*c]const u8) [*c]const u8; +pub extern fn TextToLower(text: [*c]const u8) [*c]const u8; +pub extern fn TextToPascal(text: [*c]const u8) [*c]const u8; +pub extern fn TextToInteger(text: [*c]const u8) c_int; +pub extern fn TextToUtf8(codepoints: [*c]const c_int, length: c_int) [*c]const u8; +pub extern fn GetCodepoints(text: [*c]const u8, count: [*c]const c_int) [*c]const c_int; +pub extern fn GetCodepointsCount(text: [*c]const u8) c_int; +pub extern fn GetNextCodepoint(text: [*c]const u8, bytesProcessed: [*c]const c_int) c_int; +pub extern fn CodepointToUtf8(codepoint: c_int, byteLength: [*c]const c_int) [*c]const u8; +pub extern fn WDrawLine3D(startPos: [*c]const Vector3, endPos: [*c]const Vector3, color: [*c]const Color) void; +pub extern fn WDrawPoint3D(position: [*c]const Vector3, color: [*c]const Color) void; +pub extern fn WDrawCircle3D(center: [*c]const Vector3, radius: f32, rotationAxis: [*c]const Vector3, rotationAngle: f32, color: [*c]const Color) void; +pub extern fn WDrawCube(position: [*c]const Vector3, width: f32, height: f32, length: f32, color: [*c]const Color) void; +pub extern fn WDrawCubeV(position: [*c]const Vector3, size: [*c]const Vector3, color: [*c]const Color) void; +pub extern fn WDrawCubeWires(position: [*c]const Vector3, width: f32, height: f32, length: f32, color: [*c]const Color) void; +pub extern fn WDrawCubeWiresV(position: [*c]const Vector3, size: [*c]const Vector3, color: [*c]const Color) void; +pub extern fn WDrawCubeTexture(texture: Texture2D, position: [*c]const Vector3, width: f32, height: f32, length: f32, color: [*c]const Color) void; +pub extern fn WDrawSphere(centerPos: [*c]const Vector3, radius: f32, color: [*c]const Color) void; +pub extern fn WDrawSphereEx(centerPos: [*c]const Vector3, radius: f32, rings: c_int, slices: c_int, color: [*c]const Color) void; +pub extern fn WDrawSphereWires(centerPos: [*c]const Vector3, radius: f32, rings: c_int, slices: c_int, color: [*c]const Color) void; +pub extern fn WDrawCylinder(position: [*c]const Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: [*c]const Color) void; +pub extern fn WDrawCylinderWires(position: [*c]const Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: [*c]const Color) void; +pub extern fn WDrawPlane(centerPos: [*c]const Vector3, size: [*c]const Vector2, color: [*c]const Color) void; +pub extern fn WDrawRay(ray: Ray, color: [*c]const Color) void; +pub extern fn DrawGrid(slices: c_int, spacing: f32) void; +pub extern fn WDrawGizmo(position: [*c]const Vector3) void; +pub extern fn LoadModel(fileName: [*c]const u8) Model; +pub extern fn LoadModelFromMesh(mesh: Mesh) Model; +pub extern fn UnloadModel(model: Model) void; +pub extern fn LoadMeshes(fileName: [*c]const u8, meshCount: [*c]const c_int) [*c]const Mesh; +pub extern fn ExportMesh(mesh: Mesh, fileName: [*c]const u8) void; +pub extern fn UnloadMesh(mesh: Mesh) void; +pub extern fn LoadMaterials(fileName: [*c]const u8, materialCount: [*c]const c_int) [*c]const Material; +pub extern fn LoadMaterialDefault() Material; +pub extern fn UnloadMaterial(material: Material) void; +pub extern fn SetMaterialTexture(material: [*c]const Material, mapType: c_int, texture: Texture2D) void; +pub extern fn SetModelMeshMaterial(model: [*c]const Model, meshId: c_int, materialId: c_int) void; +pub extern fn LoadModelAnimations(fileName: [*c]const u8, animsCount: [*c]const c_int) [*c]const ModelAnimation; +pub extern fn UpdateModelAnimation(model: Model, anim: ModelAnimation, frame: c_int) void; +pub extern fn UnloadModelAnimation(anim: ModelAnimation) void; +pub extern fn IsModelAnimationValid(model: Model, anim: ModelAnimation) bool; +pub extern fn GenMeshPoly(sides: c_int, radius: f32) Mesh; +pub extern fn GenMeshPlane(width: f32, length: f32, resX: c_int, resZ: c_int) Mesh; +pub extern fn GenMeshCube(width: f32, height: f32, length: f32) Mesh; +pub extern fn GenMeshSphere(radius: f32, rings: c_int, slices: c_int) Mesh; +pub extern fn GenMeshHemiSphere(radius: f32, rings: c_int, slices: c_int) Mesh; +pub extern fn GenMeshCylinder(radius: f32, height: f32, slices: c_int) Mesh; +pub extern fn GenMeshTorus(radius: f32, size: f32, radSeg: c_int, sides: c_int) Mesh; +pub extern fn GenMeshKnot(radius: f32, size: f32, radSeg: c_int, sides: c_int) Mesh; +pub extern fn WGenMeshHeightmap(heightmap: Image, size: [*c]const Vector3) Mesh; +pub extern fn WGenMeshCubicmap(cubicmap: Image, cubeSize: [*c]const Vector3) Mesh; +pub extern fn MeshBoundingBox(mesh: Mesh) BoundingBox; +pub extern fn MeshTangents(mesh: [*c]const Mesh) void; +pub extern fn MeshBinormals(mesh: [*c]const Mesh) void; +pub extern fn WDrawModel(model: Model, position: [*c]const Vector3, scale: f32, tint: [*c]const Color) void; +pub extern fn WDrawModelEx(model: Model, position: [*c]const Vector3, rotationAxis: [*c]const Vector3, rotationAngle: f32, scale: [*c]const Vector3, tint: [*c]const Color) void; +pub extern fn WDrawModelWires(model: Model, position: [*c]const Vector3, scale: f32, tint: [*c]const Color) void; +pub extern fn WDrawModelWiresEx(model: Model, position: [*c]const Vector3, rotationAxis: [*c]const Vector3, rotationAngle: f32, scale: [*c]const Vector3, tint: [*c]const Color) void; +pub extern fn WDrawBoundingBox(box: BoundingBox, color: [*c]const Color) void; +pub extern fn WDrawBillboard(camera: Camera, texture: Texture2D, center: [*c]const Vector3, size: f32, tint: [*c]const Color) void; +pub extern fn WDrawBillboardRec(camera: Camera, texture: Texture2D, sourceRec: [*c]const Rectangle, center: [*c]const Vector3, size: f32, tint: [*c]const Color) void; +pub extern fn WCheckCollisionSpheres(centerA: [*c]const Vector3, radiusA: f32, centerB: [*c]const Vector3, radiusB: f32) bool; +pub extern fn CheckCollisionBoxes(box1: BoundingBox, box2: BoundingBox) bool; +pub extern fn WCheckCollisionBoxSphere(box: BoundingBox, center: [*c]const Vector3, radius: f32) bool; +pub extern fn WCheckCollisionRaySphere(ray: Ray, center: [*c]const Vector3, radius: f32) bool; +pub extern fn WCheckCollisionRaySphereEx(ray: Ray, center: [*c]const Vector3, radius: f32, collisionPoint: [*c]const Vector3) bool; +pub extern fn CheckCollisionRayBox(ray: Ray, box: BoundingBox) bool; +pub extern fn GetCollisionRayModel(ray: Ray, model: Model) RayHitInfo; +pub extern fn WGetCollisionRayTriangle(ray: Ray, p1: [*c]const Vector3, p2: [*c]const Vector3, p3: [*c]const Vector3) RayHitInfo; +pub extern fn GetCollisionRayGround(ray: Ray, groundHeight: f32) RayHitInfo; +pub extern fn WUnloadShader(shader: [*c]const Shader) void; +pub extern fn GetTextureDefault() Texture2D; +pub extern fn GetShapesTexture() Texture2D; +pub extern fn WSetShapesTexture(texture: Texture2D, source: [*c]const Rectangle) void; +pub extern fn WGetShaderLocation(shader: [*c]const Shader, uniformName: [*c]const u8) int; +pub extern fn WSetShaderValue(shader: [*c]const Shader, uniformLoc: c_int, value: [*c]const void, uniformType: c_int) void; +pub extern fn WSetShaderValueV(shader: [*c]const Shader, uniformLoc: c_int, value: [*c]const void, uniformType: c_int, count: c_int) void; +pub extern fn WSetShaderValueMatrix(shader: [*c]const Shader, uniformLoc: c_int, mat: Matrix) void; +pub extern fn WSetShaderValueTexture(shader: [*c]const Shader, uniformLoc: c_int, texture: Texture2D) void; +pub extern fn SetMatrixProjection(proj: Matrix) void; +pub extern fn SetMatrixModelview(view: Matrix) void; +pub extern fn GetMatrixModelview() Matrix; +pub extern fn GetMatrixProjection() Matrix; +pub extern fn WGenTextureCubemap(shader: [*c]const Shader, map: Texture2D, size: c_int) Texture2D; +pub extern fn WGenTextureIrradiance(shader: [*c]const Shader, cubemap: Texture2D, size: c_int) Texture2D; +pub extern fn WGenTexturePrefilter(shader: [*c]const Shader, cubemap: Texture2D, size: c_int) Texture2D; +pub extern fn WGenTextureBRDF(shader: [*c]const Shader, size: c_int) Texture2D; +pub extern fn WBeginShaderMode(shader: [*c]const Shader) void; +pub extern fn EndShaderMode() void; +pub extern fn BeginBlendMode(mode: c_int) void; +pub extern fn EndBlendMode() void; +pub extern fn InitVrSimulator() void; +pub extern fn CloseVrSimulator() void; +pub extern fn UpdateVrTracking(camera: [*c]const Camera) void; +pub extern fn WSetVrConfiguration(info: VrDeviceInfo, distortion: [*c]const Shader) void; +pub extern fn IsVrSimulatorReady() bool; +pub extern fn ToggleVrMode() void; +pub extern fn BeginVrDrawing() void; +pub extern fn EndVrDrawing() void; +pub extern fn InitAudioDevice() void; +pub extern fn CloseAudioDevice() void; +pub extern fn IsAudioDeviceReady() bool; +pub extern fn SetMasterVolume(volume: f32) void; +pub extern fn LoadWave(fileName: [*c]const u8) Wave; +pub extern fn LoadSound(fileName: [*c]const u8) Sound; +pub extern fn LoadSoundFromWave(wave: Wave) Sound; +pub extern fn UpdateSound(sound: Sound, data: [*c]const void, samplesCount: c_int) void; +pub extern fn UnloadWave(wave: Wave) void; +pub extern fn UnloadSound(sound: Sound) void; +pub extern fn ExportWave(wave: Wave, fileName: [*c]const u8) void; +pub extern fn ExportWaveAsCode(wave: Wave, fileName: [*c]const u8) void; +pub extern fn PlaySound(sound: Sound) void; +pub extern fn StopSound(sound: Sound) void; +pub extern fn PauseSound(sound: Sound) void; +pub extern fn ResumeSound(sound: Sound) void; +pub extern fn PlaySoundMulti(sound: Sound) void; +pub extern fn StopSoundMulti() void; +pub extern fn GetSoundsPlaying() c_int; +pub extern fn IsSoundPlaying(sound: Sound) bool; +pub extern fn SetSoundVolume(sound: Sound, volume: f32) void; +pub extern fn SetSoundPitch(sound: Sound, pitch: f32) void; +pub extern fn WaveFormat(wave: [*c]const Wave, sampleRate: c_int, sampleSize: c_int, channels: c_int) void; +pub extern fn WaveCopy(wave: Wave) Wave; +pub extern fn WaveCrop(wave: [*c]const Wave, initSample: c_int, finalSample: c_int) void; +pub extern fn GetWaveData(wave: Wave) [*c]const f32; +pub extern fn LoadMusicStream(fileName: [*c]const u8) Music; +pub extern fn UnloadMusicStream(music: Music) void; +pub extern fn PlayMusicStream(music: Music) void; +pub extern fn UpdateMusicStream(music: Music) void; +pub extern fn StopMusicStream(music: Music) void; +pub extern fn PauseMusicStream(music: Music) void; +pub extern fn ResumeMusicStream(music: Music) void; +pub extern fn IsMusicPlaying(music: Music) bool; +pub extern fn SetMusicVolume(music: Music, volume: f32) void; +pub extern fn SetMusicPitch(music: Music, pitch: f32) void; +pub extern fn SetMusicLoopCount(music: Music, count: c_int) void; +pub extern fn GetMusicTimeLength(music: Music) f32; +pub extern fn GetMusicTimePlayed(music: Music) f32; +pub extern fn InitAudioStream(sampleRate: c_uint, sampleSize: c_uint, channels: c_uint) AudioStream; +pub extern fn UpdateAudioStream(stream: AudioStream, data: [*c]const void, samplesCount: c_int) void; +pub extern fn CloseAudioStream(stream: AudioStream) void; +pub extern fn IsAudioStreamProcessed(stream: AudioStream) bool; +pub extern fn PlayAudioStream(stream: AudioStream) void; +pub extern fn PauseAudioStream(stream: AudioStream) void; +pub extern fn ResumeAudioStream(stream: AudioStream) void; +pub extern fn IsAudioStreamPlaying(stream: AudioStream) bool; +pub extern fn StopAudioStream(stream: AudioStream) void; +pub extern fn SetAudioStreamVolume(stream: AudioStream, volume: f32) void; +pub extern fn SetAudioStreamPitch(stream: AudioStream, pitch: f32) void; +pub extern fn SetAudioStreamBufferSizeDefault(size: c_int) void; + +pub fn ClearBackground(color: Color) void +{ + WClearBackground(&color); +} + +pub fn GetMouseRay(mousePosition: Vector2, camera: Camera) Ray +{ + return WGetMouseRay(&mousePosition, camera); +} + +pub fn ColorToInt(color: Color) int +{ + return WColorToInt(&color); +} + +pub fn DrawPixel(posX: c_int, posY: c_int, color: Color) void +{ + WDrawPixel(posX, posY, &color); +} + +pub fn DrawPixelV(position: Vector2, color: Color) void +{ + WDrawPixelV(&position, &color); +} + +pub fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void +{ + WDrawLine(startPosX, startPosY, endPosX, endPosY, &color); +} + +pub fn DrawLineV(startPos: Vector2, endPos: Vector2, color: Color) void +{ + WDrawLineV(&startPos, &endPos, &color); +} + +pub fn DrawLineEx(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void +{ + WDrawLineEx(&startPos, &endPos, thick, &color); +} + +pub fn DrawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void +{ + WDrawLineBezier(&startPos, &endPos, thick, &color); +} + +pub fn DrawLineStrip(points: []const Vector2, numPoints: c_int, color: Color) void +{ + WDrawLineStrip(&points[0], numPoints, &color); +} + +pub fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: Color) void +{ + WDrawCircle(centerX, centerY, radius, &color); +} + +pub fn DrawCircleSector(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void +{ + WDrawCircleSector(¢er, radius, startAngle, endAngle, segments, &color); +} + +pub fn DrawCircleSectorLines(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void +{ + WDrawCircleSectorLines(¢er, radius, startAngle, endAngle, segments, &color); +} + +pub fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: Color, color2: Color) void +{ + WDrawCircleGradient(centerX, centerY, radius, &color1, &color2); +} + +pub fn DrawCircleV(center: Vector2, radius: f32, color: Color) void +{ + WDrawCircleV(¢er, radius, &color); +} + +pub fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: Color) void +{ + WDrawCircleLines(centerX, centerY, radius, &color); +} + +pub fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void +{ + WDrawEllipse(centerX, centerY, radiusH, radiusV, &color); +} + +pub fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void +{ + WDrawEllipseLines(centerX, centerY, radiusH, radiusV, &color); +} + +pub fn DrawRing(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void +{ + WDrawRing(¢er, innerRadius, outerRadius, startAngle, endAngle, segments, &color); +} + +pub fn DrawRingLines(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void +{ + WDrawRingLines(¢er, innerRadius, outerRadius, startAngle, endAngle, segments, &color); +} + +pub fn DrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void +{ + WDrawRectangle(posX, posY, width, height, &color); +} + +pub fn DrawRectangleV(position: Vector2, size: Vector2, color: Color) void +{ + WDrawRectangleV(&position, &size, &color); +} + +pub fn DrawRectangleRec(rec: Rectangle, color: Color) void +{ + WDrawRectangleRec(&rec, &color); +} + +pub fn DrawRectanglePro(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) void +{ + WDrawRectanglePro(&rec, &origin, rotation, &color); +} + +pub fn DrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void +{ + WDrawRectangleGradientV(posX, posY, width, height, &color1, &color2); +} + +pub fn DrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void +{ + WDrawRectangleGradientH(posX, posY, width, height, &color1, &color2); +} + +pub fn DrawRectangleGradientEx(rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color) void +{ + WDrawRectangleGradientEx(&rec, &col1, &col2, &col3, &col4); +} + +pub fn DrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void +{ + WDrawRectangleLines(posX, posY, width, height, &color); +} + +pub fn DrawRectangleLinesEx(rec: Rectangle, lineThick: c_int, color: Color) void +{ + WDrawRectangleLinesEx(&rec, lineThick, &color); +} + +pub fn DrawRectangleRounded(rec: Rectangle, roundness: f32, segments: c_int, color: Color) void +{ + WDrawRectangleRounded(&rec, roundness, segments, &color); +} + +pub fn DrawRectangleRoundedLines(rec: Rectangle, roundness: f32, segments: c_int, lineThick: c_int, color: Color) void +{ + WDrawRectangleRoundedLines(&rec, roundness, segments, lineThick, &color); +} + +pub fn DrawTriangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void +{ + WDrawTriangle(&v1, &v2, &v3, &color); +} + +pub fn DrawTriangleLines(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void +{ + WDrawTriangleLines(&v1, &v2, &v3, &color); +} + +pub fn DrawTriangleFan(points: []const Vector2, numPoints: c_int, color: Color) void +{ + WDrawTriangleFan(&points[0], numPoints, &color); +} + +pub fn DrawTriangleStrip(points: []const Vector2, pointsCount: c_int, color: Color) void +{ + WDrawTriangleStrip(&points[0], pointsCount, &color); +} + +pub fn DrawPoly(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void +{ + WDrawPoly(¢er, sides, radius, rotation, &color); +} + +pub fn DrawPolyLines(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void +{ + WDrawPolyLines(¢er, sides, radius, rotation, &color); +} + +pub fn CheckCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool +{ + return WCheckCollisionRecs(&rec1, &rec2); +} + +pub fn CheckCollisionCircles(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) bool +{ + return WCheckCollisionCircles(¢er1, radius1, ¢er2, radius2); +} + +pub fn CheckCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) bool +{ + return WCheckCollisionCircleRec(¢er, radius, &rec); +} + +pub fn CheckCollisionPointRec(point: Vector2, rec: Rectangle) bool +{ + return WCheckCollisionPointRec(&point, &rec); +} + +pub fn CheckCollisionPointCircle(point: Vector2, center: Vector2, radius: f32) bool +{ + return WCheckCollisionPointCircle(&point, ¢er, radius); +} + +pub fn CheckCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) bool +{ + return WCheckCollisionPointTriangle(&point, &p1, &p2, &p3); +} + +pub fn LoadImageEx(pixels: []const Color, width: c_int, height: c_int) Image +{ + return WLoadImageEx(&pixels[0], width, height); +} + +pub fn GenImageColor(width: c_int, height: c_int, color: Color) Image +{ + return WGenImageColor(width, height, &color); +} + +pub fn GenImageGradientV(width: c_int, height: c_int, top: Color, bottom: Color) Image +{ + return WGenImageGradientV(width, height, &top, &bottom); +} + +pub fn GenImageGradientH(width: c_int, height: c_int, left: Color, right: Color) Image +{ + return WGenImageGradientH(width, height, &left, &right); +} + +pub fn GenImageGradientRadial(width: c_int, height: c_int, density: f32, inner: Color, outer: Color) Image +{ + return WGenImageGradientRadial(width, height, density, &inner, &outer); +} + +pub fn GenImageChecked(width: c_int, height: c_int, checksX: c_int, checksY: c_int, col1: Color, col2: Color) Image +{ + return WGenImageChecked(width, height, checksX, checksY, &col1, &col2); +} + +pub fn ImageFromImage(image: Image, rec: Rectangle) Image +{ + return WImageFromImage(image, &rec); +} + +pub fn ImageText(text: []const u8, fontSize: c_int, color: Color) Image +{ + return WImageText(&text[0], fontSize, &color); +} + +pub fn ImageTextEx(font: Font, text: []const u8, fontSize: f32, spacing: f32, tint: Color) Image +{ + return WImageTextEx(font, &text[0], fontSize, spacing, &tint); +} + +pub fn ImageToPOT(image: []const Image, fillColor: Color) void +{ + WImageToPOT(&image[0], &fillColor); +} + +pub fn ImageAlphaClear(image: []const Image, color: Color, threshold: f32) void +{ + WImageAlphaClear(&image[0], &color, threshold); +} + +pub fn ImageCrop(image: []const Image, crop: Rectangle) void +{ + WImageCrop(&image[0], &crop); +} + +pub fn ImageResizeCanvas(image: []const Image, newWidth: c_int, newHeight: c_int, offsetX: c_int, offsetY: c_int, color: Color) void +{ + WImageResizeCanvas(&image[0], newWidth, newHeight, offsetX, offsetY, &color); +} + +pub fn ImageColorTint(image: []const Image, color: Color) void +{ + WImageColorTint(&image[0], &color); +} + +pub fn ImageColorReplace(image: []const Image, color: Color, replace: Color) void +{ + WImageColorReplace(&image[0], &color, &replace); +} + +pub fn ImageClearBackground(dst: []const Image, color: Color) void +{ + WImageClearBackground(&dst[0], &color); +} + +pub fn ImageDrawPixel(dst: []const Image, posX: c_int, posY: c_int, color: Color) void +{ + WImageDrawPixel(&dst[0], posX, posY, &color); +} + +pub fn ImageDrawPixelV(dst: []const Image, position: Vector2, color: Color) void +{ + WImageDrawPixelV(&dst[0], &position, &color); +} + +pub fn ImageDrawLine(dst: []const Image, startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void +{ + WImageDrawLine(&dst[0], startPosX, startPosY, endPosX, endPosY, &color); +} + +pub fn ImageDrawLineV(dst: []const Image, start: Vector2, end: Vector2, color: Color) void +{ + WImageDrawLineV(&dst[0], &start, &end, &color); +} + +pub fn ImageDrawCircle(dst: []const Image, centerX: c_int, centerY: c_int, radius: c_int, color: Color) void +{ + WImageDrawCircle(&dst[0], centerX, centerY, radius, &color); +} + +pub fn ImageDrawCircleV(dst: []const Image, center: Vector2, radius: c_int, color: Color) void +{ + WImageDrawCircleV(&dst[0], ¢er, radius, &color); +} + +pub fn ImageDrawRectangle(dst: []const Image, posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void +{ + WImageDrawRectangle(&dst[0], posX, posY, width, height, &color); +} + +pub fn ImageDrawRectangleV(dst: []const Image, position: Vector2, size: Vector2, color: Color) void +{ + WImageDrawRectangleV(&dst[0], &position, &size, &color); +} + +pub fn ImageDrawRectangleRec(dst: []const Image, rec: Rectangle, color: Color) void +{ + WImageDrawRectangleRec(&dst[0], &rec, &color); +} + +pub fn ImageDrawRectangleLines(dst: []const Image, rec: Rectangle, thick: c_int, color: Color) void +{ + WImageDrawRectangleLines(&dst[0], &rec, thick, &color); +} + +pub fn ImageDraw(dst: []const Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color) void +{ + WImageDraw(&dst[0], src, &srcRec, &dstRec, &tint); +} + +pub fn ImageDrawText(dst: []const Image, position: Vector2, text: []const u8, fontSize: c_int, color: Color) void +{ + WImageDrawText(&dst[0], &position, &text[0], fontSize, &color); +} + +pub fn ImageDrawTextEx(dst: []const Image, position: Vector2, font: Font, text: []const u8, fontSize: f32, spacing: f32, color: Color) void +{ + WImageDrawTextEx(&dst[0], &position, font, &text[0], fontSize, spacing, &color); +} + +pub fn DrawTexture(texture: Texture2D, posX: c_int, posY: c_int, tint: Color) void +{ + WDrawTexture(texture, posX, posY, &tint); +} + +pub fn DrawTextureV(texture: Texture2D, position: Vector2, tint: Color) void +{ + WDrawTextureV(texture, &position, &tint); +} + +pub fn DrawTextureEx(texture: Texture2D, position: Vector2, rotation: f32, scale: f32, tint: Color) void +{ + WDrawTextureEx(texture, &position, rotation, scale, &tint); +} + +pub fn DrawTextureRec(texture: Texture2D, sourceRec: Rectangle, position: Vector2, tint: Color) void +{ + WDrawTextureRec(texture, &sourceRec, &position, &tint); +} + +pub fn DrawTextureQuad(texture: Texture2D, tiling: Vector2, offset: Vector2, quad: Rectangle, tint: Color) void +{ + WDrawTextureQuad(texture, &tiling, &offset, &quad, &tint); +} + +pub fn DrawTexturePro(texture: Texture2D, sourceRec: Rectangle, destRec: Rectangle, origin: Vector2, rotation: f32, tint: Color) void +{ + WDrawTexturePro(texture, &sourceRec, &destRec, &origin, rotation, &tint); +} + +pub fn DrawTextureNPatch(texture: Texture2D, nPatchInfo: NPatchInfo, destRec: Rectangle, origin: Vector2, rotation: f32, tint: Color) void +{ + WDrawTextureNPatch(texture, nPatchInfo, &destRec, &origin, rotation, &tint); +} + +pub fn LoadFontFromImage(image: Image, key: Color, firstChar: c_int) Font +{ + return WLoadFontFromImage(image, &key, firstChar); +} + +pub fn GenImageFontAtlas(chars: []const CharInfo, recs: [*c][]const Rectangle, charsCount: c_int, fontSize: c_int, padding: c_int, packMethod: c_int) Image +{ + return WGenImageFontAtlas(&chars[0], &recs[0], charsCount, fontSize, padding, packMethod); +} + +pub fn DrawText(text: []const u8, posX: c_int, posY: c_int, fontSize: c_int, color: Color) void +{ + WDrawText(&text[0], posX, posY, fontSize, &color); +} + +pub fn DrawTextEx(font: Font, text: []const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void +{ + WDrawTextEx(font, &text[0], &position, fontSize, spacing, &tint); +} + +pub fn DrawTextRec(font: Font, text: []const u8, rec: Rectangle, fontSize: f32, spacing: f32, wordWrap: bool, tint: Color) void +{ + WDrawTextRec(font, &text[0], &rec, fontSize, spacing, wordWrap, &tint); +} + +pub fn DrawTextRecEx(font: Font, text: []const u8, rec: Rectangle, fontSize: f32, spacing: f32, wordWrap: bool, tint: Color, selectStart: c_int, selectLength: c_int, selectTint: Color, selectBackTint: Color) void +{ + WDrawTextRecEx(font, &text[0], &rec, fontSize, spacing, wordWrap, &tint, selectStart, selectLength, &selectTint, &selectBackTint); +} + +pub fn DrawTextCodepoint(font: Font, codepoint: c_int, position: Vector2, scale: f32, tint: Color) void +{ + WDrawTextCodepoint(font, codepoint, &position, scale, &tint); +} + +pub fn DrawLine3D(startPos: Vector3, endPos: Vector3, color: Color) void +{ + WDrawLine3D(&startPos, &endPos, &color); +} + +pub fn DrawPoint3D(position: Vector3, color: Color) void +{ + WDrawPoint3D(&position, &color); +} + +pub fn DrawCircle3D(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) void +{ + WDrawCircle3D(¢er, radius, &rotationAxis, rotationAngle, &color); +} + +pub fn DrawCube(position: Vector3, width: f32, height: f32, length: f32, color: Color) void +{ + WDrawCube(&position, width, height, length, &color); +} + +pub fn DrawCubeV(position: Vector3, size: Vector3, color: Color) void +{ + WDrawCubeV(&position, &size, &color); +} + +pub fn DrawCubeWires(position: Vector3, width: f32, height: f32, length: f32, color: Color) void +{ + WDrawCubeWires(&position, width, height, length, &color); +} + +pub fn DrawCubeWiresV(position: Vector3, size: Vector3, color: Color) void +{ + WDrawCubeWiresV(&position, &size, &color); +} + +pub fn DrawCubeTexture(texture: Texture2D, position: Vector3, width: f32, height: f32, length: f32, color: Color) void +{ + WDrawCubeTexture(texture, &position, width, height, length, &color); +} + +pub fn DrawSphere(centerPos: Vector3, radius: f32, color: Color) void +{ + WDrawSphere(¢erPos, radius, &color); +} + +pub fn DrawSphereEx(centerPos: Vector3, radius: f32, rings: c_int, slices: c_int, color: Color) void +{ + WDrawSphereEx(¢erPos, radius, rings, slices, &color); +} + +pub fn DrawSphereWires(centerPos: Vector3, radius: f32, rings: c_int, slices: c_int, color: Color) void +{ + WDrawSphereWires(¢erPos, radius, rings, slices, &color); +} + +pub fn DrawCylinder(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: Color) void +{ + WDrawCylinder(&position, radiusTop, radiusBottom, height, slices, &color); +} + +pub fn DrawCylinderWires(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: Color) void +{ + WDrawCylinderWires(&position, radiusTop, radiusBottom, height, slices, &color); +} + +pub fn DrawPlane(centerPos: Vector3, size: Vector2, color: Color) void +{ + WDrawPlane(¢erPos, &size, &color); +} + +pub fn DrawRay(ray: Ray, color: Color) void +{ + WDrawRay(ray, &color); +} + +pub fn DrawGizmo(position: Vector3) void +{ + WDrawGizmo(&position); +} + +pub fn GenMeshHeightmap(heightmap: Image, size: Vector3) Mesh +{ + return WGenMeshHeightmap(heightmap, &size); +} + +pub fn GenMeshCubicmap(cubicmap: Image, cubeSize: Vector3) Mesh +{ + return WGenMeshCubicmap(cubicmap, &cubeSize); +} + +pub fn DrawModel(model: Model, position: Vector3, scale: f32, tint: Color) void +{ + WDrawModel(model, &position, scale, &tint); +} + +pub fn DrawModelEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void +{ + WDrawModelEx(model, &position, &rotationAxis, rotationAngle, &scale, &tint); +} + +pub fn DrawModelWires(model: Model, position: Vector3, scale: f32, tint: Color) void +{ + WDrawModelWires(model, &position, scale, &tint); +} + +pub fn DrawModelWiresEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void +{ + WDrawModelWiresEx(model, &position, &rotationAxis, rotationAngle, &scale, &tint); +} + +pub fn DrawBoundingBox(box: BoundingBox, color: Color) void +{ + WDrawBoundingBox(box, &color); +} + +pub fn DrawBillboard(camera: Camera, texture: Texture2D, center: Vector3, size: f32, tint: Color) void +{ + WDrawBillboard(camera, texture, ¢er, size, &tint); +} + +pub fn DrawBillboardRec(camera: Camera, texture: Texture2D, sourceRec: Rectangle, center: Vector3, size: f32, tint: Color) void +{ + WDrawBillboardRec(camera, texture, &sourceRec, ¢er, size, &tint); +} + +pub fn CheckCollisionSpheres(centerA: Vector3, radiusA: f32, centerB: Vector3, radiusB: f32) bool +{ + return WCheckCollisionSpheres(¢erA, radiusA, ¢erB, radiusB); +} + +pub fn CheckCollisionBoxSphere(box: BoundingBox, center: Vector3, radius: f32) bool +{ + return WCheckCollisionBoxSphere(box, ¢er, radius); +} + +pub fn CheckCollisionRaySphere(ray: Ray, center: Vector3, radius: f32) bool +{ + return WCheckCollisionRaySphere(ray, ¢er, radius); +} + +pub fn CheckCollisionRaySphereEx(ray: Ray, center: Vector3, radius: f32, collisionPoint: []const Vector3) bool +{ + return WCheckCollisionRaySphereEx(ray, ¢er, radius, &collisionPoint[0]); +} + +pub fn GetCollisionRayTriangle(ray: Ray, p1: Vector3, p2: Vector3, p3: Vector3) RayHitInfo +{ + return WGetCollisionRayTriangle(ray, &p1, &p2, &p3); +} + +pub fn UnloadShader(shader: Shader) void +{ + WUnloadShader(&shader); +} + +pub fn SetShapesTexture(texture: Texture2D, source: Rectangle) void +{ + WSetShapesTexture(texture, &source); +} + +pub fn GetShaderLocation(shader: Shader, uniformName: []const u8) int +{ + return WGetShaderLocation(&shader, &uniformName[0]); +} + +pub fn SetShaderValue(shader: Shader, uniformLoc: c_int, value: []const void, uniformType: c_int) void +{ + WSetShaderValue(&shader, uniformLoc, &value[0], uniformType); +} + +pub fn SetShaderValueV(shader: Shader, uniformLoc: c_int, value: []const void, uniformType: c_int, count: c_int) void +{ + WSetShaderValueV(&shader, uniformLoc, &value[0], uniformType, count); +} + +pub fn SetShaderValueMatrix(shader: Shader, uniformLoc: c_int, mat: Matrix) void +{ + WSetShaderValueMatrix(&shader, uniformLoc, mat); +} + +pub fn SetShaderValueTexture(shader: Shader, uniformLoc: c_int, texture: Texture2D) void +{ + WSetShaderValueTexture(&shader, uniformLoc, texture); +} + +pub fn GenTextureCubemap(shader: Shader, map: Texture2D, size: c_int) Texture2D +{ + return WGenTextureCubemap(&shader, map, size); +} + +pub fn GenTextureIrradiance(shader: Shader, cubemap: Texture2D, size: c_int) Texture2D +{ + return WGenTextureIrradiance(&shader, cubemap, size); +} + +pub fn GenTexturePrefilter(shader: Shader, cubemap: Texture2D, size: c_int) Texture2D +{ + return WGenTexturePrefilter(&shader, cubemap, size); +} + +pub fn GenTextureBRDF(shader: Shader, size: c_int) Texture2D +{ + return WGenTextureBRDF(&shader, size); +} + +pub fn BeginShaderMode(shader: Shader) void +{ + WBeginShaderMode(&shader); +} + +pub fn SetVrConfiguration(info: VrDeviceInfo, distortion: Shader) void +{ + WSetVrConfiguration(info, &distortion); +} + diff --git a/lib/raylib-zig-math.zig b/lib/raylib-zig-math.zig index b5db0a8..4f4a8d7 100755 --- a/lib/raylib-zig-math.zig +++ b/lib/raylib-zig-math.zig @@ -1,54 +1,15 @@ -// -// raylib-zig-math -// Zig version: 0.6.0 -// Author: Nikolas Wipper -// Date: 2020-02-15 -// - usingnamespace @import("raylib-zig.zig"); pub extern fn Clamp(value: f32, min: f32, max: f32) f32; pub extern fn Lerp(start: f32, end: f32, amount: f32) f32; -pub extern fn Vector2Zero() Vector2; -pub extern fn Vector2One() Vector2; -pub extern fn Vector2Add(v1: Vector2, v2: Vector2) Vector2; -pub extern fn Vector2Subtract(v1: Vector2, v2: Vector2) Vector2; -pub extern fn Vector2Length(v: Vector2) f32; -pub extern fn Vector2DotProduct(v1: Vector2, v2: Vector2) f32; -pub extern fn Vector2Distance(v1: Vector2, v2: Vector2) f32; -pub extern fn Vector2Angle(v1: Vector2, v2: Vector2) f32; -pub extern fn Vector2Scale(v: Vector2, scale: f32) Vector2; -pub extern fn Vector2MultiplyV(v1: Vector2, v2: Vector2) Vector2; -pub extern fn Vector2Negate(v: Vector2) Vector2; -pub extern fn Vector2Divide(v: Vector2, div: f32) Vector2; -pub extern fn Vector2DivideV(v1: Vector2, v2: Vector2) Vector2; -pub extern fn Vector2Normalize(v: Vector2) Vector2; -pub extern fn Vector2Lerp(v1: Vector2, v2: Vector2, amount: f32) Vector2; -pub extern fn Vector2Rotate(v: Vector2, degs: f32) Vector2; -pub extern fn Vector3Zero() Vector3; -pub extern fn Vector3One() Vector3; -pub extern fn Vector3Add(v1: Vector3, v2: Vector3) Vector3; -pub extern fn Vector3Subtract(v1: Vector3, v2: Vector3) Vector3; -pub extern fn Vector3Scale(v: Vector3, scalar: f32) Vector3; -pub extern fn Vector3Multiply(v1: Vector3, v2: Vector3) Vector3; -pub extern fn Vector3CrossProduct(v1: Vector3, v2: Vector3) Vector3; -pub extern fn Vector3Perpendicular(v: Vector3) Vector3; -pub extern fn Vector3Length(v: Vector3) f32; -pub extern fn Vector3DotProduct(v1: Vector3, v2: Vector3) f32; -pub extern fn Vector3Distance(v1: Vector3, v2: Vector3) f32; -pub extern fn Vector3Negate(v: Vector3) Vector3; -pub extern fn Vector3Divide(v: Vector3, div: f32) Vector3; -pub extern fn Vector3DivideV(v1: Vector3, v2: Vector3) Vector3; -pub extern fn Vector3Normalize(v: Vector3) Vector3; -pub extern fn Vector3OrthoNormalize(v1: [*c]Vector3, v2: [*c]Vector3) c_void; -pub extern fn Vector3Transform(v: Vector3, mat: Matrix) Vector3; -pub extern fn Vector3RotateByQuaternion(v: Vector3, q: Quaternion) Vector3; -pub extern fn Vector3Lerp(v1: Vector3, v2: Vector3, amount: f32) Vector3; -pub extern fn Vector3Reflect(v: Vector3, normal: Vector3) Vector3; -pub extern fn Vector3Min(v1: Vector3, v2: Vector3) Vector3; -pub extern fn Vector3Max(v1: Vector3, v2: Vector3) Vector3; -pub extern fn Vector3Barycenter(p: Vector3, a: Vector3, b: Vector3, c: Vector3) Vector3; -pub extern fn Vector3ToFloatV(v: Vector3) float3; +pub extern fn WVector2Length(v: [*c]const Vector2) float; +pub extern fn WVector2DotProduct(v1: [*c]const Vector2, v2: [*c]const Vector2) float; +pub extern fn WVector2Distance(v1: [*c]const Vector2, v2: [*c]const Vector2) float; +pub extern fn WVector2Angle(v1: [*c]const Vector2, v2: [*c]const Vector2) float; +pub extern fn WVector3Length(v: [*c]const Vector3) float; +pub extern fn WVector3DotProduct(v1: [*c]const Vector3, v2: [*c]const Vector3) float; +pub extern fn WVector3Distance(v1: [*c]const Vector3, v2: [*c]const Vector3) float; +pub extern fn WVector3OrthoNormalize(v1: [*c]const Vector3, v2: [*c]const Vector3) void; pub extern fn MatrixDeterminant(mat: Matrix) f32; pub extern fn MatrixTrace(mat: Matrix) f32; pub extern fn MatrixTranspose(mat: Matrix) Matrix; @@ -58,8 +19,8 @@ pub extern fn MatrixIdentity() Matrix; pub extern fn MatrixAdd(left: Matrix, right: Matrix) Matrix; pub extern fn MatrixSubtract(left: Matrix, right: Matrix) Matrix; pub extern fn MatrixTranslate(x: f32, y: f32, z: f32) Matrix; -pub extern fn MatrixRotate(axis: Vector3, angle: f32) Matrix; -pub extern fn MatrixRotateXYZ(ang: Vector3) Matrix; +pub extern fn WMatrixRotate(axis: [*c]const Vector3, angle: f32) Matrix; +pub extern fn WMatrixRotateXYZ(ang: [*c]const Vector3) Matrix; pub extern fn MatrixRotateX(angle: f32) Matrix; pub extern fn MatrixRotateY(angle: f32) Matrix; pub extern fn MatrixRotateZ(angle: f32) Matrix; @@ -68,23 +29,78 @@ pub extern fn MatrixMultiply(left: Matrix, right: Matrix) Matrix; pub extern fn MatrixFrustum(left: double, right: double, bottom: double, top: double, near: double, far: double) Matrix; pub extern fn MatrixPerspective(fovy: double, aspect: double, near: double, far: double) Matrix; pub extern fn MatrixOrtho(left: double, right: double, bottom: double, top: double, near: double, far: double) Matrix; -pub extern fn MatrixLookAt(eye: Vector3, target: Vector3, up: Vector3) Matrix; -pub extern fn MatrixToFloatV(mat: Matrix) float16; -pub extern fn QuaternionIdentity() Quaternion; -pub extern fn QuaternionLength(q: Quaternion) f32; -pub extern fn QuaternionNormalize(q: Quaternion) Quaternion; -pub extern fn QuaternionInvert(q: Quaternion) Quaternion; -pub extern fn QuaternionMultiply(q1: Quaternion, q2: Quaternion) Quaternion; -pub extern fn QuaternionLerp(q1: Quaternion, q2: Quaternion, amount: f32) Quaternion; -pub extern fn QuaternionNlerp(q1: Quaternion, q2: Quaternion, amount: f32) Quaternion; -pub extern fn QuaternionSlerp(q1: Quaternion, q2: Quaternion, amount: f32) Quaternion; -pub extern fn QuaternionFromVector3ToVector3(from: Vector3, to: Vector3) Quaternion; -pub extern fn QuaternionFromMatrix(mat: Matrix) Quaternion; -pub extern fn QuaternionToMatrix(q: Quaternion) Matrix; -pub extern fn QuaternionFromAxisAngle(axis: Vector3, angle: f32) Quaternion; -pub extern fn QuaternionToAxisAngle(q: Quaternion, outAxis: [*c]Vector3, outAngle: [*c]f32) c_void; -pub extern fn QuaternionFromEuler(roll: f32, pitch: f32, yaw: f32) Quaternion; -pub extern fn QuaternionToEuler(q: Quaternion) Vector3; -pub extern fn QuaternionTransform(q: Quaternion, mat: Matrix) Quaternion; +pub extern fn WMatrixLookAt(eye: [*c]const Vector3, target: [*c]const Vector3, up: [*c]const Vector3) Matrix; +pub extern fn WQuaternionLength(q: [*c]const Quaternion) float; +pub extern fn WQuaternionToMatrix(q: [*c]const Quaternion) Matrix; +pub extern fn WQuaternionToAxisAngle(q: [*c]const Quaternion, outAxis: [*c]const Vector3, outAngle: [*c]const f32) void; +pub fn Vector2Length(v: Vector2) float +{ + return WVector2Length(&v); +} + +pub fn Vector2DotProduct(v1: Vector2, v2: Vector2) float +{ + return WVector2DotProduct(&v1, &v2); +} + +pub fn Vector2Distance(v1: Vector2, v2: Vector2) float +{ + return WVector2Distance(&v1, &v2); +} + +pub fn Vector2Angle(v1: Vector2, v2: Vector2) float +{ + return WVector2Angle(&v1, &v2); +} + +pub fn Vector3Length(v: Vector3) float +{ + return WVector3Length(&v); +} + +pub fn Vector3DotProduct(v1: Vector3, v2: Vector3) float +{ + return WVector3DotProduct(&v1, &v2); +} + +pub fn Vector3Distance(v1: Vector3, v2: Vector3) float +{ + return WVector3Distance(&v1, &v2); +} + +pub fn Vector3OrthoNormalize(v1: []const Vector3, v2: []const Vector3) void +{ + WVector3OrthoNormalize(&v1[0], &v2[0]); +} + +pub fn MatrixRotate(axis: Vector3, angle: f32) Matrix +{ + return WMatrixRotate(&axis, angle); +} + +pub fn MatrixRotateXYZ(ang: Vector3) Matrix +{ + return WMatrixRotateXYZ(&ang); +} + +pub fn MatrixLookAt(eye: Vector3, target: Vector3, up: Vector3) Matrix +{ + return WMatrixLookAt(&eye, &target, &up); +} + +pub fn QuaternionLength(q: Quaternion) float +{ + return WQuaternionLength(&q); +} + +pub fn QuaternionToMatrix(q: Quaternion) Matrix +{ + return WQuaternionToMatrix(&q); +} + +pub fn QuaternionToAxisAngle(q: Quaternion, outAxis: []const Vector3, outAngle: []const f32) void +{ + WQuaternionToAxisAngle(&q, &outAxis[0], &outAngle[0]); +} diff --git a/lib/raylib-zig.zig b/lib/raylib-zig.zig index da7bf6e..327137b 100755 --- a/lib/raylib-zig.zig +++ b/lib/raylib-zig.zig @@ -4,7 +4,6 @@ // Author: Nikolas Wipper // Date: 2020-02-15 // -const wa = @import("workaround/workaround.zig"); pub const Vector2 = extern struct { x: f32, @@ -730,447 +729,6 @@ pub const NPatchType = extern enum(c_int) { NPT_3PATCH_HORIZONTAL = 2, }; -pub extern fn InitWindow(width: c_int, height: c_int, title: [*c]const u8) void; -pub extern fn WindowShouldClose() bool; -pub extern fn CloseWindow() void; -pub extern fn IsWindowReady() bool; -pub extern fn IsWindowMinimized() bool; -pub extern fn IsWindowResized() bool; -pub extern fn IsWindowHidden() bool; -pub extern fn IsWindowFullscreen() bool; -pub extern fn ToggleFullscreen() void; -pub extern fn UnhideWindow() void; -pub extern fn HideWindow() void; -pub extern fn SetWindowIcon(image: Image) void; -pub extern fn SetWindowTitle(title: [*c]const u8) void; -pub extern fn SetWindowPosition(x: c_int, y: c_int) void; -pub extern fn SetWindowMonitor(monitor: c_int) void; -pub extern fn SetWindowMinSize(width: c_int, height: c_int) void; -pub extern fn SetWindowSize(width: c_int, height: c_int) void; -pub extern fn GetWindowHandle() ?*c_void; -pub extern fn GetScreenWidth() c_int; -pub extern fn GetScreenHeight() c_int; -pub extern fn GetMonitorCount() c_int; -pub extern fn GetMonitorWidth(monitor: c_int) c_int; -pub extern fn GetMonitorHeight(monitor: c_int) c_int; -pub extern fn GetMonitorPhysicalWidth(monitor: c_int) c_int; -pub extern fn GetMonitorPhysicalHeight(monitor: c_int) c_int; -pub extern fn GetWindowPosition() Vector2; -pub extern fn GetMonitorName(monitor: c_int) [*c]const u8; -pub extern fn GetClipboardText() [*c]const u8; -pub extern fn SetClipboardText(text: [*c]const u8) void; -pub extern fn ShowCursor() void; -pub extern fn HideCursor() void; -pub extern fn IsCursorHidden() bool; -pub extern fn EnableCursor() void; -pub extern fn DisableCursor() void; -pub extern fn ClearBackground(color: Color) void; -pub extern fn BeginDrawing() void; -pub extern fn EndDrawing() void; -pub extern fn BeginMode2D(camera: Camera2D) void; -pub extern fn EndMode2D() void; -pub extern fn BeginMode3D(camera: Camera3D) void; -pub extern fn EndMode3D() void; -pub extern fn BeginTextureMode(target: RenderTexture2D) void; -pub extern fn EndTextureMode() void; -pub extern fn BeginScissorMode(x: c_int, y: c_int, width: c_int, height: c_int) void; -pub extern fn EndScissorMode() void; -//pub extern fn GetMouseRay(mousePosition: Vector2, camera: Camera) Ray; -pub extern fn GetCameraMatrix(camera: Camera) Matrix; -pub extern fn GetCameraMatrix2D(camera: Camera2D) Matrix; -pub extern fn GetWorldToScreen(position: Vector3, camera: Camera) Vector2; -pub extern fn GetWorldToScreenEx(position: Vector3, camera: Camera, width: c_int, height: c_int) Vector2; -pub extern fn GetWorldToScreen2D(position: Vector2, camera: Camera2D) Vector2; -pub extern fn GetScreenToWorld2D(position: Vector2, camera: Camera2D) Vector2; -pub extern fn SetTargetFPS(fps: c_int) void; -pub extern fn GetFPS() c_int; -pub extern fn GetFrameTime() f32; -pub extern fn GetTime() f64; -pub extern fn ColorToInt(color: Color) c_int; -pub extern fn ColorNormalize(color: Color) Vector4; -pub extern fn ColorFromNormalized(normalized: Vector4) Color; -pub extern fn ColorToHSV(color: Color) Vector3; -pub extern fn ColorFromHSV(hsv: Vector3) Color; -pub extern fn GetColor(hexValue: c_int) Color; -pub extern fn Fade(color: Color, alpha: f32) Color; -pub extern fn SetConfigFlags(flags: c_uint) void; -pub extern fn SetTraceLogLevel(logType: c_int) void; -pub extern fn SetTraceLogExit(logType: c_int) void; -//pub extern fn SetTraceLogCallback(callback: TraceLogCallback) void; -pub extern fn TraceLog(logType: c_int, text: [*c]const u8, ...) void; -pub extern fn TakeScreenshot(fileName: [*c]const u8) void; -pub extern fn GetRandomValue(min: c_int, max: c_int) c_int; -pub extern fn LoadFileData(fileName: [*c]const u8, bytesRead: [*c]c_uint) [*c]u8; -pub extern fn SaveFileData(fileName: [*c]const u8, data: ?*c_void, bytesToWrite: c_uint) void; -pub extern fn LoadFileText(fileName: [*c]const u8) [*c]u8; -pub extern fn SaveFileText(fileName: [*c]const u8, text: [*c]u8) void; -pub extern fn FileExists(fileName: [*c]const u8) bool; -pub extern fn IsFileExtension(fileName: [*c]const u8, ext: [*c]const u8) bool; -pub extern fn DirectoryExists(dirPath: [*c]const u8) bool; -pub extern fn GetExtension(fileName: [*c]const u8) [*c]const u8; -pub extern fn GetFileName(filePath: [*c]const u8) [*c]const u8; -pub extern fn GetFileNameWithoutExt(filePath: [*c]const u8) [*c]const u8; -pub extern fn GetDirectoryPath(filePath: [*c]const u8) [*c]const u8; -pub extern fn GetPrevDirectoryPath(dirPath: [*c]const u8) [*c]const u8; -pub extern fn GetWorkingDirectory() [*c]const u8; -pub extern fn GetDirectoryFiles(dirPath: [*c]const u8, count: [*c]c_int) [*c][*c]u8; -pub extern fn ClearDirectoryFiles() void; -pub extern fn ChangeDirectory(dir: [*c]const u8) bool; -pub extern fn IsFileDropped() bool; -pub extern fn GetDroppedFiles(count: [*c]c_int) [*c][*c]u8; -pub extern fn ClearDroppedFiles() void; -pub extern fn GetFileModTime(fileName: [*c]const u8) c_long; -pub extern fn CompressData(data: [*c]u8, dataLength: c_int, compDataLength: [*c]c_int) [*c]u8; -pub extern fn DecompressData(compData: [*c]u8, compDataLength: c_int, dataLength: [*c]c_int) [*c]u8; -pub extern fn SaveStorageValue(position: c_uint, value: c_int) void; -pub extern fn LoadStorageValue(position: c_uint) c_int; -pub extern fn OpenURL(url: [*c]const u8) void; -pub extern fn IsKeyPressed(key: KeyboardKey) bool; -pub extern fn IsKeyDown(key: KeyboardKey) bool; -pub extern fn IsKeyReleased(key: KeyboardKey) bool; -pub extern fn IsKeyUp(key: KeyboardKey) bool; -pub extern fn GetKeyPressed() KeyboardKey; -pub extern fn SetExitKey(key: KeyboardKey) void; -pub extern fn IsGamepadAvailable(gamepad: c_int) bool; -pub extern fn IsGamepadName(gamepad: c_int, name: [*c]const u8) bool; -pub extern fn GetGamepadName(gamepad: c_int) [*c]const u8; -pub extern fn IsGamepadButtonPressed(gamepad: c_int, button: c_int) bool; -pub extern fn IsGamepadButtonDown(gamepad: c_int, button: c_int) bool; -pub extern fn IsGamepadButtonReleased(gamepad: c_int, button: c_int) bool; -pub extern fn IsGamepadButtonUp(gamepad: c_int, button: c_int) bool; -pub extern fn GetGamepadButtonPressed() c_int; -pub extern fn GetGamepadAxisCount(gamepad: c_int) c_int; -pub extern fn GetGamepadAxisMovement(gamepad: c_int, axis: c_int) f32; -pub extern fn IsMouseButtonPressed(button: MouseButton) bool; -pub extern fn IsMouseButtonDown(button: MouseButton) bool; -pub extern fn IsMouseButtonReleased(button: MouseButton) bool; -pub extern fn IsMouseButtonUp(button: MouseButton) bool; -pub extern fn GetMouseX() c_int; -pub extern fn GetMouseY() c_int; -pub extern fn GetMousePosition() Vector2; -pub extern fn SetMousePosition(x: c_int, y: c_int) void; -pub extern fn SetMouseOffset(offsetX: c_int, offsetY: c_int) void; -pub extern fn SetMouseScale(scaleX: f32, scaleY: f32) void; -pub extern fn GetMouseWheelMove() c_int; -pub extern fn GetTouchX() c_int; -pub extern fn GetTouchY() c_int; -pub extern fn GetTouchPosition(index: c_int) Vector2; -pub extern fn SetGesturesEnabled(gestureFlags: c_uint) void; -pub extern fn IsGestureDetected(gesture: c_int) bool; -pub extern fn GetGestureDetected() c_int; -pub extern fn GetTouchPointsCount() c_int; -pub extern fn GetGestureHoldDuration() f32; -pub extern fn GetGestureDragVector() Vector2; -pub extern fn GetGestureDragAngle() f32; -pub extern fn GetGesturePinchVector() Vector2; -pub extern fn GetGesturePinchAngle() f32; -pub extern fn SetCameraMode(camera: Camera, mode: CameraMode) void; -pub extern fn UpdateCamera(camera: [*c]Camera) void; -pub extern fn SetCameraPanControl(panKey: c_int) void; -pub extern fn SetCameraAltControl(altKey: c_int) void; -pub extern fn SetCameraSmoothZoomControl(szKey: c_int) void; -pub extern fn SetCameraMoveControls(frontKey: c_int, backKey: c_int, rightKey: c_int, leftKey: c_int, upKey: c_int, downKey: c_int) void; -//pub extern fn DrawPixel(posX: c_int, posY: c_int, color: Color) void; -//pub extern fn DrawPixelV(position: Vector2, color: Color) void; -//pub extern fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void; -//pub extern fn DrawLineV(startPos: Vector2, endPos: Vector2, color: Color) void; -//pub extern fn DrawLineEx(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void; -//pub extern fn DrawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void; -//pub extern fn DrawLineStrip(points: [*c]Vector2, numPoints: c_int, color: Color) void; -//pub extern fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: Color) void; -//pub extern fn DrawCircleSector(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void; -//pub extern fn DrawCircleSectorLines(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void; -//pub extern fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: Color, color2: Color) void; -//pub extern fn DrawCircleV(center: Vector2, radius: f32, color: Color) void; -//pub extern fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: Color) void; -//pub extern fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void; -//pub extern fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void; -//pub extern fn DrawRing(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void; -//pub extern fn DrawRingLines(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void; -//pub extern fn DrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; -//pub extern fn DrawRectangleV(position: Vector2, size: Vector2, color: Color) void; -//pub extern fn DrawRectangleRec(rec: Rectangle, color: Color) void; -//pub extern fn DrawRectanglePro(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) void; -//pub extern fn DrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void; -//pub extern fn DrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void; -//pub extern fn DrawRectangleGradientEx(rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color) void; -//pub extern fn DrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; -//pub extern fn DrawRectangleLinesEx(rec: Rectangle, lineThick: c_int, color: Color) void; -//pub extern fn DrawRectangleRounded(rec: Rectangle, roundness: f32, segments: c_int, color: Color) void; -//pub extern fn DrawRectangleRoundedLines(rec: Rectangle, roundness: f32, segments: c_int, lineThick: c_int, color: Color) void; -//pub extern fn DrawTriangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; -//pub extern fn DrawTriangleLines(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void; -//pub extern fn DrawTriangleFan(points: [*c]Vector2, numPoints: c_int, color: Color) void; -//pub extern fn DrawTriangleStrip(points: [*c]Vector2, pointsCount: c_int, color: Color) void; -//pub extern fn DrawPoly(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void; -//pub extern fn DrawPolyLines(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void; -//pub extern fn CheckCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool; -//pub extern fn CheckCollisionCircles(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) bool; -//pub extern fn CheckCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) bool; -//pub extern fn GetCollisionRec(rec1: Rectangle, rec2: Rectangle) Rectangle; -//pub extern fn CheckCollisionPointRec(point: Vector2, rec: Rectangle) bool; -//pub extern fn CheckCollisionPointCircle(point: Vector2, center: Vector2, radius: f32) bool; -//pub extern fn CheckCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) bool; -pub extern fn LoadImage(fileName: [*c]const u8) Image; -pub extern fn LoadImageEx(pixels: [*c]Color, width: c_int, height: c_int) Image; -pub extern fn LoadImagePro(data: ?*c_void, width: c_int, height: c_int, format: PixelFormat) Image; -pub extern fn LoadImageRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: PixelFormat, headerSize: c_int) Image; -pub extern fn UnloadImage(image: Image) void; -pub extern fn ExportImage(image: Image, fileName: [*c]const u8) void; -pub extern fn ExportImageAsCode(image: Image, fileName: [*c]const u8) void; -pub extern fn GetImageData(image: Image) [*c]Color; -pub extern fn GetImageDataNormalized(image: Image) [*c]Vector4; -pub extern fn GenImageColor(width: c_int, height: c_int, color: Color) Image; -pub extern fn GenImageGradientV(width: c_int, height: c_int, top: Color, bottom: Color) Image; -pub extern fn GenImageGradientH(width: c_int, height: c_int, left: Color, right: Color) Image; -pub extern fn GenImageGradientRadial(width: c_int, height: c_int, density: f32, inner: Color, outer: Color) Image; -pub extern fn GenImageChecked(width: c_int, height: c_int, checksX: c_int, checksY: c_int, col1: Color, col2: Color) Image; -pub extern fn GenImageWhiteNoise(width: c_int, height: c_int, factor: f32) Image; -pub extern fn GenImagePerlinNoise(width: c_int, height: c_int, offsetX: c_int, offsetY: c_int, scale: f32) Image; -pub extern fn GenImageCellular(width: c_int, height: c_int, tileSize: c_int) Image; -pub extern fn ImageCopy(image: Image) Image; -pub extern fn ImageFromImage(image: Image, rec: Rectangle) Image; -pub extern fn ImageText(text: [*c]const u8, fontSize: c_int, color: Color) Image; -pub extern fn ImageTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32, tint: Color) Image; -pub extern fn ImageToPOT(image: [*c]Image, fillColor: Color) void; -pub extern fn ImageFormat(image: [*c]Image, newFormat: PixelFormat) void; -pub extern fn ImageAlphaMask(image: [*c]Image, alphaMask: Image) void; -pub extern fn ImageAlphaClear(image: [*c]Image, color: Color, threshold: f32) void; -pub extern fn ImageAlphaCrop(image: [*c]Image, threshold: f32) void; -pub extern fn ImageAlphaPremultiply(image: [*c]Image) void; -pub extern fn ImageCrop(image: [*c]Image, crop: Rectangle) void; -pub extern fn ImageResize(image: [*c]Image, newWidth: c_int, newHeight: c_int) void; -pub extern fn ImageResizeNN(image: [*c]Image, newWidth: c_int, newHeight: c_int) void; -pub extern fn ImageResizeCanvas(image: [*c]Image, newWidth: c_int, newHeight: c_int, offsetX: c_int, offsetY: c_int, color: Color) void; -pub extern fn ImageMipmaps(image: [*c]Image) void; -pub extern fn ImageDither(image: [*c]Image, rBpp: c_int, gBpp: c_int, bBpp: c_int, aBpp: c_int) void; -pub extern fn ImageFlipVertical(image: [*c]Image) void; -pub extern fn ImageFlipHorizontal(image: [*c]Image) void; -pub extern fn ImageRotateCW(image: [*c]Image) void; -pub extern fn ImageRotateCCW(image: [*c]Image) void; -pub extern fn ImageColorTint(image: [*c]Image, color: Color) void; -pub extern fn ImageColorInvert(image: [*c]Image) void; -pub extern fn ImageColorGrayscale(image: [*c]Image) void; -pub extern fn ImageColorContrast(image: [*c]Image, contrast: f32) void; -pub extern fn ImageColorBrightness(image: [*c]Image, brightness: c_int) void; -pub extern fn ImageColorReplace(image: [*c]Image, color: Color, replace: Color) void; -pub extern fn ImageExtractPalette(image: Image, maxPaletteSize: c_int, extractCount: [*c]c_int) [*c]Color; -pub extern fn GetImageAlphaBorder(image: Image, threshold: f32) Rectangle; -pub extern fn ImageClearBackground(dst: [*c]Image, color: Color) void; -pub extern fn ImageDrawPixel(dst: [*c]Image, posX: c_int, posY: c_int, color: Color) void; -pub extern fn ImageDrawPixelV(dst: [*c]Image, position: Vector2, color: Color) void; -pub extern fn ImageDrawLine(dst: [*c]Image, startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void; -pub extern fn ImageDrawLineV(dst: [*c]Image, start: Vector2, end: Vector2, color: Color) void; -pub extern fn ImageDrawCircle(dst: [*c]Image, centerX: c_int, centerY: c_int, radius: c_int, color: Color) void; -pub extern fn ImageDrawCircleV(dst: [*c]Image, center: Vector2, radius: c_int, color: Color) void; -pub extern fn ImageDrawRectangle(dst: [*c]Image, posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void; -pub extern fn ImageDrawRectangleV(dst: [*c]Image, position: Vector2, size: Vector2, color: Color) void; -pub extern fn ImageDrawRectangleRec(dst: [*c]Image, rec: Rectangle, color: Color) void; -pub extern fn ImageDrawRectangleLines(dst: [*c]Image, rec: Rectangle, thick: c_int, color: Color) void; -pub extern fn ImageDraw(dst: [*c]Image, src: Image, srcRec: Rectangle, dstRec: Rectangle, tint: Color) void; -pub extern fn ImageDrawText(dst: [*c]Image, position: Vector2, text: [*c]const u8, fontSize: c_int, color: Color) void; -pub extern fn ImageDrawTextEx(dst: [*c]Image, position: Vector2, font: Font, text: [*c]const u8, fontSize: f32, spacing: f32, color: Color) void; -pub extern fn LoadTexture(fileName: [*c]const u8) Texture2D; -pub extern fn LoadTextureFromImage(image: Image) Texture2D; -pub extern fn LoadTextureCubemap(image: Image, layoutType: c_int) TextureCubemap; -pub extern fn LoadRenderTexture(width: c_int, height: c_int) RenderTexture2D; -pub extern fn UnloadTexture(texture: Texture2D) void; -pub extern fn UnloadRenderTexture(target: RenderTexture2D) void; -pub extern fn UpdateTexture(texture: Texture2D, pixels: ?*c_void) void; -pub extern fn GetTextureData(texture: Texture2D) Image; -pub extern fn GetScreenData() Image; -pub extern fn GenTextureMipmaps(texture: [*c]Texture2D) void; -pub extern fn SetTextureFilter(texture: Texture2D, filterMode: c_int) void; -pub extern fn SetTextureWrap(texture: Texture2D, wrapMode: c_int) void; -pub extern fn DrawTexture(texture: Texture2D, posX: c_int, posY: c_int, tint: Color) void; -pub extern fn DrawTextureV(texture: Texture2D, position: Vector2, tint: Color) void; -pub extern fn DrawTextureEx(texture: Texture2D, position: Vector2, rotation: f32, scale: f32, tint: Color) void; -pub extern fn DrawTextureRec(texture: Texture2D, sourceRec: Rectangle, position: Vector2, tint: Color) void; -pub extern fn DrawTextureQuad(texture: Texture2D, tiling: Vector2, offset: Vector2, quad: Rectangle, tint: Color) void; -pub extern fn DrawTexturePro(texture: Texture2D, sourceRec: Rectangle, destRec: Rectangle, origin: Vector2, rotation: f32, tint: Color) void; -pub extern fn DrawTextureNPatch(texture: Texture2D, nPatchInfo: NPatchInfo, destRec: Rectangle, origin: Vector2, rotation: f32, tint: Color) void; -pub extern fn GetPixelDataSize(width: c_int, height: c_int, format: PixelFormat) c_int; -pub extern fn GetFontDefault() Font; -pub extern fn LoadFont(fileName: [*c]const u8) Font; -pub extern fn LoadFontEx(fileName: [*c]const u8, fontSize: c_int, fontChars: [*c]c_int, charsCount: c_int) Font; -pub extern fn LoadFontFromImage(image: Image, key: Color, firstChar: c_int) Font; -pub extern fn LoadFontData(fileName: [*c]const u8, fontSize: c_int, fontChars: [*c]c_int, charsCount: c_int, type: c_int) [*c]CharInfo; -pub extern fn GenImageFontAtlas(chars: [*c]const CharInfo, recs: [*c][*c]Rectangle, charsCount: c_int, fontSize: c_int, padding: c_int, packMethod: c_int) Image; -pub extern fn UnloadFont(font: Font) void; -pub extern fn DrawFPS(posX: c_int, posY: c_int) void; -pub extern fn DrawText(text: [*c]const u8, posX: c_int, posY: c_int, fontSize: c_int, color: Color) void; -pub extern fn DrawTextEx(font: Font, text: [*c]const u8, position: Vector2, fontSize: f32, spacing: f32, tint: Color) void; -pub extern fn DrawTextRec(font: Font, text: [*c]const u8, rec: Rectangle, fontSize: f32, spacing: f32, wordWrap: bool, tint: Color) void; -pub extern fn DrawTextRecEx(font: Font, text: [*c]const u8, rec: Rectangle, fontSize: f32, spacing: f32, wordWrap: bool, tint: Color, selectStart: c_int, selectLength: c_int, selectTint: Color, selectBackTint: Color) void; -pub extern fn DrawTextCodepoint(font: Font, codepoint: c_int, position: Vector2, scale: f32, tint: Color) void; -pub extern fn MeasureText(text: [*c]const u8, fontSize: c_int) c_int; -pub extern fn MeasureTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32) Vector2; -pub extern fn GetGlyphIndex(font: Font, codepoint: c_int) c_int; -pub extern fn TextCopy(dst: [*c]u8, src: [*c]const u8) c_int; -pub extern fn TextIsEqual(text1: [*c]const u8, text2: [*c]const u8) bool; -pub extern fn TextLength(text: [*c]const u8) c_uint; -pub extern fn TextFormat(text: [*c]const u8, ...) [*c]const u8; -pub extern fn TextSubtext(text: [*c]const u8, position: c_int, length: c_int) [*c]const u8; -pub extern fn TextReplace(text: [*c]u8, replace: [*c]const u8, by: [*c]const u8) [*c]u8; -pub extern fn TextInsert(text: [*c]const u8, insert: [*c]const u8, position: c_int) [*c]u8; -pub extern fn TextJoin(textList: [*c][*c]const u8, count: c_int, delimiter: [*c]const u8) [*c]const u8; -pub extern fn TextSplit(text: [*c]const u8, delimiter: u8, count: [*c]c_int) [*c][*c]const u8; -pub extern fn TextAppend(text: [*c]u8, append: [*c]const u8, position: [*c]c_int) void; -pub extern fn TextFindIndex(text: [*c]const u8, find: [*c]const u8) c_int; -pub extern fn TextToUpper(text: [*c]const u8) [*c]const u8; -pub extern fn TextToLower(text: [*c]const u8) [*c]const u8; -pub extern fn TextToPascal(text: [*c]const u8) [*c]const u8; -pub extern fn TextToInteger(text: [*c]const u8) c_int; -pub extern fn TextToUtf8(codepoints: [*c]c_int, length: c_int) [*c]u8; -pub extern fn GetCodepoints(text: [*c]const u8, count: [*c]c_int) [*c]c_int; -pub extern fn GetCodepointsCount(text: [*c]const u8) c_int; -pub extern fn GetNextCodepoint(text: [*c]const u8, bytesProcessed: [*c]c_int) c_int; -pub extern fn CodepointToUtf8(codepoint: c_int, byteLength: [*c]c_int) [*c]const u8; -pub extern fn DrawLine3D(startPos: Vector3, endPos: Vector3, color: Color) void; -pub extern fn DrawPoint3D(position: Vector3, color: Color) void; -pub extern fn DrawCircle3D(center: Vector3, radius: f32, rotationAxis: Vector3, rotationAngle: f32, color: Color) void; -pub extern fn DrawCube(position: Vector3, width: f32, height: f32, length: f32, color: Color) void; -pub extern fn DrawCubeV(position: Vector3, size: Vector3, color: Color) void; -pub extern fn DrawCubeWires(position: Vector3, width: f32, height: f32, length: f32, color: Color) void; -pub extern fn DrawCubeWiresV(position: Vector3, size: Vector3, color: Color) void; -pub extern fn DrawCubeTexture(texture: Texture2D, position: Vector3, width: f32, height: f32, length: f32, color: Color) void; -//pub extern fn DrawSphere(centerPos: Vector3, radius: f32, color: Color) void; -pub extern fn DrawSphereEx(centerPos: Vector3, radius: f32, rings: c_int, slices: c_int, color: Color) void; -pub extern fn DrawSphereWires(centerPos: Vector3, radius: f32, rings: c_int, slices: c_int, color: Color) void; -pub extern fn DrawCylinder(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: Color) void; -pub extern fn DrawCylinderWires(position: Vector3, radiusTop: f32, radiusBottom: f32, height: f32, slices: c_int, color: Color) void; -pub extern fn DrawPlane(centerPos: Vector3, size: Vector2, color: Color) void; -//pub extern fn DrawRay(ray: Ray, color: Color) void; -pub extern fn DrawGrid(slices: c_int, spacing: f32) void; -pub extern fn DrawGizmo(position: Vector3) void; -pub extern fn LoadModel(fileName: [*c]const u8) Model; -pub extern fn LoadModelFromMesh(mesh: Mesh) Model; -pub extern fn UnloadModel(model: Model) void; -pub extern fn LoadMeshes(fileName: [*c]const u8, meshCount: [*c]c_int) [*c]Mesh; -pub extern fn ExportMesh(mesh: Mesh, fileName: [*c]const u8) void; -pub extern fn UnloadMesh(mesh: Mesh) void; -pub extern fn LoadMaterials(fileName: [*c]const u8, materialCount: [*c]c_int) [*c]Material; -pub extern fn LoadMaterialDefault() Material; -pub extern fn UnloadMaterial(material: Material) void; -pub extern fn SetMaterialTexture(material: [*c]Material, mapType: c_int, texture: Texture2D) void; -pub extern fn SetModelMeshMaterial(model: [*c]Model, meshId: c_int, materialId: c_int) void; -pub extern fn LoadModelAnimations(fileName: [*c]const u8, animsCount: [*c]c_int) [*c]ModelAnimation; -pub extern fn UpdateModelAnimation(model: Model, anim: ModelAnimation, frame: c_int) void; -pub extern fn UnloadModelAnimation(anim: ModelAnimation) void; -pub extern fn IsModelAnimationValid(model: Model, anim: ModelAnimation) bool; -pub extern fn GenMeshPoly(sides: c_int, radius: f32) Mesh; -pub extern fn GenMeshPlane(width: f32, length: f32, resX: c_int, resZ: c_int) Mesh; -pub extern fn GenMeshCube(width: f32, height: f32, length: f32) Mesh; -pub extern fn GenMeshSphere(radius: f32, rings: c_int, slices: c_int) Mesh; -pub extern fn GenMeshHemiSphere(radius: f32, rings: c_int, slices: c_int) Mesh; -pub extern fn GenMeshCylinder(radius: f32, height: f32, slices: c_int) Mesh; -pub extern fn GenMeshTorus(radius: f32, size: f32, radSeg: c_int, sides: c_int) Mesh; -pub extern fn GenMeshKnot(radius: f32, size: f32, radSeg: c_int, sides: c_int) Mesh; -pub extern fn GenMeshHeightmap(heightmap: Image, size: Vector3) Mesh; -pub extern fn GenMeshCubicmap(cubicmap: Image, cubeSize: Vector3) Mesh; -pub extern fn MeshBoundingBox(mesh: Mesh) BoundingBox; -pub extern fn MeshTangents(mesh: [*c]Mesh) void; -pub extern fn MeshBinormals(mesh: [*c]Mesh) void; -pub extern fn DrawModel(model: Model, position: Vector3, scale: f32, tint: Color) void; -pub extern fn DrawModelEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void; -pub extern fn DrawModelWires(model: Model, position: Vector3, scale: f32, tint: Color) void; -pub extern fn DrawModelWiresEx(model: Model, position: Vector3, rotationAxis: Vector3, rotationAngle: f32, scale: Vector3, tint: Color) void; -pub extern fn DrawBoundingBox(box: BoundingBox, color: Color) void; -pub extern fn DrawBillboard(camera: Camera, texture: Texture2D, center: Vector3, size: f32, tint: Color) void; -pub extern fn DrawBillboardRec(camera: Camera, texture: Texture2D, sourceRec: Rectangle, center: Vector3, size: f32, tint: Color) void; -pub extern fn CheckCollisionSpheres(centerA: Vector3, radiusA: f32, centerB: Vector3, radiusB: f32) bool; -pub extern fn CheckCollisionBoxes(box1: BoundingBox, box2: BoundingBox) bool; -pub extern fn CheckCollisionBoxSphere(box: BoundingBox, center: Vector3, radius: f32) bool; -pub extern fn CheckCollisionRaySphere(ray: Ray, center: Vector3, radius: f32) bool; -pub extern fn CheckCollisionRaySphereEx(ray: Ray, center: Vector3, radius: f32, collisionPoint: [*c]Vector3) bool; -pub extern fn CheckCollisionRayBox(ray: Ray, box: BoundingBox) bool; -pub extern fn GetCollisionRayModel(ray: Ray, model: Model) RayHitInfo; -pub extern fn GetCollisionRayTriangle(ray: Ray, p1: Vector3, p2: Vector3, p3: Vector3) RayHitInfo; -pub extern fn GetCollisionRayGround(ray: Ray, groundHeight: f32) RayHitInfo; -pub extern fn LoadShader(vsFileName: [*c]const u8, fsFileName: [*c]const u8) Shader; -pub extern fn LoadShaderCode(vsCode: [*c]const u8, fsCode: [*c]const u8) Shader; -pub extern fn UnloadShader(shader: Shader) void; -pub extern fn GetShaderDefault() Shader; -pub extern fn GetTextureDefault() Texture2D; -pub extern fn GetShapesTexture() Texture2D; -pub extern fn GetShapesTextureRec() Rectangle; -pub extern fn SetShapesTexture(texture: Texture2D, source: Rectangle) void; -pub extern fn GetShaderLocation(shader: Shader, uniformName: [*c]const u8) c_int; -pub extern fn SetShaderValue(shader: Shader, uniformLoc: c_int, value: ?*c_void, uniformType: c_int) void; -pub extern fn SetShaderValueV(shader: Shader, uniformLoc: c_int, value: ?*c_void, uniformType: c_int, count: c_int) void; -pub extern fn SetShaderValueMatrix(shader: Shader, uniformLoc: c_int, mat: Matrix) void; -pub extern fn SetShaderValueTexture(shader: Shader, uniformLoc: c_int, texture: Texture2D) void; -pub extern fn SetMatrixProjection(proj: Matrix) void; -pub extern fn SetMatrixModelview(view: Matrix) void; -pub extern fn GetMatrixModelview() Matrix; -pub extern fn GetMatrixProjection() Matrix; -pub extern fn GenTextureCubemap(shader: Shader, map: Texture2D, size: c_int) Texture2D; -pub extern fn GenTextureIrradiance(shader: Shader, cubemap: Texture2D, size: c_int) Texture2D; -pub extern fn GenTexturePrefilter(shader: Shader, cubemap: Texture2D, size: c_int) Texture2D; -pub extern fn GenTextureBRDF(shader: Shader, size: c_int) Texture2D; -pub extern fn BeginShaderMode(shader: Shader) void; -pub extern fn EndShaderMode() void; -pub extern fn BeginBlendMode(mode: c_int) void; -pub extern fn EndBlendMode() void; -pub extern fn InitVrSimulator() void; -pub extern fn CloseVrSimulator() void; -pub extern fn UpdateVrTracking(camera: [*c]Camera) void; -pub extern fn SetVrConfiguration(info: VrDeviceInfo, distortion: Shader) void; -pub extern fn IsVrSimulatorReady() bool; -pub extern fn ToggleVrMode() void; -pub extern fn BeginVrDrawing() void; -pub extern fn EndVrDrawing() void; -pub extern fn InitAudioDevice() void; -pub extern fn CloseAudioDevice() void; -pub extern fn IsAudioDeviceReady() bool; -pub extern fn SetMasterVolume(volume: f32) void; -pub extern fn LoadWave(fileName: [*c]const u8) Wave; -pub extern fn LoadSound(fileName: [*c]const u8) Sound; -pub extern fn LoadSoundFromWave(wave: Wave) Sound; -pub extern fn UpdateSound(sound: Sound, data: ?*c_void, samplesCount: c_int) void; -pub extern fn UnloadWave(wave: Wave) void; -pub extern fn UnloadSound(sound: Sound) void; -pub extern fn ExportWave(wave: Wave, fileName: [*c]const u8) void; -pub extern fn ExportWaveAsCode(wave: Wave, fileName: [*c]const u8) void; -pub extern fn PlaySound(sound: Sound) void; -pub extern fn StopSound(sound: Sound) void; -pub extern fn PauseSound(sound: Sound) void; -pub extern fn ResumeSound(sound: Sound) void; -pub extern fn PlaySoundMulti(sound: Sound) void; -pub extern fn StopSoundMulti() void; -pub extern fn GetSoundsPlaying() c_int; -pub extern fn IsSoundPlaying(sound: Sound) bool; -pub extern fn SetSoundVolume(sound: Sound, volume: f32) void; -pub extern fn SetSoundPitch(sound: Sound, pitch: f32) void; -pub extern fn WaveFormat(wave: [*c]Wave, sampleRate: c_int, sampleSize: c_int, channels: c_int) void; -pub extern fn WaveCopy(wave: Wave) Wave; -pub extern fn WaveCrop(wave: [*c]Wave, initSample: c_int, finalSample: c_int) void; -pub extern fn GetWaveData(wave: Wave) [*c]f32; -pub extern fn LoadMusicStream(fileName: [*c]const u8) Music; -pub extern fn UnloadMusicStream(music: Music) void; -pub extern fn PlayMusicStream(music: Music) void; -pub extern fn UpdateMusicStream(music: Music) void; -pub extern fn StopMusicStream(music: Music) void; -pub extern fn PauseMusicStream(music: Music) void; -pub extern fn ResumeMusicStream(music: Music) void; -pub extern fn IsMusicPlaying(music: Music) bool; -pub extern fn SetMusicVolume(music: Music, volume: f32) void; -pub extern fn SetMusicPitch(music: Music, pitch: f32) void; -pub extern fn SetMusicLoopCount(music: Music, count: c_int) void; -pub extern fn GetMusicTimeLength(music: Music) f32; -pub extern fn GetMusicTimePlayed(music: Music) f32; -pub extern fn InitAudioStream(sampleRate: c_uint, sampleSize: c_uint, channels: c_uint) AudioStream; -pub extern fn UpdateAudioStream(stream: AudioStream, data: ?*c_void, samplesCount: c_int) void; -pub extern fn CloseAudioStream(stream: AudioStream) void; -pub extern fn IsAudioStreamProcessed(stream: AudioStream) bool; -pub extern fn PlayAudioStream(stream: AudioStream) void; -pub extern fn PauseAudioStream(stream: AudioStream) void; -pub extern fn ResumeAudioStream(stream: AudioStream) void; -pub extern fn IsAudioStreamPlaying(stream: AudioStream) bool; -pub extern fn StopAudioStream(stream: AudioStream) void; -pub extern fn SetAudioStreamVolume(stream: AudioStream, volume: f32) void; -pub extern fn SetAudioStreamPitch(stream: AudioStream, pitch: f32) void; - pub const MAP_DIFFUSE = MaterialMapType.MAP_ALBEDO; pub const MAP_SPECULAR = MaterialMapType.MAP_METALNESS; pub const LOC_MAP_SPECULAR = LOC_MAP_METALNESS; @@ -1187,262 +745,4 @@ pub const SubText = TextSubtext; pub const ShowWindow = UnhideWindow; pub const FormatText = TextFormat; -// ---------- WORKAROUND ---------- -pub extern fn WGetMouseRay(mousePosition: [*c]const Vector2, camera: Camera) Ray; -pub extern fn WDrawPixel(posX: c_int, posY: c_int, color: [*c]const Color) void; -pub extern fn WDrawPixelV(position: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: [*c]const Color) void; -pub extern fn WDrawLineV(startPos: [*c]const Vector2, endPos: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawLineEx(startPos: [*c]const Vector2, endPos: [*c]const Vector2, thick: f32, color: [*c]const Color) void; -pub extern fn WDrawLineBezier(startPos: [*c]const Vector2, endPos: [*c]const Vector2, thick: f32, color: [*c]const Color) void; -pub extern fn WDrawLineStrip(points: [*c]const Vector2, numPoints: c_int, color: [*c]const Color) void; -pub extern fn WDrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawCircleSector(center: [*c]const Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawCircleSectorLines(center: [*c]const Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: [*c]const Color, color2: [*c]const Color) void; -pub extern fn WDrawCircleV(center: [*c]const Vector2, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: [*c]const Color) void; -pub extern fn WDrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: [*c]const Color) void; -pub extern fn WDrawRing(center: [*c]const Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawRingLines(center: [*c]const Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleV(position: [*c]const Vector2, size: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawRectangleRec(rec: [*c]const Rectangle, color: [*c]const Color) void; -pub extern fn WDrawRectanglePro(rec: [*c]const Rectangle, origin: [*c]const Vector2, rotation: f32, color: [*c]const Color) void; -pub extern fn WDrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: [*c]const Color, color2: [*c]const Color) void; -pub extern fn WDrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: [*c]const Color, color2: [*c]const Color) void; -pub extern fn WDrawRectangleGradientEx(rec: [*c]const Rectangle, col1: [*c]const Color, col2: [*c]const Color, col3: [*c]const Color, col4: [*c]const Color) void; -pub extern fn WDrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleLinesEx(rec: [*c]const Rectangle, lineThick: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleRounded(rec: [*c]const Rectangle, roundness: f32, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleRoundedLines(rec: [*c]const Rectangle, roundness: f32, segments: c_int, lineThick: c_int, color: [*c]const Color) void; -pub extern fn WDrawTriangle(v1: [*c]const Vector2, v2: [*c]const Vector2, v3: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawTriangleLines(v1: [*c]const Vector2, v2: [*c]const Vector2, v3: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawTriangleFan(points: [*c]const Vector2, numPoints: c_int, color: [*c]const Color) void; -pub extern fn WDrawTriangleStrip(points: [*c]const Vector2, pointsCount: c_int, color: [*c]const Color) void; -pub extern fn WDrawPoly(center: [*c]const Vector2, sides: c_int, radius: f32, rotation: f32, color: [*c]const Color) void; -pub extern fn WDrawPolyLines(center: [*c]const Vector2, sides: c_int, radius: f32, rotation: f32, color: [*c]const Color) void; -pub extern fn WCheckCollisionRecs(rec1: [*c]const Rectangle, rec2: [*c]const Rectangle) bool; -pub extern fn WCheckCollisionCircles(center1: [*c]const Vector2, radius1: f32, center2: [*c]const Vector2, radius2: f32) bool; -pub extern fn WCheckCollisionCircleRec(center: [*c]const Vector2, radius: f32, rec: [*c]const Rectangle) bool; -pub extern fn WCheckCollisionPointRec(point: [*c]const Vector2, rec: [*c]const Rectangle) bool; -pub extern fn WCheckCollisionPointCircle(point: [*c]const Vector2, center: [*c]const Vector2, radius: f32) bool; -pub extern fn WCheckCollisionPointTriangle(point: [*c]const Vector2, p1: [*c]const Vector2, p2: [*c]const Vector2, p3: [*c]const Vector2) bool; -pub extern fn WDrawSphere(centerPos: [*c]const Vector3, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawRay(ray: Ray, color: [*c]const Color) void; - -pub fn GetMouseRay(mousePosition: Vector2, camera: Camera) Ray -{ - return WGetMouseRay(&mousePosition, camera); -} - -pub fn DrawPixel(posX: c_int, posY: c_int, color: Color) void -{ - WDrawPixel(posX, posY, &color); -} - -pub fn DrawPixelV(position: Vector2, color: Color) void -{ - WDrawPixelV(&position, &color); -} - -pub fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void -{ - WDrawLine(startPosX, startPosY, endPosX, endPosY, &color); -} - -pub fn DrawLineV(startPos: Vector2, endPos: Vector2, color: Color) void -{ - WDrawLineV(&startPos, &endPos, &color); -} - -pub fn DrawLineEx(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void -{ - WDrawLineEx(&startPos, &endPos, thick, &color); -} - -pub fn DrawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void -{ - WDrawLineBezier(&startPos, &endPos, thick, &color); -} - -pub fn DrawLineStrip(points: []const Vector2, numPoints: c_int, color: Color) void -{ - WDrawLineStrip(&points[0], numPoints, &color); -} - -pub fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: Color) void -{ - WDrawCircle(centerX, centerY, radius, &color); -} - -pub fn DrawCircleSector(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawCircleSector(¢er, radius, startAngle, endAngle, segments, &color); -} - -pub fn DrawCircleSectorLines(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawCircleSectorLines(¢er, radius, startAngle, endAngle, segments, &color); -} - -pub fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: Color, color2: Color) void -{ - WDrawCircleGradient(centerX, centerY, radius, &color1, &color2); -} - -pub fn DrawCircleV(center: Vector2, radius: f32, color: Color) void -{ - WDrawCircleV(¢er, radius, &color); -} - -pub fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: Color) void -{ - WDrawCircleLines(centerX, centerY, radius, &color); -} - -pub fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void -{ - WDrawEllipse(centerX, centerY, radiusH, radiusV, &color); -} - -pub fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void -{ - WDrawEllipseLines(centerX, centerY, radiusH, radiusV, &color); -} - -pub fn DrawRing(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawRing(¢er, innerRadius, outerRadius, startAngle, endAngle, segments, &color); -} - -pub fn DrawRingLines(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawRingLines(¢er, innerRadius, outerRadius, startAngle, endAngle, segments, &color); -} - -pub fn DrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void -{ - WDrawRectangle(posX, posY, width, height, &color); -} - -pub fn DrawRectangleV(position: Vector2, size: Vector2, color: Color) void -{ - WDrawRectangleV(&position, &size, &color); -} - -pub fn DrawRectangleRec(rec: Rectangle, color: Color) void -{ - WDrawRectangleRec(&rec, &color); -} - -pub fn DrawRectanglePro(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) void -{ - WDrawRectanglePro(&rec, &origin, rotation, &color); -} - -pub fn DrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void -{ - WDrawRectangleGradientV(posX, posY, width, height, &color1, &color2); -} - -pub fn DrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void -{ - WDrawRectangleGradientH(posX, posY, width, height, &color1, &color2); -} - -pub fn DrawRectangleGradientEx(rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color) void -{ - WDrawRectangleGradientEx(&rec, &col1, &col2, &col3, &col4); -} - -pub fn DrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void -{ - WDrawRectangleLines(posX, posY, width, height, &color); -} - -pub fn DrawRectangleLinesEx(rec: Rectangle, lineThick: c_int, color: Color) void -{ - WDrawRectangleLinesEx(&rec, lineThick, &color); -} - -pub fn DrawRectangleRounded(rec: Rectangle, roundness: f32, segments: c_int, color: Color) void -{ - WDrawRectangleRounded(&rec, roundness, segments, &color); -} - -pub fn DrawRectangleRoundedLines(rec: Rectangle, roundness: f32, segments: c_int, lineThick: c_int, color: Color) void -{ - WDrawRectangleRoundedLines(&rec, roundness, segments, lineThick, &color); -} - -pub fn DrawTriangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void -{ - WDrawTriangle(&v1, &v2, &v3, &color); -} - -pub fn DrawTriangleLines(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void -{ - WDrawTriangleLines(&v1, &v2, &v3, &color); -} - -pub fn DrawTriangleFan(points: []const Vector2, numPoints: c_int, color: Color) void -{ - WDrawTriangleFan(&points[0], numPoints, &color); -} - -pub fn DrawTriangleStrip(points: []const Vector2, pointsCount: c_int, color: Color) void -{ - WDrawTriangleStrip(&points[0], pointsCount, &color); -} - -pub fn DrawPoly(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void -{ - WDrawPoly(¢er, sides, radius, rotation, &color); -} - -pub fn DrawPolyLines(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void -{ - WDrawPolyLines(¢er, sides, radius, rotation, &color); -} - -pub fn CheckCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool -{ - return WCheckCollisionRecs(&rec1, &rec2); -} - -pub fn CheckCollisionCircles(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) bool -{ - return WCheckCollisionCircles(¢er1, radius1, ¢er2, radius2); -} - -pub fn CheckCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) bool -{ - return WCheckCollisionCircleRec(¢er, radius, &rec); -} - -pub fn CheckCollisionPointRec(point: Vector2, rec: Rectangle) bool -{ - return WCheckCollisionPointRec(&point, &rec); -} - -pub fn CheckCollisionPointCircle(point: Vector2, center: Vector2, radius: f32) bool -{ - return WCheckCollisionPointCircle(&point, ¢er, radius); -} - -pub fn CheckCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) bool -{ - return WCheckCollisionPointTriangle(&point, &p1, &p2, &p3); -} - -pub fn DrawSphere(centerPos: Vector3, radius: f32, color: Color) void -{ - WDrawSphere(¢erPos, radius, &color); -} - -pub fn DrawRay(ray: Ray, color: Color) void -{ - WDrawRay(ray, &color); -} +pub usingnamespace @import("raylib-wa.zig"); diff --git a/lib/workaround.c b/lib/workaround.c new file mode 100644 index 0000000..2d75455 --- /dev/null +++ b/lib/workaround.c @@ -0,0 +1,720 @@ +// raylib-zig (c) Nikolas Wipper 2020 + +#include +#include + +void WClearBackground(Color *color) +{ + ClearBackground(*color); +} + +Ray WGetMouseRay(Vector2 *mousePosition, Camera camera) +{ + return GetMouseRay(*mousePosition, camera); +} + +int WColorToInt(Color *color) +{ + return ColorToInt(*color); +} + +void WDrawPixel(int posX, int posY, Color *color) +{ + DrawPixel(posX, posY, *color); +} + +void WDrawPixelV(Vector2 *position, Color *color) +{ + DrawPixelV(*position, *color); +} + +void WDrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color *color) +{ + DrawLine(startPosX, startPosY, endPosX, endPosY, *color); +} + +void WDrawLineV(Vector2 *startPos, Vector2 *endPos, Color *color) +{ + DrawLineV(*startPos, *endPos, *color); +} + +void WDrawLineEx(Vector2 *startPos, Vector2 *endPos, float thick, Color *color) +{ + DrawLineEx(*startPos, *endPos, thick, *color); +} + +void WDrawLineBezier(Vector2 *startPos, Vector2 *endPos, float thick, Color *color) +{ + DrawLineBezier(*startPos, *endPos, thick, *color); +} + +void WDrawLineStrip(Vector2 *points, int numPoints, Color *color) +{ + DrawLineStrip(points, numPoints, *color); +} + +void WDrawCircle(int centerX, int centerY, float radius, Color *color) +{ + DrawCircle(centerX, centerY, radius, *color); +} + +void WDrawCircleSector(Vector2 *center, float radius, int startAngle, int endAngle, int segments, Color *color) +{ + DrawCircleSector(*center, radius, startAngle, endAngle, segments, *color); +} + +void WDrawCircleSectorLines(Vector2 *center, float radius, int startAngle, int endAngle, int segments, Color *color) +{ + DrawCircleSectorLines(*center, radius, startAngle, endAngle, segments, *color); +} + +void WDrawCircleGradient(int centerX, int centerY, float radius, Color *color1, Color *color2) +{ + DrawCircleGradient(centerX, centerY, radius, *color1, *color2); +} + +void WDrawCircleV(Vector2 *center, float radius, Color *color) +{ + DrawCircleV(*center, radius, *color); +} + +void WDrawCircleLines(int centerX, int centerY, float radius, Color *color) +{ + DrawCircleLines(centerX, centerY, radius, *color); +} + +void WDrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color *color) +{ + DrawEllipse(centerX, centerY, radiusH, radiusV, *color); +} + +void WDrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color *color) +{ + DrawEllipseLines(centerX, centerY, radiusH, radiusV, *color); +} + +void WDrawRing(Vector2 *center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color *color) +{ + DrawRing(*center, innerRadius, outerRadius, startAngle, endAngle, segments, *color); +} + +void WDrawRingLines(Vector2 *center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color *color) +{ + DrawRingLines(*center, innerRadius, outerRadius, startAngle, endAngle, segments, *color); +} + +void WDrawRectangle(int posX, int posY, int width, int height, Color *color) +{ + DrawRectangle(posX, posY, width, height, *color); +} + +void WDrawRectangleV(Vector2 *position, Vector2 *size, Color *color) +{ + DrawRectangleV(*position, *size, *color); +} + +void WDrawRectangleRec(Rectangle *rec, Color *color) +{ + DrawRectangleRec(*rec, *color); +} + +void WDrawRectanglePro(Rectangle *rec, Vector2 *origin, float rotation, Color *color) +{ + DrawRectanglePro(*rec, *origin, rotation, *color); +} + +void WDrawRectangleGradientV(int posX, int posY, int width, int height, Color *color1, Color *color2) +{ + DrawRectangleGradientV(posX, posY, width, height, *color1, *color2); +} + +void WDrawRectangleGradientH(int posX, int posY, int width, int height, Color *color1, Color *color2) +{ + DrawRectangleGradientH(posX, posY, width, height, *color1, *color2); +} + +void WDrawRectangleGradientEx(Rectangle *rec, Color *col1, Color *col2, Color *col3, Color *col4) +{ + DrawRectangleGradientEx(*rec, *col1, *col2, *col3, *col4); +} + +void WDrawRectangleLines(int posX, int posY, int width, int height, Color *color) +{ + DrawRectangleLines(posX, posY, width, height, *color); +} + +void WDrawRectangleLinesEx(Rectangle *rec, int lineThick, Color *color) +{ + DrawRectangleLinesEx(*rec, lineThick, *color); +} + +void WDrawRectangleRounded(Rectangle *rec, float roundness, int segments, Color *color) +{ + DrawRectangleRounded(*rec, roundness, segments, *color); +} + +void WDrawRectangleRoundedLines(Rectangle *rec, float roundness, int segments, int lineThick, Color *color) +{ + DrawRectangleRoundedLines(*rec, roundness, segments, lineThick, *color); +} + +void WDrawTriangle(Vector2 *v1, Vector2 *v2, Vector2 *v3, Color *color) +{ + DrawTriangle(*v1, *v2, *v3, *color); +} + +void WDrawTriangleLines(Vector2 *v1, Vector2 *v2, Vector2 *v3, Color *color) +{ + DrawTriangleLines(*v1, *v2, *v3, *color); +} + +void WDrawTriangleFan(Vector2 *points, int numPoints, Color *color) +{ + DrawTriangleFan(points, numPoints, *color); +} + +void WDrawTriangleStrip(Vector2 *points, int pointsCount, Color *color) +{ + DrawTriangleStrip(points, pointsCount, *color); +} + +void WDrawPoly(Vector2 *center, int sides, float radius, float rotation, Color *color) +{ + DrawPoly(*center, sides, radius, rotation, *color); +} + +void WDrawPolyLines(Vector2 *center, int sides, float radius, float rotation, Color *color) +{ + DrawPolyLines(*center, sides, radius, rotation, *color); +} + +bool WCheckCollisionRecs(Rectangle *rec1, Rectangle *rec2) +{ + return CheckCollisionRecs(*rec1, *rec2); +} + +bool WCheckCollisionCircles(Vector2 *center1, float radius1, Vector2 *center2, float radius2) +{ + return CheckCollisionCircles(*center1, radius1, *center2, radius2); +} + +bool WCheckCollisionCircleRec(Vector2 *center, float radius, Rectangle *rec) +{ + return CheckCollisionCircleRec(*center, radius, *rec); +} + +bool WCheckCollisionPointRec(Vector2 *point, Rectangle *rec) +{ + return CheckCollisionPointRec(*point, *rec); +} + +bool WCheckCollisionPointCircle(Vector2 *point, Vector2 *center, float radius) +{ + return CheckCollisionPointCircle(*point, *center, radius); +} + +bool WCheckCollisionPointTriangle(Vector2 *point, Vector2 *p1, Vector2 *p2, Vector2 *p3) +{ + return CheckCollisionPointTriangle(*point, *p1, *p2, *p3); +} + +Image WLoadImageEx(Color *pixels, int width, int height) +{ + return LoadImageEx(pixels, width, height); +} + +Image WGenImageColor(int width, int height, Color *color) +{ + return GenImageColor(width, height, *color); +} + +Image WGenImageGradientV(int width, int height, Color *top, Color *bottom) +{ + return GenImageGradientV(width, height, *top, *bottom); +} + +Image WGenImageGradientH(int width, int height, Color *left, Color *right) +{ + return GenImageGradientH(width, height, *left, *right); +} + +Image WGenImageGradientRadial(int width, int height, float density, Color *inner, Color *outer) +{ + return GenImageGradientRadial(width, height, density, *inner, *outer); +} + +Image WGenImageChecked(int width, int height, int checksX, int checksY, Color *col1, Color *col2) +{ + return GenImageChecked(width, height, checksX, checksY, *col1, *col2); +} + +Image WImageFromImage(Image image, Rectangle *rec) +{ + return ImageFromImage(image, *rec); +} + +Image WImageText(char *text, int fontSize, Color *color) +{ + return ImageText(text, fontSize, *color); +} + +Image WImageTextEx(Font font, char *text, float fontSize, float spacing, Color *tint) +{ + return ImageTextEx(font, text, fontSize, spacing, *tint); +} + +void WImageToPOT(Image *image, Color *fillColor) +{ + ImageToPOT(image, *fillColor); +} + +void WImageAlphaClear(Image *image, Color *color, float threshold) +{ + ImageAlphaClear(image, *color, threshold); +} + +void WImageCrop(Image *image, Rectangle *crop) +{ + ImageCrop(image, *crop); +} + +void WImageResizeCanvas(Image *image, int newWidth, int newHeight, int offsetX, int offsetY, Color *color) +{ + ImageResizeCanvas(image, newWidth, newHeight, offsetX, offsetY, *color); +} + +void WImageColorTint(Image *image, Color *color) +{ + ImageColorTint(image, *color); +} + +void WImageColorReplace(Image *image, Color *color, Color *replace) +{ + ImageColorReplace(image, *color, *replace); +} + +void WImageClearBackground(Image *dst, Color *color) +{ + ImageClearBackground(dst, *color); +} + +void WImageDrawPixel(Image *dst, int posX, int posY, Color *color) +{ + ImageDrawPixel(dst, posX, posY, *color); +} + +void WImageDrawPixelV(Image *dst, Vector2 *position, Color *color) +{ + ImageDrawPixelV(dst, *position, *color); +} + +void WImageDrawLine(Image *dst, int startPosX, int startPosY, int endPosX, int endPosY, Color *color) +{ + ImageDrawLine(dst, startPosX, startPosY, endPosX, endPosY, *color); +} + +void WImageDrawLineV(Image *dst, Vector2 *start, Vector2 *end, Color *color) +{ + ImageDrawLineV(dst, *start, *end, *color); +} + +void WImageDrawCircle(Image *dst, int centerX, int centerY, int radius, Color *color) +{ + ImageDrawCircle(dst, centerX, centerY, radius, *color); +} + +void WImageDrawCircleV(Image *dst, Vector2 *center, int radius, Color *color) +{ + ImageDrawCircleV(dst, *center, radius, *color); +} + +void WImageDrawRectangle(Image *dst, int posX, int posY, int width, int height, Color *color) +{ + ImageDrawRectangle(dst, posX, posY, width, height, *color); +} + +void WImageDrawRectangleV(Image *dst, Vector2 *position, Vector2 *size, Color *color) +{ + ImageDrawRectangleV(dst, *position, *size, *color); +} + +void WImageDrawRectangleRec(Image *dst, Rectangle *rec, Color *color) +{ + ImageDrawRectangleRec(dst, *rec, *color); +} + +void WImageDrawRectangleLines(Image *dst, Rectangle *rec, int thick, Color *color) +{ + ImageDrawRectangleLines(dst, *rec, thick, *color); +} + +void WImageDraw(Image *dst, Image src, Rectangle *srcRec, Rectangle *dstRec, Color *tint) +{ + ImageDraw(dst, src, *srcRec, *dstRec, *tint); +} + +void WImageDrawText(Image *dst, Vector2 *position, char *text, int fontSize, Color *color) +{ + ImageDrawText(dst, *position, text, fontSize, *color); +} + +void WImageDrawTextEx(Image *dst, Vector2 *position, Font font, char *text, float fontSize, float spacing, Color *color) +{ + ImageDrawTextEx(dst, *position, font, text, fontSize, spacing, *color); +} + +void WDrawTexture(Texture2D texture, int posX, int posY, Color *tint) +{ + DrawTexture(texture, posX, posY, *tint); +} + +void WDrawTextureV(Texture2D texture, Vector2 *position, Color *tint) +{ + DrawTextureV(texture, *position, *tint); +} + +void WDrawTextureEx(Texture2D texture, Vector2 *position, float rotation, float scale, Color *tint) +{ + DrawTextureEx(texture, *position, rotation, scale, *tint); +} + +void WDrawTextureRec(Texture2D texture, Rectangle *sourceRec, Vector2 *position, Color *tint) +{ + DrawTextureRec(texture, *sourceRec, *position, *tint); +} + +void WDrawTextureQuad(Texture2D texture, Vector2 *tiling, Vector2 *offset, Rectangle *quad, Color *tint) +{ + DrawTextureQuad(texture, *tiling, *offset, *quad, *tint); +} + +void WDrawTexturePro(Texture2D texture, Rectangle *sourceRec, Rectangle *destRec, Vector2 *origin, float rotation, Color *tint) +{ + DrawTexturePro(texture, *sourceRec, *destRec, *origin, rotation, *tint); +} + +void WDrawTextureNPatch(Texture2D texture, NPatchInfo nPatchInfo, Rectangle *destRec, Vector2 *origin, float rotation, Color *tint) +{ + DrawTextureNPatch(texture, nPatchInfo, *destRec, *origin, rotation, *tint); +} + +Font WLoadFontFromImage(Image image, Color *key, int firstChar) +{ + return LoadFontFromImage(image, *key, firstChar); +} + +Image WGenImageFontAtlas(CharInfo *chars, Rectangle **recs, int charsCount, int fontSize, int padding, int packMethod) +{ + return GenImageFontAtlas(chars, recs, charsCount, fontSize, padding, packMethod); +} + +void WDrawText(char *text, int posX, int posY, int fontSize, Color *color) +{ + DrawText(text, posX, posY, fontSize, *color); +} + +void WDrawTextEx(Font font, char *text, Vector2 *position, float fontSize, float spacing, Color *tint) +{ + DrawTextEx(font, text, *position, fontSize, spacing, *tint); +} + +void WDrawTextRec(Font font, char *text, Rectangle *rec, float fontSize, float spacing, bool wordWrap, Color *tint) +{ + DrawTextRec(font, text, *rec, fontSize, spacing, wordWrap, *tint); +} + +void WDrawTextRecEx(Font font, char *text, Rectangle *rec, float fontSize, float spacing, bool wordWrap, Color *tint, int selectStart, int selectLength, Color *selectTint, Color *selectBackTint) +{ + DrawTextRecEx(font, text, *rec, fontSize, spacing, wordWrap, *tint, selectStart, selectLength, *selectTint, *selectBackTint); +} + +void WDrawTextCodepoint(Font font, int codepoint, Vector2 *position, float scale, Color *tint) +{ + DrawTextCodepoint(font, codepoint, *position, scale, *tint); +} + +void WDrawLine3D(Vector3 *startPos, Vector3 *endPos, Color *color) +{ + DrawLine3D(*startPos, *endPos, *color); +} + +void WDrawPoint3D(Vector3 *position, Color *color) +{ + DrawPoint3D(*position, *color); +} + +void WDrawCircle3D(Vector3 *center, float radius, Vector3 *rotationAxis, float rotationAngle, Color *color) +{ + DrawCircle3D(*center, radius, *rotationAxis, rotationAngle, *color); +} + +void WDrawCube(Vector3 *position, float width, float height, float length, Color *color) +{ + DrawCube(*position, width, height, length, *color); +} + +void WDrawCubeV(Vector3 *position, Vector3 *size, Color *color) +{ + DrawCubeV(*position, *size, *color); +} + +void WDrawCubeWires(Vector3 *position, float width, float height, float length, Color *color) +{ + DrawCubeWires(*position, width, height, length, *color); +} + +void WDrawCubeWiresV(Vector3 *position, Vector3 *size, Color *color) +{ + DrawCubeWiresV(*position, *size, *color); +} + +void WDrawCubeTexture(Texture2D texture, Vector3 *position, float width, float height, float length, Color *color) +{ + DrawCubeTexture(texture, *position, width, height, length, *color); +} + +void WDrawSphere(Vector3 *centerPos, float radius, Color *color) +{ + DrawSphere(*centerPos, radius, *color); +} + +void WDrawSphereEx(Vector3 *centerPos, float radius, int rings, int slices, Color *color) +{ + DrawSphereEx(*centerPos, radius, rings, slices, *color); +} + +void WDrawSphereWires(Vector3 *centerPos, float radius, int rings, int slices, Color *color) +{ + DrawSphereWires(*centerPos, radius, rings, slices, *color); +} + +void WDrawCylinder(Vector3 *position, float radiusTop, float radiusBottom, float height, int slices, Color *color) +{ + DrawCylinder(*position, radiusTop, radiusBottom, height, slices, *color); +} + +void WDrawCylinderWires(Vector3 *position, float radiusTop, float radiusBottom, float height, int slices, Color *color) +{ + DrawCylinderWires(*position, radiusTop, radiusBottom, height, slices, *color); +} + +void WDrawPlane(Vector3 *centerPos, Vector2 *size, Color *color) +{ + DrawPlane(*centerPos, *size, *color); +} + +void WDrawRay(Ray ray, Color *color) +{ + DrawRay(ray, *color); +} + +void WDrawGizmo(Vector3 *position) +{ + DrawGizmo(*position); +} + +Mesh WGenMeshHeightmap(Image heightmap, Vector3 *size) +{ + return GenMeshHeightmap(heightmap, *size); +} + +Mesh WGenMeshCubicmap(Image cubicmap, Vector3 *cubeSize) +{ + return GenMeshCubicmap(cubicmap, *cubeSize); +} + +void WDrawModel(Model model, Vector3 *position, float scale, Color *tint) +{ + DrawModel(model, *position, scale, *tint); +} + +void WDrawModelEx(Model model, Vector3 *position, Vector3 *rotationAxis, float rotationAngle, Vector3 *scale, Color *tint) +{ + DrawModelEx(model, *position, *rotationAxis, rotationAngle, *scale, *tint); +} + +void WDrawModelWires(Model model, Vector3 *position, float scale, Color *tint) +{ + DrawModelWires(model, *position, scale, *tint); +} + +void WDrawModelWiresEx(Model model, Vector3 *position, Vector3 *rotationAxis, float rotationAngle, Vector3 *scale, Color *tint) +{ + DrawModelWiresEx(model, *position, *rotationAxis, rotationAngle, *scale, *tint); +} + +void WDrawBoundingBox(BoundingBox box, Color *color) +{ + DrawBoundingBox(box, *color); +} + +void WDrawBillboard(Camera camera, Texture2D texture, Vector3 *center, float size, Color *tint) +{ + DrawBillboard(camera, texture, *center, size, *tint); +} + +void WDrawBillboardRec(Camera camera, Texture2D texture, Rectangle *sourceRec, Vector3 *center, float size, Color *tint) +{ + DrawBillboardRec(camera, texture, *sourceRec, *center, size, *tint); +} + +bool WCheckCollisionSpheres(Vector3 *centerA, float radiusA, Vector3 *centerB, float radiusB) +{ + return CheckCollisionSpheres(*centerA, radiusA, *centerB, radiusB); +} + +bool WCheckCollisionBoxSphere(BoundingBox box, Vector3 *center, float radius) +{ + return CheckCollisionBoxSphere(box, *center, radius); +} + +bool WCheckCollisionRaySphere(Ray ray, Vector3 *center, float radius) +{ + return CheckCollisionRaySphere(ray, *center, radius); +} + +bool WCheckCollisionRaySphereEx(Ray ray, Vector3 *center, float radius, Vector3 *collisionPoint) +{ + return CheckCollisionRaySphereEx(ray, *center, radius, collisionPoint); +} + +RayHitInfo WGetCollisionRayTriangle(Ray ray, Vector3 *p1, Vector3 *p2, Vector3 *p3) +{ + return GetCollisionRayTriangle(ray, *p1, *p2, *p3); +} + +void WUnloadShader(Shader *shader) +{ + UnloadShader(*shader); +} + +void WSetShapesTexture(Texture2D texture, Rectangle *source) +{ + SetShapesTexture(texture, *source); +} + +int WGetShaderLocation(Shader *shader, char *uniformName) +{ + return GetShaderLocation(*shader, uniformName); +} + +void WSetShaderValue(Shader *shader, int uniformLoc, void *value, int uniformType) +{ + SetShaderValue(*shader, uniformLoc, value, uniformType); +} + +void WSetShaderValueV(Shader *shader, int uniformLoc, void *value, int uniformType, int count) +{ + SetShaderValueV(*shader, uniformLoc, value, uniformType, count); +} + +void WSetShaderValueMatrix(Shader *shader, int uniformLoc, Matrix mat) +{ + SetShaderValueMatrix(*shader, uniformLoc, mat); +} + +void WSetShaderValueTexture(Shader *shader, int uniformLoc, Texture2D texture) +{ + SetShaderValueTexture(*shader, uniformLoc, texture); +} + +Texture2D WGenTextureCubemap(Shader *shader, Texture2D map, int size) +{ + return GenTextureCubemap(*shader, map, size); +} + +Texture2D WGenTextureIrradiance(Shader *shader, Texture2D cubemap, int size) +{ + return GenTextureIrradiance(*shader, cubemap, size); +} + +Texture2D WGenTexturePrefilter(Shader *shader, Texture2D cubemap, int size) +{ + return GenTexturePrefilter(*shader, cubemap, size); +} + +Texture2D WGenTextureBRDF(Shader *shader, int size) +{ + return GenTextureBRDF(*shader, size); +} + +void WBeginShaderMode(Shader *shader) +{ + BeginShaderMode(*shader); +} + +void WSetVrConfiguration(VrDeviceInfo info, Shader *distortion) +{ + SetVrConfiguration(info, *distortion); +} + +float WVector2Length(Vector2 *v) +{ + return Vector2Length(*v); +} + +float WVector2DotProduct(Vector2 *v1, Vector2 *v2) +{ + return Vector2DotProduct(*v1, *v2); +} + +float WVector2Distance(Vector2 *v1, Vector2 *v2) +{ + return Vector2Distance(*v1, *v2); +} + +float WVector2Angle(Vector2 *v1, Vector2 *v2) +{ + return Vector2Angle(*v1, *v2); +} + +float WVector3Length(Vector3 *v) +{ + return Vector3Length(*v); +} + +float WVector3DotProduct(Vector3 *v1, Vector3 *v2) +{ + return Vector3DotProduct(*v1, *v2); +} + +float WVector3Distance(Vector3 *v1, Vector3 *v2) +{ + return Vector3Distance(*v1, *v2); +} + +void WVector3OrthoNormalize(Vector3 *v1, Vector3 *v2) +{ + Vector3OrthoNormalize(v1, v2); +} + +Matrix WMatrixRotate(Vector3 *axis, float angle) +{ + return MatrixRotate(*axis, angle); +} + +Matrix WMatrixRotateXYZ(Vector3 *ang) +{ + return MatrixRotateXYZ(*ang); +} + +Matrix WMatrixLookAt(Vector3 *eye, Vector3 *target, Vector3 *up) +{ + return MatrixLookAt(*eye, *target, *up); +} + +float WQuaternionLength(Quaternion *q) +{ + return QuaternionLength(*q); +} + +Matrix WQuaternionToMatrix(Quaternion *q) +{ + return QuaternionToMatrix(*q); +} + +void WQuaternionToAxisAngle(Quaternion *q, Vector3 *outAxis, float *outAngle) +{ + QuaternionToAxisAngle(*q, outAxis, outAngle); +} + diff --git a/lib/workaround/cfunctions b/lib/workaround/cfunctions deleted file mode 100644 index 55b11a1..0000000 --- a/lib/workaround/cfunctions +++ /dev/null @@ -1,44 +0,0 @@ -Ray GetMouseRay(Vector2 mousePosition, Camera camera); -void DrawPixel(int posX, int posY, Color color); -void DrawPixelV(Vector2 position, Color color); -void DrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color color); -void DrawLineV(Vector2 startPos, Vector2 endPos, Color color); -void DrawLineEx(Vector2 startPos, Vector2 endPos, float thick, Color color); -void DrawLineBezier(Vector2 startPos, Vector2 endPos, float thick, Color color); -void DrawLineStrip(Vector2 *points, int numPoints, Color color); -void DrawCircle(int centerX, int centerY, float radius, Color color); -void DrawCircleSector(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color); -void DrawCircleSectorLines(Vector2 center, float radius, int startAngle, int endAngle, int segments, Color color); -void DrawCircleGradient(int centerX, int centerY, float radius, Color color1, Color color2); -void DrawCircleV(Vector2 center, float radius, Color color); -void DrawCircleLines(int centerX, int centerY, float radius, Color color); -void DrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color color); -void DrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color color); -void DrawRing(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); -void DrawRingLines(Vector2 center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color color); -void DrawRectangle(int posX, int posY, int width, int height, Color color); -void DrawRectangleV(Vector2 position, Vector2 size, Color color); -void DrawRectangleRec(Rectangle rec, Color color); -void DrawRectanglePro(Rectangle rec, Vector2 origin, float rotation, Color color); -void DrawRectangleGradientV(int posX, int posY, int width, int height, Color color1, Color color2); -void DrawRectangleGradientH(int posX, int posY, int width, int height, Color color1, Color color2); -void DrawRectangleGradientEx(Rectangle rec, Color col1, Color col2, Color col3, Color col4); -void DrawRectangleLines(int posX, int posY, int width, int height, Color color); -void DrawRectangleLinesEx(Rectangle rec, int lineThick, Color color); -void DrawRectangleRounded(Rectangle rec, float roundness, int segments, Color color); -void DrawRectangleRoundedLines(Rectangle rec, float roundness, int segments, int lineThick, Color color); -void DrawTriangle(Vector2 v1, Vector2 v2, Vector2 v3, Color color); -void DrawTriangleLines(Vector2 v1, Vector2 v2, Vector2 v3, Color color); -void DrawTriangleFan(Vector2 *points, int numPoints, Color color); -void DrawTriangleStrip(Vector2 *points, int pointsCount, Color color); -void DrawPoly(Vector2 center, int sides, float radius, float rotation, Color color); -void DrawPolyLines(Vector2 center, int sides, float radius, float rotation, Color color); -bool CheckCollisionRecs(Rectangle rec1, Rectangle rec2); -bool CheckCollisionCircles(Vector2 center1, float radius1, Vector2 center2, float radius2); -bool CheckCollisionCircleRec(Vector2 center, float radius, Rectangle rec); -Rectangle GetCollisionRec(Rectangle rec1, Rectangle rec2); -bool CheckCollisionPointRec(Vector2 point, Rectangle rec); -bool CheckCollisionPointCircle(Vector2 point, Vector2 center, float radius); -bool CheckCollisionPointTriangle(Vector2 point, Vector2 p1, Vector2 p2, Vector2 p3); -void DrawSphere(Vector3 centerPos, float radius, Color color); -void DrawRay(Ray ray, Color color); diff --git a/lib/workaround/generate_c_functions.py b/lib/workaround/generate_c_functions.py deleted file mode 100644 index 2f0b5ba..0000000 --- a/lib/workaround/generate_c_functions.py +++ /dev/null @@ -1,138 +0,0 @@ -import re - -""" -Automatic utility for generating workaround functions for both C and Zig -to fix zig's issue with C ABI struct parameter. Put all functions that have -a parameter with one of the types listed in small_structs into cfunctions. -If one of those functions has a returns type listed in small_structs it -will be automatically ignored. Make sure raylib-zig.zig doesn't already -contain a function with the given names before copying the workaround in -""" - -raymath = open("cfunctions") - - -# Some c types have a different size on different systems -# and zig knows that so we tell it to get the system specific size for us -def c_to_zig_type(t: str) -> str: - if t == "float": - t = "f32" - if t == "int": - t = "c_int" - if t == "unsigned int": - t = "c_uint" - if t == "long": - t = "c_long" - if t == "void": - t = "c_void" - return t - - -def fix_pointer(name: str, type: str): - if name.startswith("*"): - name = name[1:] - type = "[*c]const " + type - return name, type - - -small_structs = ["Vector2", "Vector3", "Vector4", "Quaternion", "Color", "Rectangle", "Shader"] -zig_functions = [] -c_functions = [] -zig_heads = [] - -for line in raymath.readlines(): - # each (.*) is some variable value - result = re.search("(.*) (.*)start_arg(.*)end_arg", line.replace("(", "start_arg").replace(")", "end_arg")) - - # get whats in the (.*)'s - return_type = result.group(1) - func_name = result.group(2) - arguments = result.group(3) - - if return_type in small_structs: - continue - - zig_arguments_w = [] # arguments for the workaround function head on the zig side - zig_arguments = [] # arguments that are passed to the copied raylib function - zig_pass = [] # arguments that are passed to the workaround function on the zig side - c_arguments = [] # arguments for the workaround function head on the c side - c_pass = [] # arguments that are passed to the actual raylib function - - for arg in arguments.split(", "): - if arg == "void": break - arg_type = " ".join(arg.split(" ")[0:-1]).replace("const ", "") # everything but the last element (for stuff like "const Vector3"), but discarding const - arg_name = arg.split(" ")[-1] # last element should be the name - depoint = False # set to true if we need to dereference a pointer to a small struct in the c workaround - if arg_type in small_structs: - if not arg_name.startswith("*"): - depoint = True - - if depoint: - arg_name = "*" + arg_name # dereference the arguments - - c_arguments.append(arg_type + " " + arg_name) - if arg_name.startswith("*") and not depoint: # That's in case of an actual array - c_pass.append(arg_name[1:]) # We don't want to dereference the array - else: - c_pass.append(arg_name) - - # zig conversions - zig_type = c_to_zig_type(arg_type) - if depoint and arg_name.startswith("*"): # These are the arguments without pointers - zig_name = arg_name[1:] - zig_pass_name = "&" + zig_name - elif arg_name.startswith("*") and not depoint: # That's in case of an actual array - zig_name = arg_name[1:] - zig_type = "[]const " + arg_type - zig_pass_name = "&" + arg_name[1:] + "[0]" - else: # Normal argument i.e. float, int, etc. - zig_name = arg_name - zig_pass_name = zig_name - zig_arguments.append(zig_name + ": " + zig_type) # put everything together - zig_pass.append(zig_pass_name) - - # These are the arguments for the extern workaround functions with pointers - arg_type = c_to_zig_type(arg_type) - arg_name, arg_type = fix_pointer(arg_name, arg_type) - zig_arguments_w.append(arg_name + ": " + arg_type) # put everything together - - # Workaround function head in zig - zig_arguments_w = ", ".join(zig_arguments_w) - zig_ret_type = c_to_zig_type(return_type) - zig_func_name, zig_ret_type = fix_pointer(func_name, zig_ret_type) - zig_heads.append("pub extern fn W" + func_name + "(" + zig_arguments_w + ") " + return_type + ";") - - # Create the function to call the workaround - zig_arguments = ", ".join(zig_arguments) - zig_pass = ", ".join(zig_pass) - function = "pub fn " + func_name + "(" + zig_arguments + ") " + return_type + "\n" - function += "{\n" - if return_type != "void": - function += " return W" + func_name + "(" + zig_pass + ");\n" - else: - function += " W" + func_name + "(" + zig_pass + ");\n" - function += "}\n" - zig_functions.append(function) - - # Create workaround function - c_arguments = ", ".join(c_arguments) - c_pass = ", ".join(c_pass) - function = return_type + " W" + func_name + "(" + c_arguments + ")\n" - function += "{\n" - if return_type != "void": - function += " return " + func_name + "(" + c_pass + ");\n" - else: - function += " " + func_name + "(" + c_pass + ");\n" - function += "}\n" - c_functions.append(function) - -workaround = open("workaround.c", mode="w") -print("// raylib-zig (c) Nikolas Wipper 2020\n", file=workaround) -print("#include \n", file=workaround) - -zigworkaround = open("workaround.zig", mode="w") - -print("\n".join(c_functions), file=workaround) -print("\n".join(zig_heads), file=zigworkaround) -print("", file=zigworkaround) -print("\n".join(zig_functions), file=zigworkaround) diff --git a/lib/workaround/workaround.c b/lib/workaround/workaround.c deleted file mode 100644 index aa1de7d..0000000 --- a/lib/workaround/workaround.c +++ /dev/null @@ -1,219 +0,0 @@ -// raylib-zig (c) Nikolas Wipper 2020 - -#include - -Ray WGetMouseRay(Vector2 *mousePosition, Camera camera) -{ - return GetMouseRay(*mousePosition, camera); -} - -void WDrawPixel(int posX, int posY, Color *color) -{ - DrawPixel(posX, posY, *color); -} - -void WDrawPixelV(Vector2 *position, Color *color) -{ - DrawPixelV(*position, *color); -} - -void WDrawLine(int startPosX, int startPosY, int endPosX, int endPosY, Color *color) -{ - DrawLine(startPosX, startPosY, endPosX, endPosY, *color); -} - -void WDrawLineV(Vector2 *startPos, Vector2 *endPos, Color *color) -{ - DrawLineV(*startPos, *endPos, *color); -} - -void WDrawLineEx(Vector2 *startPos, Vector2 *endPos, float thick, Color *color) -{ - DrawLineEx(*startPos, *endPos, thick, *color); -} - -void WDrawLineBezier(Vector2 *startPos, Vector2 *endPos, float thick, Color *color) -{ - DrawLineBezier(*startPos, *endPos, thick, *color); -} - -void WDrawLineStrip(Vector2 *points, int numPoints, Color *color) -{ - DrawLineStrip(points, numPoints, *color); -} - -void WDrawCircle(int centerX, int centerY, float radius, Color *color) -{ - DrawCircle(centerX, centerY, radius, *color); -} - -void WDrawCircleSector(Vector2 *center, float radius, int startAngle, int endAngle, int segments, Color *color) -{ - DrawCircleSector(*center, radius, startAngle, endAngle, segments, *color); -} - -void WDrawCircleSectorLines(Vector2 *center, float radius, int startAngle, int endAngle, int segments, Color *color) -{ - DrawCircleSectorLines(*center, radius, startAngle, endAngle, segments, *color); -} - -void WDrawCircleGradient(int centerX, int centerY, float radius, Color *color1, Color *color2) -{ - DrawCircleGradient(centerX, centerY, radius, *color1, *color2); -} - -void WDrawCircleV(Vector2 *center, float radius, Color *color) -{ - DrawCircleV(*center, radius, *color); -} - -void WDrawCircleLines(int centerX, int centerY, float radius, Color *color) -{ - DrawCircleLines(centerX, centerY, radius, *color); -} - -void WDrawEllipse(int centerX, int centerY, float radiusH, float radiusV, Color *color) -{ - DrawEllipse(centerX, centerY, radiusH, radiusV, *color); -} - -void WDrawEllipseLines(int centerX, int centerY, float radiusH, float radiusV, Color *color) -{ - DrawEllipseLines(centerX, centerY, radiusH, radiusV, *color); -} - -void WDrawRing(Vector2 *center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color *color) -{ - DrawRing(*center, innerRadius, outerRadius, startAngle, endAngle, segments, *color); -} - -void WDrawRingLines(Vector2 *center, float innerRadius, float outerRadius, int startAngle, int endAngle, int segments, Color *color) -{ - DrawRingLines(*center, innerRadius, outerRadius, startAngle, endAngle, segments, *color); -} - -void WDrawRectangle(int posX, int posY, int width, int height, Color *color) -{ - DrawRectangle(posX, posY, width, height, *color); -} - -void WDrawRectangleV(Vector2 *position, Vector2 *size, Color *color) -{ - DrawRectangleV(*position, *size, *color); -} - -void WDrawRectangleRec(Rectangle *rec, Color *color) -{ - DrawRectangleRec(*rec, *color); -} - -void WDrawRectanglePro(Rectangle *rec, Vector2 *origin, float rotation, Color *color) -{ - DrawRectanglePro(*rec, *origin, rotation, *color); -} - -void WDrawRectangleGradientV(int posX, int posY, int width, int height, Color *color1, Color *color2) -{ - DrawRectangleGradientV(posX, posY, width, height, *color1, *color2); -} - -void WDrawRectangleGradientH(int posX, int posY, int width, int height, Color *color1, Color *color2) -{ - DrawRectangleGradientH(posX, posY, width, height, *color1, *color2); -} - -void WDrawRectangleGradientEx(Rectangle *rec, Color *col1, Color *col2, Color *col3, Color *col4) -{ - DrawRectangleGradientEx(*rec, *col1, *col2, *col3, *col4); -} - -void WDrawRectangleLines(int posX, int posY, int width, int height, Color *color) -{ - DrawRectangleLines(posX, posY, width, height, *color); -} - -void WDrawRectangleLinesEx(Rectangle *rec, int lineThick, Color *color) -{ - DrawRectangleLinesEx(*rec, lineThick, *color); -} - -void WDrawRectangleRounded(Rectangle *rec, float roundness, int segments, Color *color) -{ - DrawRectangleRounded(*rec, roundness, segments, *color); -} - -void WDrawRectangleRoundedLines(Rectangle *rec, float roundness, int segments, int lineThick, Color *color) -{ - DrawRectangleRoundedLines(*rec, roundness, segments, lineThick, *color); -} - -void WDrawTriangle(Vector2 *v1, Vector2 *v2, Vector2 *v3, Color *color) -{ - DrawTriangle(*v1, *v2, *v3, *color); -} - -void WDrawTriangleLines(Vector2 *v1, Vector2 *v2, Vector2 *v3, Color *color) -{ - DrawTriangleLines(*v1, *v2, *v3, *color); -} - -void WDrawTriangleFan(Vector2 *points, int numPoints, Color *color) -{ - DrawTriangleFan(points, numPoints, *color); -} - -void WDrawTriangleStrip(Vector2 *points, int pointsCount, Color *color) -{ - DrawTriangleStrip(points, pointsCount, *color); -} - -void WDrawPoly(Vector2 *center, int sides, float radius, float rotation, Color *color) -{ - DrawPoly(*center, sides, radius, rotation, *color); -} - -void WDrawPolyLines(Vector2 *center, int sides, float radius, float rotation, Color *color) -{ - DrawPolyLines(*center, sides, radius, rotation, *color); -} - -bool WCheckCollisionRecs(Rectangle *rec1, Rectangle *rec2) -{ - return CheckCollisionRecs(*rec1, *rec2); -} - -bool WCheckCollisionCircles(Vector2 *center1, float radius1, Vector2 *center2, float radius2) -{ - return CheckCollisionCircles(*center1, radius1, *center2, radius2); -} - -bool WCheckCollisionCircleRec(Vector2 *center, float radius, Rectangle *rec) -{ - return CheckCollisionCircleRec(*center, radius, *rec); -} - -bool WCheckCollisionPointRec(Vector2 *point, Rectangle *rec) -{ - return CheckCollisionPointRec(*point, *rec); -} - -bool WCheckCollisionPointCircle(Vector2 *point, Vector2 *center, float radius) -{ - return CheckCollisionPointCircle(*point, *center, radius); -} - -bool WCheckCollisionPointTriangle(Vector2 *point, Vector2 *p1, Vector2 *p2, Vector2 *p3) -{ - return CheckCollisionPointTriangle(*point, *p1, *p2, *p3); -} - -void WDrawSphere(Vector3 *centerPos, float radius, Color *color) -{ - DrawSphere(*centerPos, radius, *color); -} - -void WDrawRay(Ray ray, Color *color) -{ - DrawRay(ray, *color); -} - diff --git a/lib/workaround/workaround.zig b/lib/workaround/workaround.zig deleted file mode 100644 index 9551167..0000000 --- a/lib/workaround/workaround.zig +++ /dev/null @@ -1,259 +0,0 @@ -pub extern fn WGetMouseRay(mousePosition: [*c]const Vector2, camera: Camera) Ray; -pub extern fn WDrawPixel(posX: c_int, posY: c_int, color: [*c]const Color) void; -pub extern fn WDrawPixelV(position: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: [*c]const Color) void; -pub extern fn WDrawLineV(startPos: [*c]const Vector2, endPos: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawLineEx(startPos: [*c]const Vector2, endPos: [*c]const Vector2, thick: f32, color: [*c]const Color) void; -pub extern fn WDrawLineBezier(startPos: [*c]const Vector2, endPos: [*c]const Vector2, thick: f32, color: [*c]const Color) void; -pub extern fn WDrawLineStrip(points: [*c]const Vector2, numPoints: c_int, color: [*c]const Color) void; -pub extern fn WDrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawCircleSector(center: [*c]const Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawCircleSectorLines(center: [*c]const Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: [*c]const Color, color2: [*c]const Color) void; -pub extern fn WDrawCircleV(center: [*c]const Vector2, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: [*c]const Color) void; -pub extern fn WDrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: [*c]const Color) void; -pub extern fn WDrawRing(center: [*c]const Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawRingLines(center: [*c]const Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleV(position: [*c]const Vector2, size: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawRectangleRec(rec: [*c]const Rectangle, color: [*c]const Color) void; -pub extern fn WDrawRectanglePro(rec: [*c]const Rectangle, origin: [*c]const Vector2, rotation: f32, color: [*c]const Color) void; -pub extern fn WDrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: [*c]const Color, color2: [*c]const Color) void; -pub extern fn WDrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: [*c]const Color, color2: [*c]const Color) void; -pub extern fn WDrawRectangleGradientEx(rec: [*c]const Rectangle, col1: [*c]const Color, col2: [*c]const Color, col3: [*c]const Color, col4: [*c]const Color) void; -pub extern fn WDrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleLinesEx(rec: [*c]const Rectangle, lineThick: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleRounded(rec: [*c]const Rectangle, roundness: f32, segments: c_int, color: [*c]const Color) void; -pub extern fn WDrawRectangleRoundedLines(rec: [*c]const Rectangle, roundness: f32, segments: c_int, lineThick: c_int, color: [*c]const Color) void; -pub extern fn WDrawTriangle(v1: [*c]const Vector2, v2: [*c]const Vector2, v3: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawTriangleLines(v1: [*c]const Vector2, v2: [*c]const Vector2, v3: [*c]const Vector2, color: [*c]const Color) void; -pub extern fn WDrawTriangleFan(points: [*c]const Vector2, numPoints: c_int, color: [*c]const Color) void; -pub extern fn WDrawTriangleStrip(points: [*c]const Vector2, pointsCount: c_int, color: [*c]const Color) void; -pub extern fn WDrawPoly(center: [*c]const Vector2, sides: c_int, radius: f32, rotation: f32, color: [*c]const Color) void; -pub extern fn WDrawPolyLines(center: [*c]const Vector2, sides: c_int, radius: f32, rotation: f32, color: [*c]const Color) void; -pub extern fn WCheckCollisionRecs(rec1: [*c]const Rectangle, rec2: [*c]const Rectangle) bool; -pub extern fn WCheckCollisionCircles(center1: [*c]const Vector2, radius1: f32, center2: [*c]const Vector2, radius2: f32) bool; -pub extern fn WCheckCollisionCircleRec(center: [*c]const Vector2, radius: f32, rec: [*c]const Rectangle) bool; -pub extern fn WCheckCollisionPointRec(point: [*c]const Vector2, rec: [*c]const Rectangle) bool; -pub extern fn WCheckCollisionPointCircle(point: [*c]const Vector2, center: [*c]const Vector2, radius: f32) bool; -pub extern fn WCheckCollisionPointTriangle(point: [*c]const Vector2, p1: [*c]const Vector2, p2: [*c]const Vector2, p3: [*c]const Vector2) bool; -pub extern fn WDrawSphere(centerPos: [*c]const Vector3, radius: f32, color: [*c]const Color) void; -pub extern fn WDrawRay(ray: Ray, color: [*c]const Color) void; - -pub fn GetMouseRay(mousePosition: Vector2, camera: Camera) Ray -{ - return WGetMouseRay(&mousePosition, camera); -} - -pub fn DrawPixel(posX: c_int, posY: c_int, color: Color) void -{ - WDrawPixel(posX, posY, &color); -} - -pub fn DrawPixelV(position: Vector2, color: Color) void -{ - WDrawPixelV(&position, &color); -} - -pub fn DrawLine(startPosX: c_int, startPosY: c_int, endPosX: c_int, endPosY: c_int, color: Color) void -{ - WDrawLine(startPosX, startPosY, endPosX, endPosY, &color); -} - -pub fn DrawLineV(startPos: Vector2, endPos: Vector2, color: Color) void -{ - WDrawLineV(&startPos, &endPos, &color); -} - -pub fn DrawLineEx(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void -{ - WDrawLineEx(&startPos, &endPos, thick, &color); -} - -pub fn DrawLineBezier(startPos: Vector2, endPos: Vector2, thick: f32, color: Color) void -{ - WDrawLineBezier(&startPos, &endPos, thick, &color); -} - -pub fn DrawLineStrip(points: []const Vector2, numPoints: c_int, color: Color) void -{ - WDrawLineStrip(&points[0], numPoints, &color); -} - -pub fn DrawCircle(centerX: c_int, centerY: c_int, radius: f32, color: Color) void -{ - WDrawCircle(centerX, centerY, radius, &color); -} - -pub fn DrawCircleSector(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawCircleSector(¢er, radius, startAngle, endAngle, segments, &color); -} - -pub fn DrawCircleSectorLines(center: Vector2, radius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawCircleSectorLines(¢er, radius, startAngle, endAngle, segments, &color); -} - -pub fn DrawCircleGradient(centerX: c_int, centerY: c_int, radius: f32, color1: Color, color2: Color) void -{ - WDrawCircleGradient(centerX, centerY, radius, &color1, &color2); -} - -pub fn DrawCircleV(center: Vector2, radius: f32, color: Color) void -{ - WDrawCircleV(¢er, radius, &color); -} - -pub fn DrawCircleLines(centerX: c_int, centerY: c_int, radius: f32, color: Color) void -{ - WDrawCircleLines(centerX, centerY, radius, &color); -} - -pub fn DrawEllipse(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void -{ - WDrawEllipse(centerX, centerY, radiusH, radiusV, &color); -} - -pub fn DrawEllipseLines(centerX: c_int, centerY: c_int, radiusH: f32, radiusV: f32, color: Color) void -{ - WDrawEllipseLines(centerX, centerY, radiusH, radiusV, &color); -} - -pub fn DrawRing(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawRing(¢er, innerRadius, outerRadius, startAngle, endAngle, segments, &color); -} - -pub fn DrawRingLines(center: Vector2, innerRadius: f32, outerRadius: f32, startAngle: c_int, endAngle: c_int, segments: c_int, color: Color) void -{ - WDrawRingLines(¢er, innerRadius, outerRadius, startAngle, endAngle, segments, &color); -} - -pub fn DrawRectangle(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void -{ - WDrawRectangle(posX, posY, width, height, &color); -} - -pub fn DrawRectangleV(position: Vector2, size: Vector2, color: Color) void -{ - WDrawRectangleV(&position, &size, &color); -} - -pub fn DrawRectangleRec(rec: Rectangle, color: Color) void -{ - WDrawRectangleRec(&rec, &color); -} - -pub fn DrawRectanglePro(rec: Rectangle, origin: Vector2, rotation: f32, color: Color) void -{ - WDrawRectanglePro(&rec, &origin, rotation, &color); -} - -pub fn DrawRectangleGradientV(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void -{ - WDrawRectangleGradientV(posX, posY, width, height, &color1, &color2); -} - -pub fn DrawRectangleGradientH(posX: c_int, posY: c_int, width: c_int, height: c_int, color1: Color, color2: Color) void -{ - WDrawRectangleGradientH(posX, posY, width, height, &color1, &color2); -} - -pub fn DrawRectangleGradientEx(rec: Rectangle, col1: Color, col2: Color, col3: Color, col4: Color) void -{ - WDrawRectangleGradientEx(&rec, &col1, &col2, &col3, &col4); -} - -pub fn DrawRectangleLines(posX: c_int, posY: c_int, width: c_int, height: c_int, color: Color) void -{ - WDrawRectangleLines(posX, posY, width, height, &color); -} - -pub fn DrawRectangleLinesEx(rec: Rectangle, lineThick: c_int, color: Color) void -{ - WDrawRectangleLinesEx(&rec, lineThick, &color); -} - -pub fn DrawRectangleRounded(rec: Rectangle, roundness: f32, segments: c_int, color: Color) void -{ - WDrawRectangleRounded(&rec, roundness, segments, &color); -} - -pub fn DrawRectangleRoundedLines(rec: Rectangle, roundness: f32, segments: c_int, lineThick: c_int, color: Color) void -{ - WDrawRectangleRoundedLines(&rec, roundness, segments, lineThick, &color); -} - -pub fn DrawTriangle(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void -{ - WDrawTriangle(&v1, &v2, &v3, &color); -} - -pub fn DrawTriangleLines(v1: Vector2, v2: Vector2, v3: Vector2, color: Color) void -{ - WDrawTriangleLines(&v1, &v2, &v3, &color); -} - -pub fn DrawTriangleFan(points: []const Vector2, numPoints: c_int, color: Color) void -{ - WDrawTriangleFan(&points[0], numPoints, &color); -} - -pub fn DrawTriangleStrip(points: []const Vector2, pointsCount: c_int, color: Color) void -{ - WDrawTriangleStrip(&points[0], pointsCount, &color); -} - -pub fn DrawPoly(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void -{ - WDrawPoly(¢er, sides, radius, rotation, &color); -} - -pub fn DrawPolyLines(center: Vector2, sides: c_int, radius: f32, rotation: f32, color: Color) void -{ - WDrawPolyLines(¢er, sides, radius, rotation, &color); -} - -pub fn CheckCollisionRecs(rec1: Rectangle, rec2: Rectangle) bool -{ - return WCheckCollisionRecs(&rec1, &rec2); -} - -pub fn CheckCollisionCircles(center1: Vector2, radius1: f32, center2: Vector2, radius2: f32) bool -{ - return WCheckCollisionCircles(¢er1, radius1, ¢er2, radius2); -} - -pub fn CheckCollisionCircleRec(center: Vector2, radius: f32, rec: Rectangle) bool -{ - return WCheckCollisionCircleRec(¢er, radius, &rec); -} - -pub fn CheckCollisionPointRec(point: Vector2, rec: Rectangle) bool -{ - return WCheckCollisionPointRec(&point, &rec); -} - -pub fn CheckCollisionPointCircle(point: Vector2, center: Vector2, radius: f32) bool -{ - return WCheckCollisionPointCircle(&point, ¢er, radius); -} - -pub fn CheckCollisionPointTriangle(point: Vector2, p1: Vector2, p2: Vector2, p3: Vector2) bool -{ - return WCheckCollisionPointTriangle(&point, &p1, &p2, &p3); -} - -pub fn DrawSphere(centerPos: Vector3, radius: f32, color: Color) void -{ - WDrawSphere(¢erPos, radius, &color); -} - -pub fn DrawRay(ray: Ray, color: Color) void -{ - WDrawRay(ray, &color); -} - diff --git a/projectSetup.sh b/projectSetup.sh index 5c47142..59537e9 100755 --- a/projectSetup.sh +++ b/projectSetup.sh @@ -14,19 +14,18 @@ pub fn build(b: *Builder) void { const exe = b.addExecutable("'"$PROJECT_NAME"'", "src/main.zig"); exe.setBuildMode(mode); exe.linkSystemLibrary("raylib"); + exe.addCSourceFile("raylib-zig/workaround.c", &[_][]const u8{}); exe.addPackagePath("raylib", "raylib-zig/raylib-zig.zig"); - exe.install(); + exe.addPackagePath("raylib-math", "lib/raylib-zig-math.zig"); - const run_cmd = exe.run(); - run_cmd.step.dependOn(b.getInstallStep()); - - const run_step = b.step("run", "Run the app"); - run_step.dependOn(&run_cmd.step); + const runExe = exe.run(); + const exeStep = b.step("run", "Runs the app"); + exeStep.dependOn(&runExe.step); } ' >> build.zig mkdir src mkdir raylib-zig -cp ../lib/* raylib-zig +cp ../lib/** raylib-zig cp ../examples/core/basic_window.zig src mv src/basic_window.zig src/main.zig \ No newline at end of file diff --git a/raylib-headers/math-funcs.py b/raylib-headers/math-funcs.py deleted file mode 100644 index ff08854..0000000 --- a/raylib-headers/math-funcs.py +++ /dev/null @@ -1,61 +0,0 @@ -import re - -""" -Automatic utility for extracting function definitions from raymath.h -and translating them to zig. This can technically be used for raylib.h -as well when setting prefix = "RLAPI " and possibly also for all other -raylib headers -""" - -raymath = open("raymath.h") - -prefix = "RMDEF " - - -# Some c types have a different size on different systems -# and zig knows that so we tell it to get the system specific size for us -def c_to_zig_type(t: str) -> str: - if t == "float": - t = "f32" - if t == "int": - t = "c_int" - if t == "unsigned int": - t = "c_uint" - if t == "long": - t = "c_long" - if t == "void": - t = "c_void" - return t - - -def fix_pointer(name: str, type: str): - if name.startswith("*"): - name = name[1:] - type = "[*c]" + type - return name, type - - -for line in raymath.readlines(): - if line.startswith(prefix): - # each (.*) is some variable value - result = re.search(prefix + "(.*) (.*)start_arg(.*)end_arg", line.replace("(", "start_arg").replace(")", "end_arg")) - - # get whats in the (.*)'s - return_type = result.group(1) - func_name = result.group(2) - arguments = result.group(3) - - func_name, return_type = fix_pointer(func_name, return_type) - - return_type = c_to_zig_type(return_type) - zig_arguments = [] - for arg in arguments.split(", "): - if arg == "void": break - arg_type = " ".join(arg.split(" ")[0:-1]) # everything but the last element (for stuff like "const Vector3") - arg_type = arg_type.replace("const ", "") # zig doesn't like const in function arguments that aren't pointer and really we don't need const - arg_type = c_to_zig_type(arg_type) - arg_name = arg.split(" ")[-1] # last element should be the name - arg_name, arg_type = fix_pointer(arg_name, arg_type) - zig_arguments.append(arg_name + ": " + arg_type) # put everything together - zig_arguments = ", ".join(zig_arguments) - print("pub extern fn " + func_name + "(" + zig_arguments + ") " + return_type + ";") diff --git a/tests/draw_sphere.zig b/tests/draw_sphere.zig index 46a81e6..2f9b8f0 100644 --- a/tests/draw_sphere.zig +++ b/tests/draw_sphere.zig @@ -14,7 +14,7 @@ pub fn main() anyerror!void const screenWidth = 800; const screenHeight = 450; - InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window"); + InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - draw sphere"); var camera = Camera { .position = Vector3 { .x = 0.0, .y = 0.0, .z = 0.0 }, // Camera position