Clang vs CBindingGen

Do you have any unfinished code you could upload?

I might want to take part in the Game Makers Toolkit game jam next month and if i don’t have to start from scratch that might motivate me to get something runable by then.

Not really anything beyond a basic proof of concept. I basically used Gnumic’s example:

wrap.toml

[general]
library_name = ":libraylib"
output_file_path = "./LibRaylib.jl"
module_name = "LibRaylib"
use_julia_native_enum_type = true

wrap.jl

using Clang.Generators

cd(@__DIR__)

const RAYLIB_H = ["/usr/local/include/raylib.h"]

options = load_options(joinpath(@__DIR__, "wrap.toml"))

args = String[]

ctx = create_context(RAYLIB_H, args, options)

build!(ctx)

Running wrap.jl produces LibRayLib.jl which is 99% fine, but needs a tiny bit of editing to account for issues with vararg functions and some macros (no idea if that has been fixed in the meantime). Then code like this works:

run_rl.jl



include("LibRaylib.jl")

const RL = LibRaylib

const screen_width = 1600
const screen_height = 900

function run()
	RL.InitWindow(screen_width, screen_height, "run")

	camera = RL.Camera2D(RL.Vector2(500, 500), 
		RL.Vector2(screen_width/2, screen_height/2),
		0.0,
		1.0)

	x = floor(Int, rand() * 1000) + 200
	y = floor(Int, rand() * 700) + 100

	while RL.WindowShouldClose() == 0
		RL.BeginDrawing()
		
		RL.BeginMode2D(camera)
		RL.ClearBackground(RL.Color(0, 0, 0, 255))

		x += floor(Int, (rand()-0.49)*10)
		y += floor(Int, (rand()-0.49)*10)

		RL.DrawText("Dies ist ein Test!", 200, 200, 20, RL.Color(250, 0, 0, 255))
		RL.DrawCircle(x, y, 100, RL.Color(0, 255, 0, 150))

		RL.EndMode2D()




		RL.EndDrawing()
	end

	RL.CloseWindow()
end


run()
1 Like