Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix arrays #12

Merged
merged 3 commits into from
Aug 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
68 changes: 68 additions & 0 deletions resources/shader.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
shaders:
- slang: glsl430
programs:
- name: default
vs:
path: /Users/ccuddigan/Github/delve-framework/assets/shaders/built/default/default_default_glsl430_vs.glsl
is_binary: false
entry_point: main
inputs:
- slot: 10
name: pos
sem_name: TEXCOORD
sem_index: 0
- slot: 1
name: color0
sem_name: TEXCOORD
sem_index: 1
- slot: 2
name: texcoord0
sem_name: TEXCOORD
sem_index: 2
outputs:
- slot: 20
name: color
sem_name: TEXCOORD
sem_index: 30
- slot: 1
name: uv
sem_name: TEXCOORD
sem_index: 1
uniform_blocks:
- slot: 40
size: 144
struct_name: vs_params
inst_name: _19
uniforms:
- name: u_projViewMatrix
type: vec4
array_count: 4
offset: 50
fs:
path: /Users/ccuddigan/Github/delve-framework/assets/shaders/built/default/default_default_glsl430_fs.glsl
is_binary: false
entry_point: main
inputs:
- slot: 70
name: color
sem_name: TEXCOORD
sem_index: 80
- slot: 1
name: uv
sem_name: TEXCOORD
sem_index: 1
outputs:
- slot: 90
name: frag_color
sem_name: TEXCOORD
sem_index: 100
uniform_blocks:
- slot: 110
size: 32
struct_name: fs_params
inst_name: _36
uniforms:
- name: u_color_override
type: vec4
array_count: 1
offset: 120
21 changes: 9 additions & 12 deletions resources/tutorial.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,12 @@ education: |
3 A-Levels
BSc in the Internet of Things
tutorial:
- yml:
name: "YAML Ain't Markup Language"
type: awesome
born: 2001
- json:
name: JavaScript Object Notation
type: great
born: 2001
- xml:
name: Extensible Markup Language
type: good
born: 1996
- name: "YAML Ain't Markup Language"
type: awesome
born: 2001
- name: JavaScript Object Notation
type: great
born: 2001
- name: Extensible Markup Language
type: good
born: 1996
39 changes: 39 additions & 0 deletions src/Suspense.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
const Self = @This();

const std = @import("std");

arr: std.ArrayList([]const u8),
current_index: usize,

pub fn init(allocator: std.mem.Allocator) Self {
return .{
.arr = std.ArrayList([]const u8).init(allocator),
.current_index = 0,
};
}

pub fn deinit(self: *Self) void {
self.arr.deinit();
}

pub fn set(self: *Self, data: []const u8) !void {
try self.arr.append(data);
}

pub fn get(self: *Self) ?[]const u8 {
if (self.arr.items.len == 0) {
return null;
}

if (self.current_index == self.arr.items.len) {
self.current_index = 0;
self.arr.clearAndFree();
return null;
}

const element = self.arr.items[self.current_index];

self.current_index += 1;

return element;
}
63 changes: 41 additions & 22 deletions src/main.zig
Original file line number Diff line number Diff line change
Expand Up @@ -2,27 +2,50 @@ const std = @import("std");

const Ymlz = @import("root.zig").Ymlz;

const Tutorial = struct {
const Uniform = struct {
name: []const u8,
type: []const u8,
born: u16,
array_count: i32,
offset: usize,
};

const Tester = struct {
first: i32,
second: i64,
const UniformBlock = struct {
slot: u64,
size: u64,
struct_name: []const u8,
inst_name: []const u8,
uniforms: []Uniform,
};

const Input = struct {
slot: u64,
name: []const u8,
fourth: f32,
foods: [][]const u8,
// inner: struct {
// sd: i32,
// k: u8,
// l: []const u8,
// another: struct {
// new: f32,
// stringed: []const u8,
// },
// },
sem_name: []const u8,
sem_index: usize,
};

const Details = struct {
path: []const u8,
is_binary: bool,
entry_point: []const u8,
inputs: []Input,
outputs: []Input,
uniform_blocks: []UniformBlock,
};

const Program = struct {
name: []const u8,
vs: Details,
fs: Details,
};

const Shader = struct {
slang: []const u8,
programs: []Program,
};

const Experiment = struct {
shaders: []Shader,
};

pub fn main() !void {
Expand All @@ -45,13 +68,9 @@ pub fn main() !void {
);
defer allocator.free(yml_path);

var ymlz = try Ymlz(Tester).init(allocator);
var ymlz = try Ymlz(Experiment).init(allocator);
const result = try ymlz.loadFile(yml_path);
defer ymlz.deinit(result);

std.debug.print("Tester: {any}\n", .{result});
std.debug.print("Tester.name: {s}\n", .{result.name});
std.debug.print("Tester.forth: {}\n", .{result.fourth});
std.debug.print("Tester.foods: {any}\n", .{result.foods});
// std.debug.print("Tester.inner: {any}\n", .{result.inner});
std.debug.print("Tester: {s}\n", .{result.shaders[0].programs[0].fs.uniform_blocks[0].uniforms[0].name});
}
Loading