Skip to content

Commit

Permalink
Hello
Browse files Browse the repository at this point in the history
  • Loading branch information
Neil Wolfkid committed Jan 10, 2023
1 parent 75b71bc commit ab13f53
Show file tree
Hide file tree
Showing 13 changed files with 527 additions and 112 deletions.
4 changes: 2 additions & 2 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/meshbox",
"args": ["data.bin"],
"program": "${workspaceFolder}/zig-out/bin/meshbox",
"args": ["demo/"],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
Expand Down
45 changes: 1 addition & 44 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,52 +1,9 @@
{
"makefile.launchConfigurations": [
{
"cwd": "/home/darl/Projects/meshbox",
"binaryPath": "/home/darl/Projects/meshbox/meshbox",
"binaryArgs": []
},
{
"cwd": "/home/darl/Projects/meshbox",
"binaryPath": "/home/darl/Projects/meshbox/meshbox",
"binaryArgs": []
}
],
"files.associations": {
"array": "c",
"string_view": "c",
"initializer_list": "c",
"cmath": "c",
"shader.h": "c",
"string": "c",
"deque": "c",
"unordered_map": "c",
"vector": "c",
"system_error": "c",
"zip.h": "c",
"bit": "c",
"*.tcc": "c",
"exception": "c",
"algorithm": "c",
"functional": "c",
"random": "c",
"limits": "c",
"numeric": "c",
"ostream": "c",
"streambuf": "c",
"typeinfo": "c",
"*.rh": "c",
"compare": "c",
"type_traits": "c",
"tuple": "c",
"utility": "c",
"stat.h": "c"
},
"Lua.diagnostics.disable": [
"undefined-global"
],
"Lua.diagnostics.globals": [
"cb_frame",
"cb_init"
"mb_frame",
],
"Lua.workspace.checkThirdParty": false
}
2 changes: 1 addition & 1 deletion build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn build(b: *std.build.Builder) void {
exe.install();

const run_cmd = exe.run();
//run_cmd.addArg("demo/");
run_cmd.addArg("demo/");
run_cmd.step.dependOn(b.getInstallStep());
if (b.args) |args| {
run_cmd.addArgs(args);
Expand Down
Binary file removed demo/meshbox.iqm
Binary file not shown.
13 changes: 2 additions & 11 deletions demo/meshbox.lua
Original file line number Diff line number Diff line change
@@ -1,29 +1,20 @@
local vertices, indices = vx_load("meshbox.iqm")
print(table.concat(indices, ", "))

for k, v in ipairs(vertices) do
print(("{x=%f, y=%f, z=%f, u=%f, v=%f},"):format(v.x, v.y, v.z, v.u, v.v))
end
local vertices, indices = vx_load("barbie.iqm")

local a = 0
function mb_loop(dt)
a = a + dt * 12

tx_bind("<meshbox>")
mx_mode("projection")
mx_perspective(100, 0, 1000)

mx_mode("view")
mx_look_at(
math.sin(a)*3, math.cos(a)*3, 3,
0, 5, 0,
0, 0, 0,
0, 0, 1
)

mx_mode("model")
mx_identity()
vx_mesh(vertices)
vx_render(indices)

gx_background(0, 0, 0, 1)
end
Binary file removed demo/meshbox_text.iqm
Binary file not shown.
64 changes: 64 additions & 0 deletions docs/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/meshy.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 3 additions & 9 deletions lib/ziglua/src/ziglua-5.4/lib.zig
Original file line number Diff line number Diff line change
Expand Up @@ -325,20 +325,14 @@ pub const Lua = struct {
const alignment = @alignOf(std.c.max_align_t);
const allocator = opaqueCast(Allocator, data.?);

if (@ptrCast(?[*]align(alignment) u8, @alignCast(alignment, ptr))) |prev_ptr| {
if (nsize == 0) {
return null;
} else if (@ptrCast(?[*]align(alignment) u8, @alignCast(alignment, ptr))) |prev_ptr| {
const prev_slice = prev_ptr[0..osize];

// when nsize is zero the allocator must behave like free and return null
if (nsize == 0) {
allocator.free(prev_slice);
return null;
}

// when nsize is not zero the allocator must behave like realloc
const new_ptr = allocator.reallocAdvanced(prev_slice, nsize, 0) catch return null;
return new_ptr.ptr;
} else if (nsize == 0) {
return null;
} else {
// ptr is null, allocate a new block of memory
const new_ptr = allocator.alignedAlloc(u8, alignment, nsize) catch return null;
Expand Down
6 changes: 6 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
![image](docs/logo.svg)
A Lua game engine for making PS1-styled games, with a comfortable API that ressembles OpenGL 1.0.

Currently project-in-construction, come back later!

![image](docs/meshy.png)
Loading

0 comments on commit ab13f53

Please sign in to comment.