various fixes
This commit is contained in:
parent
fef7b8e417
commit
904b915d31
3 changed files with 18 additions and 15 deletions
|
@ -3,8 +3,7 @@
|
||||||
.version = "0.0.0",
|
.version = "0.0.0",
|
||||||
.dependencies = .{
|
.dependencies = .{
|
||||||
.zclay = .{
|
.zclay = .{
|
||||||
.url = "../../",
|
.path = "../../",
|
||||||
.hash = "1220d6ec9e404578dd1484fd60b767f1c91906c0cc19a86c4089a36c6366aa193fef",
|
|
||||||
},
|
},
|
||||||
.@"raylib-zig" = .{
|
.@"raylib-zig" = .{
|
||||||
.url = "https://github.com/Not-Nik/raylib-zig/archive/f26b2ab084be5e2840b7451818590cc512b7b972.tar.gz",
|
.url = "https://github.com/Not-Nik/raylib-zig/archive/f26b2ab084be5e2840b7451818590cc512b7b972.tar.gz",
|
||||||
|
|
|
@ -114,7 +114,7 @@ pub fn main() anyerror!void {
|
||||||
.window_highdpi = true,
|
.window_highdpi = true,
|
||||||
.window_resizable = true,
|
.window_resizable = true,
|
||||||
});
|
});
|
||||||
rl.initWindow(1000, 1000, "Raylib Odin Example");
|
rl.initWindow(1000, 1000, "Raylib zig Example");
|
||||||
rl.setTargetFPS(60);
|
rl.setTargetFPS(60);
|
||||||
|
|
||||||
// loadFont(@embedFile("./resources/Roboto-Regular.ttf"), 0, 100);
|
// loadFont(@embedFile("./resources/Roboto-Regular.ttf"), 0, 100);
|
||||||
|
@ -131,8 +131,8 @@ pub fn main() anyerror!void {
|
||||||
|
|
||||||
const mouse_pos = rl.getMousePosition();
|
const mouse_pos = rl.getMousePosition();
|
||||||
cl.setPointerState(.{
|
cl.setPointerState(.{
|
||||||
mouse_pos.x,
|
.x = mouse_pos.x,
|
||||||
mouse_pos.y,
|
.y = mouse_pos.y,
|
||||||
}, rl.isMouseButtonDown(.mouse_button_left));
|
}, rl.isMouseButtonDown(.mouse_button_left));
|
||||||
|
|
||||||
cl.setLayoutDimensions(.{
|
cl.setLayoutDimensions(.{
|
||||||
|
|
24
src/root.zig
24
src/root.zig
|
@ -3,10 +3,13 @@ const builtin = @import("builtin");
|
||||||
|
|
||||||
pub const String = extern struct {
|
pub const String = extern struct {
|
||||||
length: c_int,
|
length: c_int,
|
||||||
chars: [*]c_char,
|
chars: [*c]c_char,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const Vector2 = [2]f32;
|
pub const Vector2 = extern struct {
|
||||||
|
x: f32,
|
||||||
|
y: f32,
|
||||||
|
};
|
||||||
|
|
||||||
pub const Dimensions = extern struct {
|
pub const Dimensions = extern struct {
|
||||||
width: f32,
|
width: f32,
|
||||||
|
@ -17,7 +20,7 @@ pub const Arena = extern struct {
|
||||||
label: String,
|
label: String,
|
||||||
nextAllocation: u64,
|
nextAllocation: u64,
|
||||||
capacity: u64,
|
capacity: u64,
|
||||||
memory: [*]c_char,
|
memory: [*c]c_char,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const BoundingBox = extern struct {
|
pub const BoundingBox = extern struct {
|
||||||
|
@ -48,7 +51,8 @@ pub const ElementId = extern struct {
|
||||||
stringId: String,
|
stringId: String,
|
||||||
};
|
};
|
||||||
|
|
||||||
pub const EnumBackingType = if (builtin.os.tag == .windows) u32 else u8;
|
// pub const EnumBackingType = if (builtin.os.tag == .windows) u32 else u8;
|
||||||
|
pub const EnumBackingType = u8;
|
||||||
|
|
||||||
pub const RenderCommandType = enum(EnumBackingType) {
|
pub const RenderCommandType = enum(EnumBackingType) {
|
||||||
None,
|
None,
|
||||||
|
@ -221,17 +225,17 @@ pub fn ClayArray(comptime T: type) type {
|
||||||
return extern struct {
|
return extern struct {
|
||||||
capacity: u32,
|
capacity: u32,
|
||||||
length: u32,
|
length: u32,
|
||||||
internalArray: [*]T,
|
internalArray: [*c]T,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
const extern_elements = struct {
|
const extern_elements = struct {
|
||||||
// TODO: should use @extern instead but zls does not yet support it well
|
// TODO: should use @extern instead but zls does not yet support it well
|
||||||
extern "c" fn Clay_MinMemorySize() u32;
|
extern "c" fn Clay_MinMemorySize() u32;
|
||||||
extern "c" fn Clay_CreateArenaWithCapacityAndMemory(capacity: u32, offset: [*]u8) Arena;
|
extern "c" fn Clay_CreateArenaWithCapacityAndMemory(capacity: u32, offset: [*c]u8) Arena;
|
||||||
extern "c" fn Clay_SetPointerState(position: [*]f32, pointerDown: bool) void;
|
extern "c" fn Clay_SetPointerState(position: Vector2, pointerDown: bool) void;
|
||||||
extern "c" fn Clay_Initialize(arena: Arena, layoutDimensions: Dimensions) void;
|
extern "c" fn Clay_Initialize(arena: Arena, layoutDimensions: Dimensions) void;
|
||||||
extern "c" fn Clay_UpdateScrollContainers(isPointerActive: bool, scrollDelta: [*]f32, deltaTime: f32) void;
|
extern "c" fn Clay_UpdateScrollContainers(isPointerActive: bool, scrollDelta: Vector2, deltaTime: f32) void;
|
||||||
extern "c" fn Clay_SetLayoutDimensions(dimensions: Dimensions) void;
|
extern "c" fn Clay_SetLayoutDimensions(dimensions: Dimensions) void;
|
||||||
extern "c" fn Clay_BeginLayout() void;
|
extern "c" fn Clay_BeginLayout() void;
|
||||||
extern "c" fn Clay_EndLayout() ClayArray(RenderCommand);
|
extern "c" fn Clay_EndLayout() ClayArray(RenderCommand);
|
||||||
|
@ -296,11 +300,11 @@ pub const borderConfig = extern_elements.Clay__StoreBorderElementConfig;
|
||||||
pub const hashString = extern_elements.Clay__HashString;
|
pub const hashString = extern_elements.Clay__HashString;
|
||||||
|
|
||||||
pub fn setPointerState(position: Vector2, pointerDown: bool) void {
|
pub fn setPointerState(position: Vector2, pointerDown: bool) void {
|
||||||
extern_elements.Clay_SetPointerState(@ptrCast(@constCast(&position)), pointerDown);
|
extern_elements.Clay_SetPointerState(position, pointerDown);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn updateScrollContainers(isPointerActive: bool, scrollDelta: Vector2, deltaTime: f32) void {
|
pub fn updateScrollContainers(isPointerActive: bool, scrollDelta: Vector2, deltaTime: f32) void {
|
||||||
extern_elements.Clay_UpdateScrollContainers(isPointerActive, @ptrCast(@constCast(&scrollDelta)), deltaTime);
|
extern_elements.Clay_UpdateScrollContainers(isPointerActive, scrollDelta, deltaTime);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn text(id: ElementId, string: []const u8, config: *TextElementConfig) void {
|
pub fn text(id: ElementId, string: []const u8, config: *TextElementConfig) void {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue