mirror of
https://github.com/Not-Nik/raylib-zig.git
synced 2025-09-09 12:07:27 +00:00
Update to 4.5-dev
This commit is contained in:
parent
63ea851d66
commit
1e06706bff
2
.gitignore
vendored
2
.gitignore
vendored
@ -2,7 +2,5 @@ zig-cache/
|
||||
.idea/
|
||||
Project/*
|
||||
|
||||
raylib.h
|
||||
raymath.h
|
||||
libraylib.a
|
||||
**/.DS_Store
|
||||
|
15
README.md
15
README.md
@ -4,9 +4,9 @@
|
||||
|
||||
Manually tweaked, auto generated [raylib](https://github.com/raysan5/raylib) bindings for zig.
|
||||
|
||||
Bindings tested on raylib version 4.2.0 and Zig 0.9.1
|
||||
Bindings tested on raylib version 4.5.0-dev and Zig 0.10.1
|
||||
|
||||
Thanks to @jessrud, @mbcrocci, @franciscod, @Gertkeno, @alanoliveira, @sacredbirdman, @rcorre and @Ivan-Velickovic for their contributions to this binding.
|
||||
Thanks to @jessrud, @mbcrocci, @franciscod, @AlxHnr, @Gertkeno, @Ivan-Velickovic, @alanoliveira, @rcorre and @sacredbirdman for their contributions to this binding.
|
||||
|
||||
The binding currently only supports a subset of raylib. For more information read [here](#technical-restrictions).
|
||||
|
||||
@ -56,25 +56,22 @@ pub fn main() anyerror!void {
|
||||
|
||||
## Technical restrictions
|
||||
|
||||
Due to zig being a relatively new language it does [not have full C ABI support](https://github.com/ziglang/zig/issues/1481) at the moment. For use that mainly means we
|
||||
can't use any functions that return structs that are less than 16 bytes large.
|
||||
Due to zig being a relatively new language it does [not have full C ABI support](https://github.com/ziglang/zig/issues/1481) at the moment. For use that mainly means we can't use any functions that return structs that are less than 16 bytes large.
|
||||
|
||||
## Building the examples
|
||||
|
||||
To build all available examples simply `zig build examples`. To list available examples run `zig build --help`. If you want to run and examples, say `basic_window`
|
||||
run `zig build basic_window`
|
||||
To build all available examples simply `zig build examples`. To list available examples run `zig build --help`. If you want to run an example, say `basic_window` run `zig build basic_window`
|
||||
|
||||
## Building and using
|
||||
|
||||
+ (Optional) Install raylib
|
||||
+ Execute `projectSetup.sh project_name`, this will create a folder with the name specified
|
||||
+ Execute `project_setup.sh project_name`, this will create a folder with the name specified
|
||||
+ You can copy that folder anywhere you want and edit the source
|
||||
+ Run `zig build run` at any time to test your project
|
||||
|
||||
### When is the binding updated?
|
||||
|
||||
I plan on updating it every mayor release (2.5, 3.0, etc.). Keep in mind these are technically header files, so any implementation stuff should be updatable with some
|
||||
hacks on your side.
|
||||
I plan on updating it every mayor release (2.5, 3.0, etc.). Keep in mind these are technically header files, so any implementation stuff should be updatable with some hacks on your side.
|
||||
|
||||
### What's to be done?
|
||||
|
||||
|
@ -39,7 +39,7 @@ pub fn main() anyerror!void
|
||||
rl.DrawRectangle(screenWidth/2 - 40, @floatToInt(c_int, boxPositionY), 80, 80, rl.MAROON);
|
||||
|
||||
rl.DrawText("Use mouse wheel to move the cube up and down!", 10, 10, 20, rl.GRAY);
|
||||
rl.DrawText(rl.FormatText("Box position Y: %03i", @floatToInt(c_int, boxPositionY)), 10, 40, 20, rl.LIGHTGRAY);
|
||||
rl.DrawText(rl.TextFormat("Box position Y: %03i", @floatToInt(c_int, boxPositionY)), 10, 40, 20, rl.LIGHTGRAY);
|
||||
|
||||
rl.EndDrawing();
|
||||
//----------------------------------------------------------------------------------
|
||||
|
@ -60,7 +60,7 @@ pub fn main() anyerror!void
|
||||
{
|
||||
// Draw circle and touch index number
|
||||
rl.DrawCircleV(touchPosition, 34, rl.ORANGE);
|
||||
rl.DrawText(rl.FormatText("%d", i), @floatToInt(c_int, touchPosition.x) - 10, @floatToInt(c_int, touchPosition.y) - 70, 40, rl.BLACK);
|
||||
rl.DrawText(rl.TextFormat("%d", i), @floatToInt(c_int, touchPosition.x) - 10, @floatToInt(c_int, touchPosition.y) - 70, 40, rl.BLACK);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -144,5 +144,5 @@ def parse_header(header_name: str, output_file: str, prefix: str):
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
parse_header("raylib.h", "raylib-wa.zig", "RLAPI ")
|
||||
parse_header("raymath.h", "raylib-zig-math.zig", "RMAPI ")
|
||||
parse_header("../raylib/src/raylib.h", "raylib-wa.zig", "RLAPI ")
|
||||
parse_header("../raylib/src/raymath.h", "raylib-zig-math.zig", "RMAPI ")
|
||||
|
@ -151,8 +151,8 @@ pub extern fn TakeScreenshot(fileName: [*c]const u8) void;
|
||||
pub extern fn SetConfigFlags(flags: ConfigFlags) void;
|
||||
pub extern fn TraceLog(logLevel: c_int, text: [*c]const u8, ...) void;
|
||||
pub extern fn SetTraceLogLevel(logLevel: c_int) void;
|
||||
pub extern fn MemAlloc(size: c_int) *anyopaque;
|
||||
pub extern fn MemRealloc(ptr: *anyopaque, size: c_int) *anyopaque;
|
||||
pub extern fn MemAlloc(size: c_uint) *anyopaque;
|
||||
pub extern fn MemRealloc(ptr: *anyopaque, size: c_uint) *anyopaque;
|
||||
pub extern fn MemFree(ptr: *anyopaque) void;
|
||||
pub extern fn OpenURL(url: [*c]const u8) void;
|
||||
pub extern fn SetTraceLogCallback(callback: TraceLogCallback) void;
|
||||
@ -285,6 +285,7 @@ pub extern fn CheckCollisionCircleRec(center: Vector2, radius: f32, rec: Rectang
|
||||
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 CheckCollisionPointPoly(point: Vector2, points: [*c]Vector2, pointCount: c_int) bool;
|
||||
pub extern fn CheckCollisionLines(startPos1: Vector2, endPos1: Vector2, startPos2: Vector2, endPos2: Vector2, collisionPoint: [*c]Vector2) bool;
|
||||
pub extern fn CheckCollisionPointLine(point: Vector2, p1: Vector2, p2: Vector2, threshold: c_int) bool;
|
||||
pub extern fn GetCollisionRec(rec1: Rectangle, rec2: Rectangle) Rectangle;
|
||||
@ -303,7 +304,9 @@ pub extern fn GenImageGradientH(width: c_int, height: c_int, left: Color, right:
|
||||
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 GenImageText(width: c_int, height: c_int, text: [*c]const u8) 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;
|
||||
@ -315,6 +318,7 @@ pub extern fn ImageAlphaCrop(image: [*c]Image, threshold: f32) void;
|
||||
pub extern fn ImageAlphaClear(image: [*c]Image, color: Color, threshold: f32) void;
|
||||
pub extern fn ImageAlphaMask(image: [*c]Image, alphaMask: Image) void;
|
||||
pub extern fn ImageAlphaPremultiply(image: [*c]Image) void;
|
||||
pub extern fn ImageBlurGaussian(image: [*c]Image, blurSize: c_int) 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, fill: Color) void;
|
||||
@ -343,6 +347,8 @@ pub extern fn ImageDrawLine(dst: [*c]Image, startPosX: c_int, startPosY: c_int,
|
||||
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 ImageDrawCircleLines(dst: [*c]Image, centerX: c_int, centerY: c_int, radius: c_int, color: Color) void;
|
||||
pub extern fn ImageDrawCircleLinesV(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;
|
||||
@ -365,17 +371,17 @@ pub extern fn DrawTexture(texture: Texture2D, posX: c_int, posY: c_int, tint: Co
|
||||
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, source: Rectangle, position: Vector2, tint: Color) void;
|
||||
pub extern fn DrawTextureQuad(texture: Texture2D, tiling: Vector2, offset: Vector2, quad: Rectangle, tint: Color) void;
|
||||
pub extern fn DrawTextureTiled(texture: Texture2D, source: Rectangle, dest: Rectangle, origin: Vector2, rotation: f32, scale: f32, tint: Color) void;
|
||||
pub extern fn DrawTexturePro(texture: Texture2D, source: Rectangle, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void;
|
||||
pub extern fn DrawTextureNPatch(texture: Texture2D, nPatchInfo: NPatchInfo, dest: Rectangle, origin: Vector2, rotation: f32, tint: Color) void;
|
||||
pub extern fn DrawTexturePoly(texture: Texture2D, center: Vector2, points: [*c]Vector2, texcoords: [*c]Vector2, pointCount: c_int, tint: Color) void;
|
||||
pub extern fn Fade(color: Color, alpha: f32) Color;
|
||||
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(hue: f32, saturation: f32, value: f32) Color;
|
||||
pub extern fn ColorTint(color: Color, tint: Color) Color;
|
||||
pub extern fn ColorBrightness(color: Color, factor: f32) Color;
|
||||
pub extern fn ColorContrast(color: Color, contrast: f32) Color;
|
||||
pub extern fn ColorAlpha(color: Color, alpha: f32) Color;
|
||||
pub extern fn ColorAlphaBlend(dst: Color, src: Color, tint: Color) Color;
|
||||
pub extern fn GetColor(hexValue: c_uint) Color;
|
||||
@ -403,12 +409,15 @@ pub extern fn MeasureTextEx(font: Font, text: [*c]const u8, fontSize: f32, spaci
|
||||
pub extern fn GetGlyphIndex(font: Font, codepoint: c_int) c_int;
|
||||
pub extern fn GetGlyphInfo(font: Font, codepoint: c_int) GlyphInfo;
|
||||
pub extern fn GetGlyphAtlasRec(font: Font, codepoint: c_int) Rectangle;
|
||||
pub extern fn LoadUTF8(codepoints: [*c]const c_int, length: c_int) [*c]u8;
|
||||
pub extern fn UnloadUTF8(text: [*c]u8) void;
|
||||
pub extern fn LoadCodepoints(text: [*c]const u8, count: [*c]c_int) [*c]c_int;
|
||||
pub extern fn UnloadCodepoints(codepoints: [*c]c_int) void;
|
||||
pub extern fn GetCodepointCount(text: [*c]const u8) c_int;
|
||||
pub extern fn GetCodepoint(text: [*c]const u8, bytesProcessed: [*c]c_int) c_int;
|
||||
pub extern fn CodepointToUTF8(codepoint: c_int, byteSize: [*c]c_int) [*c]const u8;
|
||||
pub extern fn TextCodepointsToUTF8(codepoints: [*c]const c_int, length: c_int) [*c]u8;
|
||||
pub extern fn GetCodepoint(text: [*c]const u8, codepointSize: [*c]c_int) c_int;
|
||||
pub extern fn GetCodepointNext(text: [*c]const u8, codepointSize: [*c]c_int) c_int;
|
||||
pub extern fn GetCodepointPrevious(text: [*c]const u8, codepointSize: [*c]c_int) c_int;
|
||||
pub extern fn CodepointToUTF8(codepoint: c_int, utf8Size: [*c]c_int) [*c]const u8;
|
||||
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;
|
||||
@ -433,8 +442,6 @@ pub extern fn DrawCube(position: Vector3, width: f32, height: f32, length: f32,
|
||||
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 DrawCubeTextureRec(texture: Texture2D, source: Rectangle, 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;
|
||||
@ -442,6 +449,8 @@ pub extern fn DrawCylinder(position: Vector3, radiusTop: f32, radiusBottom: f32,
|
||||
pub extern fn DrawCylinderEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: 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 DrawCylinderWiresEx(startPos: Vector3, endPos: Vector3, startRadius: f32, endRadius: f32, sides: c_int, color: Color) void;
|
||||
pub extern fn DrawCapsule(startPos: Vector3, endPos: Vector3, radius: f32, slices: c_int, rings: c_int, color: Color) void;
|
||||
pub extern fn DrawCapsuleWires(startPos: Vector3, endPos: Vector3, radius: f32, slices: c_int, rings: 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;
|
||||
|
@ -167,7 +167,6 @@ pub const RenderTexture = extern struct {
|
||||
id: c_uint,
|
||||
texture: Texture,
|
||||
depth: Texture,
|
||||
depthTexture: bool,
|
||||
|
||||
pub fn Begin(self: RenderTexture2D) void {
|
||||
rl.BeginTextureMode(self);
|
||||
@ -188,7 +187,7 @@ pub const NPatchInfo = extern struct {
|
||||
layout: c_int,
|
||||
};
|
||||
|
||||
pub const CharInfo = extern struct {
|
||||
pub const GlyphInfo = extern struct {
|
||||
value: c_int,
|
||||
offsetX: c_int,
|
||||
offsetY: c_int,
|
||||
@ -198,11 +197,11 @@ pub const CharInfo = extern struct {
|
||||
|
||||
pub const Font = extern struct {
|
||||
baseSize: c_int,
|
||||
charsCount: c_int,
|
||||
charsPadding: c_int,
|
||||
glyphCount: c_int,
|
||||
glyphPadding: c_int,
|
||||
texture: Texture2D,
|
||||
recs: [*c]Rectangle,
|
||||
chars: [*c]CharInfo,
|
||||
glyphs: [*c]GlyphInfo,
|
||||
};
|
||||
|
||||
pub const Camera3D = extern struct {
|
||||
@ -356,12 +355,12 @@ pub const AudioStream = extern struct {
|
||||
|
||||
pub const Sound = extern struct {
|
||||
stream: AudioStream,
|
||||
sampleCount: c_uint,
|
||||
frameCount: c_uint,
|
||||
};
|
||||
|
||||
pub const Music = extern struct {
|
||||
stream: AudioStream,
|
||||
sampleCount: c_uint,
|
||||
frameCount: c_uint,
|
||||
looping: bool,
|
||||
ctxType: c_int,
|
||||
ctxData: ?*anyopaque,
|
||||
@ -648,6 +647,13 @@ pub const ShaderUniformDataType = enum(c_int) {
|
||||
SHADER_UNIFORM_SAMPLER2D = 8,
|
||||
};
|
||||
|
||||
pub const ShaderAttribute = enum(c_int) {
|
||||
SHADER_ATTRIB_FLOAT = 0,
|
||||
SHADER_ATTRIB_VEC2 = 1,
|
||||
SHADER_ATTRIB_VEC3 = 2,
|
||||
SHADER_ATTRIB_VEC4 = 3,
|
||||
};
|
||||
|
||||
pub const PixelFormat = enum(c_int) {
|
||||
PIXELFORMAT_UNCOMPRESSED_GRAYSCALE = 1,
|
||||
PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA = 2,
|
||||
@ -710,7 +716,8 @@ pub const BlendMode = enum(c_int) {
|
||||
BLEND_ADD_COLORS = 3,
|
||||
BLEND_SUBTRACT_COLORS = 4,
|
||||
BLEND_ALPHA_PREMULTIPLY = 5,
|
||||
BLEND_CUSTOM = 5,
|
||||
BLEND_CUSTOM = 6,
|
||||
BLEND_CUSTOM_SEPARATE = 7,
|
||||
};
|
||||
|
||||
pub const Gestures = enum(c_int) {
|
||||
@ -752,23 +759,15 @@ pub const SaveFileDataCallback = ?fn ([*c]const u8, ?*anyopaque, c_uint) callcon
|
||||
pub const LoadFileTextCallback = ?fn ([*c]const u8) callconv(.C) [*c]u8;
|
||||
pub const SaveFileTextCallback = ?fn ([*c]const u8, [*c]u8) callconv(.C) bool;
|
||||
|
||||
pub const RAYLIB_VERSION_MAJOR = @as(c_int, 4);
|
||||
pub const RAYLIB_VERSION_MINOR = @as(c_int, 5);
|
||||
pub const RAYLIB_VERSION_PATCH = @as(c_int, 0);
|
||||
pub const RAYLIB_VERSION = "4.5-dev";
|
||||
|
||||
pub const MAX_TOUCH_POINTS = 10;
|
||||
pub const MAX_MATERIAL_MAPS = 12;
|
||||
pub const MAX_SHADER_LOCATIONS = 32;
|
||||
|
||||
pub const PI = 3.141593;
|
||||
|
||||
pub const SpriteFont = rl.Font;
|
||||
pub const SubText = rl.TextSubtext;
|
||||
pub const FormatText = rl.TextFormat;
|
||||
pub const LoadText = rl.LoadFileText;
|
||||
pub const GetExtension = rl.GetFileExtension;
|
||||
pub const GetImageData = rl.LoadImageColors;
|
||||
pub const FILTER_POINT = TextureFilter.TEXTURE_FILTER_POINT;
|
||||
pub const FILTER_BILINEAR = TextureFilter.TEXTURE_FILTER_BILINEAR;
|
||||
pub const MAP_DIFFUSE = MATERIAL_MAP_DIFFUSE;
|
||||
pub const PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 = PixelFormat.PIXELFORMAT_UNCOMPRESSED_R8G8B8A8;
|
||||
|
||||
pub const MATERIAL_MAP_DIFFUSE = MaterialMapIndex.MATERIAL_MAP_ALBEDO;
|
||||
pub const MATERIAL_MAP_SPECULAR = MaterialMapIndex.MATERIAL_MAP_METALNESS;
|
||||
pub const SHADER_LOC_MAP_DIFFUSE = ShaderLocationIndex.SHADER_LOC_MAP_ALBEDO;
|
||||
|
2
raylib
2
raylib
@ -1 +1 @@
|
||||
Subproject commit bf2ad9df5fdcaa385b2a7f66fd85632eeebbadaa
|
||||
Subproject commit 542ef8904a2ce9d87ab53289026da7a715907b87
|
Loading…
x
Reference in New Issue
Block a user