Merge pull request #15 from franciscod/devel

updates for zig 0.9.0
This commit is contained in:
Nikolas 2022-01-08 20:59:18 +01:00 committed by GitHub
commit 3c94160c6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 247 additions and 181 deletions

View File

@ -25,41 +25,41 @@ pub fn build(b: *Builder) void {
.path = "examples/core/basic_window.zig",
.desc = "Creates a basic window with text",
},
.{
.name = "input_keys",
.path = "examples/core/input_keys.zig",
.desc = "Simple keyboard input",
},
.{
.name = "input_mouse",
.path = "examples/core/input_mouse.zig",
.desc = "Simple mouse input",
},
.{
.name = "input_mouse_wheel",
.path = "examples/core/input_mouse_wheel.zig",
.desc = "Mouse wheel input",
},
.{
.name = "input_multitouch",
.path = "examples/core/input_multitouch.zig",
.desc = "Multitouch input",
},
.{
.name = "2d_camera",
.path = "examples/core/2d_camera.zig",
.desc = "Shows the functionality of a 2D camera",
},
.{
.name = "models_loading",
.path = "examples/models/models_loading.zig",
.desc = "Loads a model and renders it",
},
.{
.name = "shaders_basic_lighting",
.path = "examples/shaders/shaders_basic_lighting.zig",
.desc = "Loads a model and renders it",
},
// .{
// .name = "input_keys",
// .path = "examples/core/input_keys.zig",
// .desc = "Simple keyboard input",
// },
// .{
// .name = "input_mouse",
// .path = "examples/core/input_mouse.zig",
// .desc = "Simple mouse input",
// },
// .{
// .name = "input_mouse_wheel",
// .path = "examples/core/input_mouse_wheel.zig",
// .desc = "Mouse wheel input",
// },
// .{
// .name = "input_multitouch",
// .path = "examples/core/input_multitouch.zig",
// .desc = "Multitouch input",
// },
// .{
// .name = "2d_camera",
// .path = "examples/core/2d_camera.zig",
// .desc = "Shows the functionality of a 2D camera",
// },
// .{
// .name = "models_loading",
// .path = "examples/models/models_loading.zig",
// .desc = "Loads a model and renders it",
// },
// .{
// .name = "shaders_basic_lighting",
// .path = "examples/shaders/shaders_basic_lighting.zig",
// .desc = "Loads a model and renders it",
// },
};
const examples_step = b.step("examples", "Builds all the examples");

View File

@ -5,22 +5,21 @@
// Date: 2020-02-15
//
usingnamespace @import("raylib");
const rl = @import("raylib");
pub fn main() anyerror!void
{
pub fn main() anyerror!void {
// Initialization
//--------------------------------------------------------------------------------------
const screenWidth = 800;
const screenHeight = 450;
InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
rl.InitWindow(screenWidth, screenHeight, "raylib-zig [core] example - basic window");
SetTargetFPS(60); // Set our game to run at 60 frames-per-second
rl.SetTargetFPS(60); // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------
// Main game loop
while (!WindowShouldClose()) // Detect window close button or ESC key
while (!rl.WindowShouldClose()) // Detect window close button or ESC key
{
// Update
//----------------------------------------------------------------------------------
@ -29,18 +28,18 @@ pub fn main() anyerror!void
// Draw
//----------------------------------------------------------------------------------
BeginDrawing();
rl.BeginDrawing();
ClearBackground(WHITE);
rl.ClearBackground(rl.WHITE);
DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY);
rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY);
EndDrawing();
rl.EndDrawing();
//----------------------------------------------------------------------------------
}
// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow(); // Close window and OpenGL context
rl.CloseWindow(); // Close window and OpenGL context
//--------------------------------------------------------------------------------------
}

12
lib.zig
View File

@ -14,7 +14,7 @@ pub fn Pkg(pkgdir: []const u8) type {
const raylibFlags = &[_][]const u8{
"-std=c99",
"-DPLATFORM_DESKTOP",
"-D_POSIX_C_SOURCE",
"-D_POSIX_C_SOURCE=199309L",
"-DGL_SILENCE_DEPRECATION",
};
@ -61,7 +61,7 @@ pub fn Pkg(pkgdir: []const u8) type {
exe.linkLibC();
fetchSubmodules(exe.builder) catch
std.debug.warn(
std.debug.print(
\\Warning:
\\Unable to fetch git submodule(s) Assuming package folder is not under
\\version control. If build fails, this is probably why.
@ -84,25 +84,25 @@ pub fn Pkg(pkgdir: []const u8) type {
if (ran_git) return;
ran_git = true;
std.debug.warn("attempting to fetch submodule(s)...\n", .{});
std.debug.print("attempting to fetch submodule(s)...\n", .{});
const git_proc = std.ChildProcess.init(
&[_][]const u8{ "git", "submodule", "update", "--init" },
b.allocator,
) catch {
std.debug.warn("unable to create child process for git. build interrupted\n", .{});
std.debug.print("unable to create child process for git. build interrupted\n", .{});
std.os.exit(1);
};
git_proc.cwd = pkgdir;
const term = git_proc.spawnAndWait() catch {
std.debug.warn("unable to spawn child process for git. build interrupted\n", .{});
std.debug.print("unable to spawn child process for git. build interrupted\n", .{});
std.os.exit(1);
};
switch (term) {
.Exited => |code| if (code != 0) return error.GitFail,
else => {
std.debug.warn("git terminated unexpectedly. build interrupted\n", .{});
std.debug.print("git terminated unexpectedly. build interrupted\n", .{});
std.os.exit(1);
},
}

View File

@ -3,29 +3,30 @@ import re
"""
Automatic utility for generating raylib function headers. Simply put
raylib.h in the working directory of this script and execute.
Tested with raylib version 3.0.0
Tested with raylib version 3.7.0
"""
C_TO_ZIG = {
"bool": "bool",
"char": "u8",
"double": "f64",
"float": "f32",
"int": "c_int",
"long": "c_long",
"unsigned char": "u8",
"unsigned int": "c_uint",
}
# Some c types have a different size on different systems
# Some c types have a different sizes 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 == "double":
t = "f64"
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 c_to_zig_type(c: str) -> str:
c = c.replace("const ", "")
z = C_TO_ZIG.get(c)
if z is not None:
return z
return c
def fix_pointer(name: str, t: str):
@ -38,7 +39,7 @@ def fix_pointer(name: str, t: str):
t = pre + "const " + t
if t == "[*c]const void":
t = "*const c_void"
t = "*const anyopaque"
return name, t
@ -57,22 +58,46 @@ def fix_enums(arg_name, arg_type, func_name):
return arg_type
small_structs = ["Vector2", "Vector3", "Vector4", "Quaternion", "Color", "Rectangle", "Shader"]
def parse_header(header_name: str, output_file: str, prefix: str):
header = open(header_name, mode="r")
zig_functions = []
zig_heads = []
zig_types = set()
leftover = ""
for line in header.readlines():
if line.startswith("typedef struct"):
zig_types.add(line.split(' ')[2])
elif line.startswith("typedef enum"):
# don't trip the general typedef case
pass
elif line.startswith("typedef "):
zig_types.add(line.split(' ')[2].replace(';', '').strip())
if not line.startswith(prefix):
continue
line = line.split(";", 1)[0]
if leftover:
line = leftover + line
leftover = ""
line = line.replace("* ", " *")
line = line.replace(",", ", ")
line = line.replace(" ", " ")
# each (.*) is some variable value
result = re.search(prefix + "(.*) (.*)start_arg(.*)end_arg(.*)", line.replace("(", "start_arg").replace(")", "end_arg"))
if result is None:
leftover += line
continue
# get whats in the (.*)'s
return_type = result.group(1)
func_name = result.group(2)
@ -95,13 +120,17 @@ def parse_header(header_name: str, output_file: str, prefix: str):
arg_type = c_to_zig_type(arg_type)
arg_name, arg_type = fix_pointer(arg_name, arg_type)
zig_types.add(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 + ";")
zigheader = open(output_file, mode="w")
print("usingnamespace @import(\"raylib-zig.zig\");\n", file=zigheader)
print("""const rl = @import("raylib-zig.zig");\n""", file=zigheader)
print("\n".join(sorted(f"const {t} = rl.{t};" for t in zig_types if ('*' not in t) and (t not in C_TO_ZIG.values()))), file=zigheader)
print("", file=zigheader)
print("\n".join(zig_heads), file=zigheader)
print("", file=zigheader)
print("\n".join(zig_functions), file=zigheader)

View File

@ -1,4 +1,51 @@
usingnamespace @import("raylib-zig.zig");
const rl = @import("raylib-zig.zig");
const AudioStream = rl.AudioStream;
const BoneInfo = rl.BoneInfo;
const BoundingBox = rl.BoundingBox;
const Camera = rl.Camera;
const Camera2D = rl.Camera2D;
const Camera3D = rl.Camera3D;
const CameraMode = rl.CameraMode;
const CharInfo = rl.CharInfo;
const Color = rl.Color;
const Font = rl.Font;
const Gestures = rl.Gestures;
const Image = rl.Image;
const KeyboardKey = rl.KeyboardKey;
const LoadFileDataCallback = rl.LoadFileDataCallback;
const LoadFileTextCallback = rl.LoadFileTextCallback;
const Material = rl.Material;
const MaterialMap = rl.MaterialMap;
const Matrix = rl.Matrix;
const Mesh = rl.Mesh;
const Model = rl.Model;
const ModelAnimation = rl.ModelAnimation;
const MouseButton = rl.MouseButton;
const Music = rl.Music;
const NPatchInfo = rl.NPatchInfo;
const Quaternion = rl.Quaternion;
const Ray = rl.Ray;
const RayHitInfo = rl.RayHitInfo;
const Rectangle = rl.Rectangle;
const RenderTexture = rl.RenderTexture;
const RenderTexture2D = rl.RenderTexture2D;
const SaveFileDataCallback = rl.SaveFileDataCallback;
const SaveFileTextCallback = rl.SaveFileTextCallback;
const Shader = rl.Shader;
const Sound = rl.Sound;
const Texture = rl.Texture;
const Texture2D = rl.Texture2D;
const TextureCubemap = rl.TextureCubemap;
const TraceLogCallback = rl.TraceLogCallback;
const Transform = rl.Transform;
const Vector2 = rl.Vector2;
const Vector3 = rl.Vector3;
const Vector4 = rl.Vector4;
const VrDeviceInfo = rl.VrDeviceInfo;
const VrStereoConfig = rl.VrStereoConfig;
const Wave = rl.Wave;
const rAudioBuffer = rl.rAudioBuffer;
pub extern fn InitWindow(width: c_int, height: c_int, title: [*c]const u8) void;
pub extern fn WindowShouldClose() bool;
@ -23,7 +70,7 @@ 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() *const c_void;
pub extern fn GetWindowHandle() *const anyopaque;
pub extern fn GetScreenWidth() c_int;
pub extern fn GetScreenHeight() c_int;
pub extern fn GetMonitorCount() c_int;
@ -68,8 +115,8 @@ pub extern fn LoadShader(vsFileName: [*c]const u8, fsFileName: [*c]const u8) Sha
pub extern fn LoadShaderFromMemory(vsCode: [*c]const u8, fsCode: [*c]const u8) Shader;
pub extern fn GetShaderLocation(shader: Shader, uniformName: [*c]const u8) c_int;
pub extern fn GetShaderLocationAttrib(shader: Shader, attribName: [*c]const u8) c_int;
pub extern fn SetShaderValue(shader: Shader, locIndex: c_int, value: *const c_void, uniformType: c_int) void;
pub extern fn SetShaderValueV(shader: Shader, locIndex: c_int, value: *const c_void, uniformType: c_int, count: c_int) void;
pub extern fn SetShaderValue(shader: Shader, locIndex: c_int, value: *const anyopaque, uniformType: c_int) void;
pub extern fn SetShaderValueV(shader: Shader, locIndex: c_int, value: *const anyopaque, uniformType: c_int, count: c_int) void;
pub extern fn SetShaderValueMatrix(shader: Shader, locIndex: c_int, mat: Matrix) void;
pub extern fn SetShaderValueTexture(shader: Shader, locIndex: c_int, texture: Texture2D) void;
pub extern fn UnloadShader(shader: Shader) void;
@ -89,9 +136,9 @@ pub extern fn TakeScreenshot(fileName: [*c]const u8) void;
pub extern fn SetConfigFlags(flags: c_uint) 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) *const c_void;
pub extern fn MemRealloc(ptr: *const c_void, size: c_int) *const c_void;
pub extern fn MemFree(ptr: *const c_void) void;
pub extern fn MemAlloc(size: c_int) *const anyopaque;
pub extern fn MemRealloc(ptr: *const anyopaque, size: c_int) *const anyopaque;
pub extern fn MemFree(ptr: *const anyopaque) void;
pub extern fn SetTraceLogCallback(callback: TraceLogCallback) void;
pub extern fn SetLoadFileDataCallback(callback: LoadFileDataCallback) void;
pub extern fn SetSaveFileDataCallback(callback: SaveFileDataCallback) void;
@ -99,7 +146,7 @@ pub extern fn SetLoadFileTextCallback(callback: LoadFileTextCallback) void;
pub extern fn SetSaveFileTextCallback(callback: SaveFileTextCallback) void;
pub extern fn LoadFileData(fileName: [*c]const u8, bytesRead: [*c]const c_uint) [*c]const u8;
pub extern fn UnloadFileData(data: [*c]const u8) void;
pub extern fn SaveFileData(fileName: [*c]const u8, data: *const c_void, bytesToWrite: c_uint) bool;
pub extern fn SaveFileData(fileName: [*c]const u8, data: *const anyopaque, bytesToWrite: c_uint) bool;
pub extern fn LoadFileText(fileName: [*c]const u8) [*c]const u8;
pub extern fn UnloadFileText(text: [*c]const u8) void;
pub extern fn SaveFileText(fileName: [*c]const u8, text: [*c]const u8) bool;
@ -282,8 +329,8 @@ pub extern fn LoadTextureCubemap(image: Image, layout: 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: *const c_void) void;
pub extern fn UpdateTextureRec(texture: Texture2D, rec: Rectangle, pixels: *const c_void) void;
pub extern fn UpdateTexture(texture: Texture2D, pixels: *const anyopaque) void;
pub extern fn UpdateTextureRec(texture: Texture2D, rec: Rectangle, pixels: *const anyopaque) void;
pub extern fn GetTextureData(texture: Texture2D) Image;
pub extern fn GetScreenData() Image;
pub extern fn GenTextureMipmaps(texture: [*c]const Texture2D) void;
@ -307,8 +354,8 @@ pub extern fn ColorFromHSV(hue: f32, saturation: f32, value: 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_int) Color;
pub extern fn GetPixelColor(srcPtr: *const c_void, format: c_int) Color;
pub extern fn SetPixelColor(dstPtr: *const c_void, color: Color, format: c_int) void;
pub extern fn GetPixelColor(srcPtr: *const anyopaque, format: c_int) Color;
pub extern fn SetPixelColor(dstPtr: *const anyopaque, color: Color, format: c_int) 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;
@ -323,7 +370,6 @@ 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, fontSize: 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;
@ -371,7 +417,7 @@ pub extern fn LoadModelFromMesh(mesh: Mesh) Model;
pub extern fn UnloadModel(model: Model) void;
pub extern fn UnloadModelKeepMeshes(model: Model) void;
pub extern fn UploadMesh(mesh: [*c]const Mesh, dynamic: bool) void;
pub extern fn UpdateMeshBuffer(mesh: Mesh, index: c_int, data: *const c_void, dataSize: c_int, offset: c_int) void;
pub extern fn UpdateMeshBuffer(mesh: Mesh, index: c_int, data: *const anyopaque, dataSize: c_int, offset: c_int) void;
pub extern fn DrawMesh(mesh: Mesh, material: Material, transform: Matrix) void;
pub extern fn DrawMeshInstanced(mesh: Mesh, material: Material, transforms: [*c]const Matrix, instances: c_int) void;
pub extern fn UnloadMesh(mesh: Mesh) void;
@ -424,7 +470,7 @@ pub extern fn LoadWave(fileName: [*c]const u8) Wave;
pub extern fn LoadWaveFromMemory(fileType: [*c]const u8, fileData: [*c]const u8, dataSize: c_int) Wave;
pub extern fn LoadSound(fileName: [*c]const u8) Sound;
pub extern fn LoadSoundFromWave(wave: Wave) Sound;
pub extern fn UpdateSound(sound: Sound, data: *const c_void, samplesCount: c_int) void;
pub extern fn UpdateSound(sound: Sound, data: *const anyopaque, 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) bool;
@ -458,7 +504,7 @@ pub extern fn SetMusicPitch(music: Music, pitch: f32) 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: *const c_void, samplesCount: c_int) void;
pub extern fn UpdateAudioStream(stream: AudioStream, data: *const anyopaque, 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;

View File

@ -1,4 +1,11 @@
usingnamespace @import("raylib-zig.zig");
const rl = @import("raylib-zig.zig");
const Matrix = rl.Matrix;
const Quaternion = rl.Quaternion;
const Vector2 = rl.Vector2;
const Vector3 = rl.Vector3;
const float16 = rl.float16;
const float3 = rl.float3;
pub extern fn Clamp(value: f32, min: f32, max: f32) f32;
pub extern fn Lerp(start: f32, end: f32, amount: f32) f32;

View File

@ -5,6 +5,10 @@
// Date: 2020-02-15
//
pub usingnamespace @import("raylib-wa.zig");
const rl = @This();
pub const Vector2 = extern struct {
x: f32,
y: f32,
@ -50,33 +54,33 @@ pub const Color = extern struct {
a: u8,
};
pub const LIGHTGRAY = Color { .r = 200, .g = 200, .b = 200, .a = 255 };
pub const GRAY = Color { .r = 130, .g = 130, .b = 130, .a = 255 };
pub const DARKGRAY = Color { .r = 80, .g = 80, .b = 80, .a = 255 };
pub const YELLOW = Color { .r = 253, .g = 249, .b = 0, .a = 255 };
pub const GOLD = Color { .r = 255, .g = 203, .b = 0, .a = 255 };
pub const ORANGE = Color { .r = 255, .g = 161, .b = 0, .a = 255 };
pub const PINK = Color { .r = 255, .g = 109, .b = 194, .a = 255 };
pub const RED = Color { .r = 230, .g = 41, .b = 55, .a = 255 };
pub const MAROON = Color { .r = 190, .g = 33, .b = 55, .a = 255 };
pub const GREEN = Color { .r = 0, .g = 228, .b = 48, .a = 255 };
pub const LIME = Color { .r = 0, .g = 158, .b = 47, .a = 255 };
pub const DARKGREEN = Color { .r = 0, .g = 117, .b = 44, .a = 255 };
pub const SKYBLUE = Color { .r = 102, .g = 191, .b = 255, .a = 255 };
pub const BLUE = Color { .r = 0, .g = 121, .b = 241, .a = 255 };
pub const DARKBLUE = Color { .r = 0, .g = 82, .b = 172, .a = 255 };
pub const PURPLE = Color { .r = 200, .g = 122, .b = 255, .a = 255 };
pub const VIOLET = Color { .r = 135, .g = 60, .b = 190, .a = 255 };
pub const DARKPURPLE = Color { .r = 112, .g = 31, .b = 126, .a = 255 };
pub const BEIGE = Color { .r = 211, .g = 176, .b = 131, .a = 255 };
pub const BROWN = Color { .r = 127, .g = 106, .b = 79, .a = 255 };
pub const DARKBROWN = Color { .r = 76, .g = 63, .b = 47, .a = 255 };
pub const LIGHTGRAY = Color{ .r = 200, .g = 200, .b = 200, .a = 255 };
pub const GRAY = Color{ .r = 130, .g = 130, .b = 130, .a = 255 };
pub const DARKGRAY = Color{ .r = 80, .g = 80, .b = 80, .a = 255 };
pub const YELLOW = Color{ .r = 253, .g = 249, .b = 0, .a = 255 };
pub const GOLD = Color{ .r = 255, .g = 203, .b = 0, .a = 255 };
pub const ORANGE = Color{ .r = 255, .g = 161, .b = 0, .a = 255 };
pub const PINK = Color{ .r = 255, .g = 109, .b = 194, .a = 255 };
pub const RED = Color{ .r = 230, .g = 41, .b = 55, .a = 255 };
pub const MAROON = Color{ .r = 190, .g = 33, .b = 55, .a = 255 };
pub const GREEN = Color{ .r = 0, .g = 228, .b = 48, .a = 255 };
pub const LIME = Color{ .r = 0, .g = 158, .b = 47, .a = 255 };
pub const DARKGREEN = Color{ .r = 0, .g = 117, .b = 44, .a = 255 };
pub const SKYBLUE = Color{ .r = 102, .g = 191, .b = 255, .a = 255 };
pub const BLUE = Color{ .r = 0, .g = 121, .b = 241, .a = 255 };
pub const DARKBLUE = Color{ .r = 0, .g = 82, .b = 172, .a = 255 };
pub const PURPLE = Color{ .r = 200, .g = 122, .b = 255, .a = 255 };
pub const VIOLET = Color{ .r = 135, .g = 60, .b = 190, .a = 255 };
pub const DARKPURPLE = Color{ .r = 112, .g = 31, .b = 126, .a = 255 };
pub const BEIGE = Color{ .r = 211, .g = 176, .b = 131, .a = 255 };
pub const BROWN = Color{ .r = 127, .g = 106, .b = 79, .a = 255 };
pub const DARKBROWN = Color{ .r = 76, .g = 63, .b = 47, .a = 255 };
pub const WHITE = Color {.r = 255, .g = 255, .b = 255, .a = 255 };
pub const BLACK = Color { .r = 0, .g = 0, .b = 0, .a = 255 };
pub const BLANK = Color { .r = 0, .g = 0, .b = 0, .a = 0 };
pub const MAGENTA = Color { .r = 255, .g = 0, .b = 255, .a = 255 };
pub const RAYWHITE = Color { .r = 245, .g = 245, .b = 245, .a = 255 };
pub const WHITE = Color{ .r = 255, .g = 255, .b = 255, .a = 255 };
pub const BLACK = Color{ .r = 0, .g = 0, .b = 0, .a = 255 };
pub const BLANK = Color{ .r = 0, .g = 0, .b = 0, .a = 0 };
pub const MAGENTA = Color{ .r = 255, .g = 0, .b = 255, .a = 255 };
pub const RAYWHITE = Color{ .r = 245, .g = 245, .b = 245, .a = 255 };
pub const Rectangle = extern struct {
x: f32,
@ -86,86 +90,70 @@ pub const Rectangle = extern struct {
};
pub const Image = extern struct {
data: ?*c_void,
data: ?*anyopaque,
width: c_int,
height: c_int,
mipmaps: c_int,
format: PixelFormat,
pub fn init(fileName: [*c]const u8) Image {
return LoadImage(fileName);
}
pub fn initEx(pixels: [*c]Color, width: c_int, height: c_int) Image {
return LoadImageEx(pixels, width, height);
}
pub fn initPro(data: ?*c_void, width: c_int, height: c_int, format: PixelFormat) Image {
return LoadImagePro(data, width, height, format);
return rl.LoadImage(fileName);
}
pub fn initRaw(fileName: [*c]const u8, width: c_int, height: c_int, format: PixelFormat, headerSize: c_int) Image {
return LoadImageRaw(fileName, width, height, format, headerSize);
return rl.LoadImageRaw(fileName, width, height, format, headerSize);
}
pub fn initText(text: [*c]const u8, fontSize: c_int, color: Color) Image {
return ImageText(text, fontSize, color);
return rl.ImageText(text, fontSize, color);
}
pub fn initTextEx(font: Font, text: [*c]const u8, fontSize: f32, spacing: f32, tint: Color) Image {
return ImageTextEx(font, text, fontSize, spacing, tint);
return rl.ImageTextEx(font, text, fontSize, spacing, tint);
}
pub fn copy(image: Image) Image {
return ImageCopy(image);
return rl.ImageCopy(image);
}
pub fn copyRec(image: Image, rec: Rectangle) Image {
return ImageFromImage(image, rec);
return rl.ImageFromImage(image, rec);
}
pub fn GenColor(width: c_int, height: c_int, color: Color) Image {
return GenImageColor(width, height, color);
return rl.GenImageColor(width, height, color);
}
pub fn GenGradientV(width: c_int, height: c_int, top: Color, bottom: Color) Image {
return GenImageGradientV(width, height, top, bottom);
return rl.GenImageGradientV(width, height, top, bottom);
}
pub fn GenGradientH(width: c_int, height: c_int, left: Color, right: Color) Image {
return GenImageGradientH(width, height, left, right);
return rl.GenImageGradientH(width, height, left, right);
}
pub fn GenGradientRadial(width: c_int, height: c_int, density: f32, inner: Color, outer: Color) Image {
return GenImageGradientRadial(width, height, density, inner, outer);
return rl.GenImageGradientRadial(width, height, density, inner, outer);
}
pub fn GenChecked(width: c_int, height: c_int, checksX: c_int, checksY: c_int, col1: Color, col2: Color) Image {
return GenImageChecked(width, height, checksX, checksY, col1, col2);
return rl.GenImageChecked(width, height, checksX, checksY, col1, col2);
}
pub fn GenWhiteNoise(width: c_int, height: c_int, factor: f32) Image {
return GenImageWhiteNoise(width, height, factor);
return rl.GenImageWhiteNoise(width, height, factor);
}
pub fn GenPerlinNoise(width: c_int, height: c_int, offsetX: c_int, offsetY: c_int, scale: f32) Image {
return GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
return rl.GenImagePerlinNoise(width, height, offsetX, offsetY, scale);
}
pub fn GenCellular(width: c_int, height: c_int, tileSize: c_int) Image {
return GenImageCellular(width, height, tileSize);
}
pub fn GetData(self: Image) [*c]Color {
return GetImageData(self);
}
pub fn GetDataNormalized(self: Image) [*c]Color {
return GetImageDataNormalized(self);
return rl.GenImageCellular(width, height, tileSize);
}
pub fn UseAsWindowIcon(self: Image) void {
SetWindowIcon(self);
rl.SetWindowIcon(self);
}
};
@ -186,11 +174,11 @@ pub const RenderTexture = extern struct {
depthTexture: bool,
pub fn Begin(self: RenderTexture2D) void {
BeginTextureMode(self);
rl.BeginTextureMode(self);
}
pub fn End(_: RenderTexture2D) void {
EndTextureMode();
rl.EndTextureMode();
}
};
pub const RenderTexture2D = RenderTexture;
@ -229,23 +217,23 @@ pub const Camera3D = extern struct {
projection: CameraProjection,
pub fn Begin(self: Camera3D) void {
BeginMode3D(self);
rl.BeginMode3D(self);
}
pub fn Update(self: *Camera3D) void {
UpdateCamera(self);
rl.UpdateCamera(self);
}
pub fn GetMatrix(self: Camera3D) Matrix {
return GetCameraMatrix(self);
return rl.GetCameraMatrix(self);
}
pub fn SetMode(self: Camera3D, mode: CameraMode) void {
SetCameraMode(self, mode);
rl.SetCameraMode(self, mode);
}
pub fn End(_: Camera3D) void {
EndMode3D();
rl.EndMode3D();
}
};
pub const Camera = Camera3D;
@ -257,15 +245,15 @@ pub const Camera2D = extern struct {
zoom: f32,
pub fn Begin(self: Camera2D) void {
BeginMode2D(self);
rl.BeginMode2D(self);
}
pub fn GetMatrix(self: Camera2D) Matrix {
return GetCameraMatrix2D(self);
return rl.GetCameraMatrix2D(self);
}
pub fn End(_: Camera2D) void {
EndMode2D();
rl.EndMode2D();
}
};
@ -356,7 +344,7 @@ pub const Wave = extern struct {
sampleRate: c_uint,
sampleSize: c_uint,
channels: c_uint,
data: ?*c_void,
data: ?*anyopaque,
};
pub const rAudioBuffer = opaque {};
@ -378,7 +366,7 @@ pub const Music = extern struct {
sampleCount: c_uint,
looping: bool,
ctxType: c_int,
ctxData: ?*c_void,
ctxData: ?*anyopaque,
};
pub const VrDeviceInfo = extern struct {
@ -748,35 +736,30 @@ pub const NPatchType = enum(c_int) {
NPT_3PATCH_HORIZONTAL = 2,
};
pub const TraceLogCallback = ?fn (c_int, [*c]const u8, [*c]struct___va_list_tag) callconv(.C) void;
// pub const TraceLogCallback = ?fn (c_int, [*c]const u8, [*c]struct___va_list_tag) callconv(.C) void;
pub const LoadFileDataCallback = ?fn ([*c]const u8, [*c]c_uint) callconv(.C) [*c]u8;
pub const SaveFileDataCallback = ?fn ([*c]const u8, ?*c_void, c_uint) callconv(.C) bool;
pub const SaveFileDataCallback = ?fn ([*c]const u8, ?*anyopaque, c_uint) callconv(.C) bool;
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 MAX_TOUCH_POINTS = 10;
pub const MAX_MATERIAL_MAPS = 12;
pub const MAX_SHADER_LOCATIONS = 32;
pub const PI = 3.141593;
pub const SpriteFont = Font;
pub const SubText = TextSubtext;
pub const ShowWindow = UnhideWindow;
pub const FormatText = TextFormat;
pub const LoadText = LoadFileText;
pub const GetExtension = GetFileExtension;
pub const GetImageData = LoadImageColors;
pub const FILTER_POINT = TEXTURE_FILTER_POINT;
pub const FILTER_BILINEAR = TEXTURE_FILTER_BILINEAR;
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 PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 = PixelFormat.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 = SHADER_LOC_MAP_ALBEDO;
pub const SHADER_LOC_MAP_SPECULAR = SHADER_LOC_MAP_METALNESS;
pub usingnamespace @import("raylib-wa.zig");
pub const SHADER_LOC_MAP_DIFFUSE = ShaderLocationIndex.SHADER_LOC_MAP_ALBEDO;
pub const SHADER_LOC_MAP_SPECULAR = ShaderLocationIndex.SHADER_LOC_MAP_METALNESS;

View File

@ -1,3 +1,5 @@
#!/bin/env bash
if [ "$#" -ne 1 ]; then
PROJECT_NAME='Project'
else