raylib bindings started
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
NUBC = ../compiler/NubLang.CLI/bin/Debug/net9.0/nubc
|
||||
|
||||
out: .build/out.o
|
||||
gcc -nostartfiles -o out x86_64.s .build/out.o
|
||||
gcc -nostartfiles -lm -o out x86_64.s .build/out.o vendor/raylib-5.5_linux_amd64/lib/libraylib.a
|
||||
|
||||
.build/out.o: $(NUBC) src/main.nub src/ref.nub
|
||||
$(NUBC) src/main.nub src/ref.nub
|
||||
.build/out.o: $(NUBC) src/main.nub src/raylib.nub
|
||||
$(NUBC) src/main.nub src/raylib.nub
|
||||
|
||||
.PHONY: $(NUBC)
|
||||
# .PHONY: $(NUBC)
|
||||
$(NUBC):
|
||||
dotnet build ../compiler/NubLang.CLI/NubLang.CLI.csproj
|
||||
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
import "core"
|
||||
import "raylib"
|
||||
|
||||
module "main"
|
||||
|
||||
struct Human
|
||||
{
|
||||
name: cstring
|
||||
}
|
||||
|
||||
extern "main" func main(args: []cstring): i64
|
||||
{
|
||||
let x: core::ref<Human> = {}
|
||||
test(x)
|
||||
return 0
|
||||
}
|
||||
raylib::InitWindow(1600, 900, "Hi from nub-lang")
|
||||
|
||||
func test(x: core::ref<Human>)
|
||||
{
|
||||
while !raylib::WindowShouldClose()
|
||||
{
|
||||
raylib::BeginDrawing()
|
||||
raylib::EndDrawing()
|
||||
}
|
||||
|
||||
return 0
|
||||
}
|
||||
1502
example/src/raylib.nub
Normal file
1502
example/src/raylib.nub
Normal file
File diff suppressed because it is too large
Load Diff
@@ -1,40 +0,0 @@
|
||||
module "core"
|
||||
|
||||
extern "puts" func puts(text: cstring)
|
||||
extern "malloc" func malloc(size: u64): ^void
|
||||
extern "free" func free(address: ^void)
|
||||
|
||||
export struct ref<T>
|
||||
{
|
||||
value: ^T
|
||||
count: ^u64
|
||||
|
||||
@oncreate
|
||||
func on_create()
|
||||
{
|
||||
puts("on_create")
|
||||
this.value = @interpret(^T, malloc(@size(T)))
|
||||
this.count = @interpret(^u64, malloc(@size(u64)))
|
||||
this.count^ = 1
|
||||
}
|
||||
|
||||
@oncopy
|
||||
func on_copy()
|
||||
{
|
||||
puts("on_copy")
|
||||
this.count^ = this.count^ + 1
|
||||
}
|
||||
|
||||
@ondestroy
|
||||
func on_destroy()
|
||||
{
|
||||
puts("on_destroy")
|
||||
this.count^ = this.count^ - 1
|
||||
if this.count^ <= 0
|
||||
{
|
||||
puts("free")
|
||||
free(@interpret(^void, this.value))
|
||||
free(@interpret(^void, this.count))
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user