#Gaylib - Raylib functionnal bindings in Gleam
1 messages ยท Page 1 of 1 (latest)
There
so
I get your point with the shapes
I keep forgetting variables are immutable in gleam
so it actually does make sense with that argument
I think?
it's just funny btw
I almost finished copying all raylib functions in gleam
and now have to start over
mostly
๐ญ
the API Louis said made sense to me -
rl.drawing([
rl.Text("Hello world", 190, 200, 20, rl.LIGHT_GREY),
rl.Text("Hello world 2!", 190, 240, 20, rl.RED),
])
it's basically what raylib looks like normally
I don't know
I love and hate it
it almost looks too simplistic to do anything with it
this would literally be
BeginDrawing();
DrawText("Hello world", 190, 200, 20, LIGHTGRAY);
DrawText("Hello world", 190, 240, 20, LIGHTGRAY);
EndDrawing();
```in c
it looks very similar to lustre's html
then you might introduce a camera, shading
yeah exactly that's the issue
html is very "simple"
one parent many childs
this works with UIs pretty well too
but that's for a game/graphics library
there are more things to it
like usually you would have to
BeginShaderMode(shader)
BeginMode3D(camera)
BeginDrawing()
// ...
// End...
with that API you can't do that
i mean
rl.drawing([ // basically BeginDrawing()
rl.Text("Hello world", 190, 200, 20, rl.LIGHT_GREY),
rl.Text("Hello world 2!", 190, 240, 20, rl.RED),
]) // basically EndDrawing()
that I know
that works when it's simple
you can't do that with that
rl.drawing([
rl.Camera2D(target: rl.Vec2(100, 100), rotation: 40.0, zoom: 1.0, draws: [
rl.Rectangle(...),
rl.Rectangle(...),
rl.Rectangle(...),
]),
rl.Text(...),
])
why not? this is your api
but
I don't understand how the fuck you're supposed to use that to then make the proper calls to raylib
like what if the user passes in two cameras
and wtf are the argument rl.drawing takes
if drawcall == camera2d then do_calls() pseudocode
what
@-@
I don't understand how all of that makes any single inch of sense
you don't do BeginDrawing and then BeginMode2D
you do the opposite
type DrawCall {
Camera2D(...)
Text(...)
Rectangle(...)
}
pub fn drawing(draws: List(DrawCall))
this implies the opposite
uhhh yeah you dooo?
what
gotta 'encode' the stuff you want drawn/functions you want called in data/types -> pass through FFI -> 'decode' into the respective function calls
that i know
i just
i don't even know how to use raylib
i should just stop
sorry
i was trying to not get angry at myself and sad and all
i'm good
I'm gonna mostly restart everything and try those ideas thx
mh
wait
actually this doesn't fix my main issue
the main loop is usually not a single "phase"
there's also the event handling
like key/button press and stuff
in C you call one function, take its result and do stuff accordingly
you can't just do that here
as I said the goal would be to do a single call per frame
I see how it could be possible to have like a bit
2 to 5
but 1
that seems impossible here
again I don't have the functionnal programming logic at all i'm bad at it
so i'm surely just blind
while (!WindowShouldClose()) {
if (IsKeyDown(KEY_RIGHT)) { ... }
BeginDrawing();
...
EndDrawing();
}
type Model {
Model(...)
}
fn view(model: Model) {
rl.drawing([
...
])
}
fn update(event: rl.Event, model: Model) -> Model {
case event {
rl.KeyDown(rl.KEY_RIGHT) -> { ... }
_ -> model
}
}
fn main() {
rl.run(update, view)
}
```i'd prob start by modelling it using MVU/MVU-adjacent stuff, maybe like this? you collate all the events for that frame, pass them to gleam and then gleam can either handle them 1-by-1 like i showed here or you could pass a `List(rl.Event)` and handle them like that?
just spitballing ideas
well I mean
it's a good idea
but there's a big problem
just using WindowShouldClose might work in simple cases
but in some cases it shouldn't exit
in some other cases you might want another event to do it
and I don't see how update should return a Model?-
you update the model
aaaaaaaaaaaaaa
it's a generic
then make that an argument too
you don't mean a 3D model
yeah ig
your API doesn't care about what the state of the user's application is
no i'm talking about MVU-
i think taking a look at lustre would honestly help
probably
...
mhm
sorry
don't be
too late
That's because it is ๐ ๐
I think, seeing the C produced that indeed, lustre's approach would make it REALLY nice and approachable. These would be so good.
i'm trying
excluding the background buildings because โจ time โจ, i imagine that the "2d camera" example at https://raylib.com/examples.html could look like this
there's probably some syntax errors here as i typed it in a text editor without the API actually existing
and spelling mistakes then ๐
I see
interesting
mmh
you can't... save the window?
in raylib it's not exposed
or is it?
ooooh
I see what you did with the State
doesn't matter - this could be a gleam type just to transfer the information better
then in C you grab the value and just
InitWindow(window.width, window.height, window.title)
i see what you mean
i'd make an example impl but i have 0 clue how to do NIFs
i looked into it for like 20mins before my d&d session and decided it was over my pay grade
i mean i find C on it's own a pain in the arse so
i'm unsure, is it really possible to like get a list of all the events in raylib?
and then call update with all of em
idk
the way you did it it looks like update is called per event not per frames?
you decide what an event is
addressed that in the message text
ah
so I know it's for what we're going, but I made this work
pub fn main() {
init_window(800, 600, charlist.from_string("RayGleam"), 60)
drawing([
Background(Color(255, 0, 0, 255))
])
close_window()
}
obviously the window closes instantly
but it's something!
(the C is a mess, i'm glad I made some macros)
I need to make a logo for raygleam one day
gaylib :3
what if you give it a black border around the pride colors
glucy
luke
chad
jared the gay lib
i like jared
so it's gonna be jared
:3
i like it but idk it's not great
you made me rename raygleam to gaylib
jeez
alright
refactor
and then i'll commit the first thingy
Gaylib - Raylib functionnal bindings in Gleam
hehe
?
the name chamge is official now
jared is pretty silly i think
nuh
it doesn't look like this normaly wait
it's a font problem
lemme fix it
i think it's good now
yep it's good now
great
Alr, so I've been working a bit on it today
(gl is for gaylib)
it's clearly impractical for now since the events are a list
but at least it works
And keypress too
fn update(state: State, update: gl.Update) -> #(State, List(gl.Action)) {
let actions = case list.contains(update.events, gl.WindowShouldClose) {
True -> [gl.Close]
False -> []
}
let time = case list.contains(update.events, gl.KeyPressed(gl.R)) {
False -> state.time +. update.dt /. 1.5
True -> 0.
}
#(State(
gl.Vec4(
x: maths.sin({ time *. 2. } +. 1.),
y: maths.sin({ time *. 2. +. 2. } +. 1.),
z: maths.sin({ time *. 2. +. 4. } +. 1.),
w: 1.,
)
|> gl.vec4_to_color,
time:
), actions)
}
This example update function basically make the background_colorfield of State rotate between red, green, and blue
and when pressing R it resets the timer
and since the whole math is based on it
it starts again
dumb example I know
but showcases what you can do for now :3
However I'm having a big big issue
for most of the other input events, unless checking every single key/button, you can't know if it was Released, if it Down, etc...
all key presses done in a single frame are easily accessible in raylib with the GetKeyPressed() function
it returns the last element in the list of key presses in current frame and pops it
or returns 0 if that list is empty
which allows me to create a dynamic array of key pressed in C to then make an erlang list
however you cannot do that for the key that are down
so I have to do at least 109 function calls (for each keyboard key currently down)
sounds a bit uhm
much
so idk if it's the right approach
Maybe a variant of each press and a function that takes that type
on the gleam side that is
that'd hopefully cut down on the functions you have to write ๐
well yes but I did not understand what you said lol so
and it's not about the number of functions i write
but I call
all of that is still done in one single function
pushed it if anyone want to take a look https://codeberg.org/movva-lpu/gaylib/commit/2fd0c01219654b731c279232a88022344de2f0f7
are the keys each their own function on the raylib side?
no
it's one single function for each action
GetKeyDown, GetKeyPressed, GetKeyReleased
no
wait
IsKeyDown, IsKeyPressed, IsKeyReleased
and thx to its convenience I use GetKeyPressed rn
but that's only on the frame you press the key
unlike IsKeyDown
but it has to be done for each key
and again that's just for keyboard keys the same has to be done for gamepad buttons
oh god
im so dumb
C passes copy to functions
not reference
I got used to rust after using it once
shoot
pub type Color {
Color(r: Int, g: Int, b: Int, a: Int)
}
fyi there's a gleam community package for this ^.^
there is no issue
a
im just pointing out for your information that there's a gleam_cimmunity_colour package
well maybe but I hate depending on too much things
color stuff ain't too hard
well
i mean
for RGB
i was just pointing it out in case you didnt know and cared.
yeah thx
i'll look into it... maybe
but idc :3
at least for now
since in rl there's a way to use HSV for some stuff, i might have to look into how it's done elsewere
cuz I looked into it and gosh I hate HSV and HSL
and there's worse ;_;
i mean no
i love them
it's so cool
but not the maths
sorry if I sounded too cold or anything haha-
I have no idea how to properly have some kind of "Action" that you can do during the update
like move the window, close it, and stuff
like
meh
and even Events, they come in as a List
which is inpractical lol
I looked at Lustre and it helped a bit
now you can initialize the window like that
which kinda makes more sense
which is a big problem when you start handling a lot of events
the game still runs fine at 60 fps
but yeah
even 144
and more so it's fine
another issue btw
the events are one frame late
since I do drawing and getting the events at the same time
idk how to explain honestly-
i mean it's still pretty cool
once FFI call for all of that
and also contructing everything from C
that's pretty cool
NIF is pretty powerful
Alr so imma pause this for now
I'm stuck on the design of the API
Tho i'm still fully open to suggestions
I don't know functionnal programming enough
and Raylib is clearly not made for pure functionnal programming and even less in a VM like BEAM
I'm still proud of what I achieved still
For example I implemented the possibility to handle runtime errors
Which is very practical
All function from NIF return a result I construct in C
And are then passed to a error handler you made or a default one
rn there are two default ones, panic_handler and ignore_handler
both do what you'd expect I think haha
Or for example I got some inspiration from Lustre
But I can't really copy its design because of the fundamental differences and constraints afai
And I think for someone that doesn't know functionnal programming at all I did a pretty good job
But rn I need to actually learn more of those things before making gaylib good
Thank u all for your participation <3
See you soon!
you need a contributor?
I mean I wouldn't mind haha
Never really collaborated on any of my projects lol
So idk how that would go haha
And note that this is a complex project that no one will end up using
the thing that should actually be done is a raylib-like but in functionnal style
which already exists
what are you referring to that already exists
also no i would use this all the time for many reasons so thats enough of a reason to me
i actually was already planning on trying to do gleam bindings for raylib anyways
I know functional graphic libraries already exist
Idk their names tho
oh lol but thats not gleam nor raylib
yes but raylib is not made for that at all
Plus
Since FFI calls are expensive
so theres nothing for me to contribute with?
I only allow the library to do one per frame
Wdym?
But traditionnally you do lots per frame
like if i wanted to help mature the project, is there anything left for me to do?
So I had to fundamentaly change how raylib works
of course haha
Lemme finnish what i'm doing
then go see how it's like rn
you'll see what i mean
it doesn't look like raylib in gleam
I could have done it differently
like accumulate actions somewhere
and then pass them to C and call
Which we kinda do rn too
but less
i mean i'm looking at the main gleam file and it doesnt look that bad
ok ๐โ๐ฆบ
there
implemented what I talked about in my big message
the testing.gleam is still similar as before
what part did you change?
Mostly C and a bit of the API
Now the C functions return a Result
and the errors are passed to window.error which by default is panic_handler
before functions returned a badarg
which made the BEAM crash with a non very explicit error
that was logged to the console yes but before erlang's crap
now it doesn't
it returns a Result(a, Charlist) (where a is unique to each function)
a Charlist is basically and erlang string
and then is turned to a gleam String
and finally passed to the specified error handler
it's not perfect, I plan to return an element from a gleam enum instead
and you can fully describe the errors in gleam
which is probs better
and decide to crash on some and not others
rn it's not the case
sry i talk in broken-up lines haha
idk if you ever worked with NIF so if you have some questions please ask
I'm actually getting good at its basics
oh and that might come in handy for future people:
https://www.erlang.org/doc/apps/erts/erl_nif.html#description
I'll put it in the readme
damn I thought you could pin messages in your own posts
lowkey waiting for you to be done sending lol idk why
i initially had a very error-light idea with a context pattern do you wanna see
what?
i don't know what u mean
but ig?
(i just don't wanna restart making the whole API once again)
@external(erlang, "graphics_ffi", "init_context")
fn external_init_context() -> Dynamic
@external(erlang, "graphics_ffi", "flush_commands")
fn external_flush_commands(commands: List(Dynamic)) -> Nil
// command type to represent drawing operations
pub type Command {
Line(x1: Int, y1: Int, x2: Int, y2: Int)
Circle(x: Int, y: Int, radius: Int)
Rectangle(x: Int, y: Int, width: Int, height: Int)
SetColor(color: String)
}
// drawing context with command buffer
pub type DrawingContext {
DrawingContext(
ffi_context: Dynamic, // Cached FFI context
commands: List(Command), // Command buffer
draw_line: fn(Int, Int, Int, Int) -> Nil,
draw_circle: fn(Int, Int, Int) -> Nil,
fill_rect: fn(Int, Int, Int, Int) -> Nil,
set_color: fn(String) -> Nil,
// flush function to execute all commands at once
flush: fn() -> Nil
)
}
pub fn new() -> DrawingContext {
// Initialize FFI context once
let ffi_context = external_init_context()
let commands = []
// recursive reference for the context
let ctx = DrawingContext(
ffi_context: ffi_context,
commands: commands,
draw_line: fn(_, _, _, _) { Nil }, // Placeholder
draw_circle: fn(_, _, _) { Nil }, // Placeholder
fill_rect: fn(_, _, _, _) { Nil }, // Placeholder
set_color: fn(_) { Nil }, // Placeholder
flush: fn() { Nil } // Placeholder
)
DrawingContext(
..ctx,
draw_line: fn(x1, y1, x2, y2) {
ctx.commands = [Line(x1, y1, x2, y2), ..ctx.commands]
Nil
},
draw_circle: fn(x, y, radius) {
ctx.commands = [Circle(x, y, radius), ..ctx.commands]
Nil
},
fill_rect: fn(x, y, width, height) {
ctx.commands = [Rectangle(x, y, width, height), ..ctx.commands]
Nil
},
set_color: fn(color) {
ctx.commands = [SetColor(color), ..ctx.commands]
Nil
},
flush: fn() {
// Convert commands to the format needed by FFI
let ffi_commands = convert_commands_for_ffi(ctx.commands)
// Single FFI call to execute all commands
external_flush_commands(ffi_commands)
// Clear command buffer
ctx.commands = []
Nil
}
)
}
// convert commands to FFI format
fn convert_commands_for_ffi(commands: List(Command)) -> List(Dynamic) {
// Implementation would depend on what the FFI expects
}
// Usage example showing reduced FFI calls
pub fn demo_efficient() {
let ctx = new()
// Queue multiple operations
ctx.set_color("red")
ctx.draw_line(0, 0, 100, 100)
ctx.draw_circle(50, 50, 25)
ctx.fill_rect(10, 10, 30, 30)
// Single FFI boundary crossing for all operations
ctx.flush()
}
something like that
batch draws as a type then flush
you might want to put that in a
```rs
```
block
something like that ^^^
obv keeping most of the current impl in ur repo
or not maybe that wont work
obv that proto was thought up b4 looking at gaylib
well i mean
that's invalid gleam
i don't really understand the idea to be honest-
it looks cool
but i don't understand
like
what is ffi_context supposed to be?
the rest I kinda get
including the flush
yeah its more of a pseudo-thing and my b i'm kinda new, stepped straight off the docs
that's not bad
yeah I see
first of all
ALL gleam variables are immutable
so doing ctx.commands = doesn't mean shit
x)
and ffi_context would probably have an opaque type instead of a Dynamic
Dynamics aren't made for what you're trying to achieve
I think
unless you want it to be editable in gleam
usually it represents a dictionnary/tuple or js object depending on the target
to be decoded in gleam
so it wouldn't be done like that
But it's not a bad idea at all
however
technically gaylib already works in a similar fashion
since the draw function is expected to return a list of drawcalls
the "flushing" is implicit you could say
and drawcalls are records
if I wasn't in class i would have suggested to do a call so i can explain properly
ah i see (all 3-5 points)
imma have to look at your current code and gleam itself
there is no context exposed tho since it has no purpose for it i think
even in raylib the context/window in internal
and the informations are exposed through functions
yeah my idea stemmed off of how rust kinda does it where you have one type with an inner table of function that you can call all at once so that the drawing state is immutable during the frame and isn't referenced
ah
it's purely functionnal
types aren't structures
or classes
just records
and records are just fancy tuples
i mean like litteraly
it's like tagged tuples if you will
where the first element of the tuple is an "atom"
well yeah not methods but you can have a function in a record/type
yeah
word
?
yeah i got it dw
yeauh
also idk if you have any info about it on here but do you have any ideas or intent for the js end?
ah
are you apposed to me trying to see if its possible (leaving the gleam code/syntax the same)
y
using C ffi in JS with node or something is not impossible
sure
you could also do wasm
wym
I think you can do C FFI in Node
can you elaborate
yeah rl already has node and quickjs bindings
why would it be silly
it sounds like a cool experiment to me
it'd be no more or less silly than writing these C bindings in erlang
me too thats exactly why i want ti
yeah i get it
use Civet then
it's a typescript superset x')
it's actually a cool project imo
thats still js lol
i want the bad stuff out lol not new stuff in
exactly
thus why im using gleam
we dont do that here.
yeah but i wouldnt have to code in it directly
its like a hazmat suit
I see what you mean
there is nothing 'stack' about js ๐
truuuu
wait
we basically just said that the only thing JS is is a callstack
that's wrong
exactly
which isn't a bad thing in itself
yeah but its limitting
i mean, if the GC was good
the gc isnt even the worst thing but yeah
oh well yeah
ironic enough ive seen the worst stuff from the build tooling
memory leaks during jitting and whatnot
ufff
true
I think JS is a pile of good stuff and of terrible stuff actually
but put on old bad stuff
it's just sad that it's the main tooling for frontend dev
go gc vs js gc isnt even a joke of a contest but i would rather just use rust if im in a position to use go
the best thing about js is its functional syntax more specifically lambdas
yeah but bun is in zig
which slaps
since Microsoft is a corporation, time is money, and rewriting it in Go is probs the best choice for them
and the fact it has a GC doesn't really matter in their case imo
iirc the choice was made because go allowed a pretty close 1:1 representation of the existing TS logic
yes
ik
so it was fast to change
i dont get why wouldnt ms just use c# if dotnet is so good according to them
they had a script do most of the job
x)
I like C# honestly it's a good language for some stuff imo
but it's not in a good state
i just dont like dotnet
i prefer the java language but the dotnet tooling ๐
i agree except the dotnet part
the licensing is all over the place tho (for both)
maven and gradle are
tollerable
i guess dotnet is better in some aspects
terrible
i need a lang to come with tooling tbh
gradle is the worst build system i've ever had the displeasure of using
well i mean groovy is a terrible language lol
gradle is fine to me honestly ive had better experiences with it than dotnet
i use the kotlin dsl
oh use kotlin
No language bashing please!
lol
what if its bad tho
yeah sorry-
/j
I don't mean it like that tho
I get why it exist
there is a cool part I get it
but if it's basically unsed except for gradle there are reasons i'd say
is this a rule my bad
lua is my favorite interpretted lang ๐
i hope not
i guess with lots of work you might be able to do some parts in it
yeah...
Tho mixins would need to be in Java like Kotlin mods
I know quilt has part of it's std also made / wrapped in kotlin if u use it
btw
let's stop
this ain't about gaylib-
alright added a way to configure the window
pub fn main() {
let window =
gl.basic_window(
width: 800,
height: 600,
title: "Gaylib Test",
default: State(gl.Color(255, 0, 0, 255), 0.0),
update:,
draw:,
)
// NEW! gl.configure TM /j
|> gl.configure(
gl.default_config()
|> gl.config_vsync_hint()
|> gl.config_undecorated(),
)
gl.start(window:, update:, draw:)
}
now the config needs to be used in C
done
@external(erlang, "gaylib_ffi", "init_window")
fn init_window(
width: Int,
height: Int,
title: Charlist,
fps: Int,
config_flags: Int,
) -> Result(Nil, Charlist)
``` now `init_window` takes `config_flags` as an Int
and said int is made from the config: Config field of the Window using this big function
/// Converts the boolean based `Config` to raylib window bitwise orred flags.
pub fn config_to_flags(config: Config) -> Int {
case config.vsync_hint {
True -> 0x00000040
False -> 0
}
|> int.bitwise_or(case config.fullscreen_mode {
True -> 0x00000002
False -> 0
})
|> int.bitwise_or(case config.window_resizable {
True -> 0x00000004
False -> 0
})
|> int.bitwise_or(case config.window_undecorated {
True -> 0x00000008
False -> 0
})
|> int.bitwise_or(case config.window_hidden {
True -> 0x00000080
False -> 0
})
|> int.bitwise_or(case config.window_minimized {
True -> 0x00000200
False -> 0
})
|> int.bitwise_or(case config.window_maximized {
True -> 0x00000400
False -> 0
})
|> int.bitwise_or(case config.window_unfocused {
True -> 0x00000800
False -> 0
})
|> int.bitwise_or(case config.window_topmost {
True -> 0x00001000
False -> 0
})
|> int.bitwise_or(case config.window_always_run {
True -> 0x00000100
False -> 0
})
|> int.bitwise_or(case config.window_transparent {
True -> 0x00000010
False -> 0
})
|> int.bitwise_or(case config.window_highdpi {
True -> 0x00002000
False -> 0
})
|> int.bitwise_or(case config.window_mouse_passthrough {
True -> 0x00004000
False -> 0
})
|> int.bitwise_or(case config.borderless_windowed_mode {
True -> 0x00008000
False -> 0
})
|> int.bitwise_or(case config.msaa_4x_hint {
True -> 0x00000020
False -> 0
})
|> int.bitwise_or(case config.interlaced_hint {
True -> 0x00010000
False -> 0
})
}
since it's called once I don't really care that it does lots of FFI calls
what stops someone calling it with 123456789 as an argument instead of using this function?
i mean it's private
it's not supposed to be called by the user
but nothing
just like in C
it's not an excuse btw
i just don't know how to prevent the user from doing it
like I could make a private type with an internal int
but since the init_window function is private I don't think it matters?
there is no way to pass in the int flags manually
so like my answer is the fact it's private and is used only once, where its argument is deduced from a Config, ig
if it's not good enough ig i'd like to know how to make it enough x)
?
Oh yeah then it makes sense! Then the config_to_flags function should be private too, right?
oh it is
i just tested it so made it public
sorry
forgot to mention that
oh wait
no nvm
it can't
since Config is a public type
and it needs to be public too since it's used in other APIs including the Window record
Why don't you make init_window accept Config instead of Int?
because i'm lazy to convert the huge record that is Config to ints in C
ik it would be better
i'll probably do it at some point
You can still do the conversion in Gleam
Just do it privately so users can't make invalid config
Oh I see
you can't pass something invalid to it
mhm
we can call now @gentle harness / go to general vc i'm free
if you want me to explain the codebase
probs better
if you need it that is
Oh I just understood something
Before returning an Error() on errors, I was returning something called a "badarg" since it's what's used in erl_nif's example
and that's an exception
lol
I forgot that was a thing in erlang
new commit dabs
oh shet
too late?
^
nah i can wait, working on sum rn anyways
you can give info tho i'm just not actively looking
oh damn
if you want/can
Sorry for the lack of updates i've been pretty tired lately ':/
No need to apologise :)
did it now 
that's what they all say
lol
tho it's really the case here
it should have been glaylib or raygleam (that also had a typo in the poll, it was typed rayglib)
but raygleam won
but then ollie said that
and i changed Jared (the logo) to have "gaylib" typed on it instead of "raygleam"
looked cool
with the gay pride plag
so I kept it
Wow peak i love raylib maybe I should learn gleam someday
ehhh prob not I like c++
did u just think out loud in chat ๐
What license is this ?
I'm interested in some of the code for erlang (not gleam)
i do love me some gleam though.. but not in this case
sib
c++ and gleam are
- different paradigms
- different use cases
- functionnaly different (gleam is not a compilable language, it runs in a VM, akin to Java in the JVM)
it's like comparing pizza to a hammer
haha you're right :3
I wasn't trying to look for comparisons๐ญ๐ญ I was just saying that I most likely wasn't gonna learn it
gleam does look cool tho
So maybe somedayโ๏ธ
:3
refactored the shitty C code today lol
lol
there!!!
it's all in here now
all clearer
also some new TODOs
1 for better error handling
and the other for signal handling
cuz I noticed that if the NIF raised a signal
the beam just sorta stops
and exits with exit code 0
even with a segfault
(which is not so great lol)
now that I split the C in multiple parts
should I do the same with gaylib.gleam?
like putting all the direct bindings (only types afaik) into gaylib/bindings or gaylib/types
and stuff like that
what do you think?
That's generally considered an antipattern in Gleam. You should group your modules by behaviour, not type of definition
ah
but it's a bindings library so there is no direct behaviour-
the behaviour is in C
i just find it kind of a mess to navigate with absolutely everything in the same place
The functions still have behaviour when you call them though, regardless of implementation language
it's just that there are a ton of types-
I'm not super familiar with the Raylib API, but off the top of my head you could split code for 2d drawing, 3d drawing, audio, etc
linear algebra too
or what raylib calls raymath
but it's mostly linear algebra
makes sense makes sense
and I can't really do as you say
since i'm not doing function to function bindings
Like, for instance
drawing requires you to create a "Drawcall" from one of its constructors (like Rectangle, Background, etc...)
and it's a single type
i can't just split it can I?
Those sound like pretty tightly coupled pieces of a code, so you wouldn't want to split those
yeah I see
Really you would split it if you have several distinct sections of the library that don't interact and can each function on their own
well appart linear algebra everything needs each other directly
For example, looking at the library, I could imagine you splitting it into a config module, a maths module and then the main module for actually drawing to the screen
It's a distinct piece of code which can exist independently of the rest of the code
no it can't?
it needs types from the main gaylib module?
like Window
at least part of it
Just looks like booleans to me
Well yes, that would be in the main module
i'm not going to make a module for just a type?
But all these functions
i guess
Or you keep it as one module
You were the one asking for ideas on how to split it, so I gave you some
yes yes yes
sorry
i'm just not sure i follow
but okay
there
did you mean smth like that?
Yeah something like that
You can play around with it to see if you think it's an improvement over the old api
i think it is but also not cuz well
if you look in testing.gleam
i found it clearer to directly rename them
guys, I think I can't use this library, I'm too straight here... no wait, yea, I can use it
also
ik it's funny but
gl does really sound like other.... open source library
open
you could make it half rainbow, half pink
but the lib looks cool, gonna test it more later
the "gay" is using the pride flag
there is nothing much to test at the moment lol
only two "draw calls" are implemented
clearing the background and drawing the FPS count
you can use keydown "events" too
and close the window
hmmmm, time to see if I can make a box move with only a background
technically, if I have 2 apps running
hmmmmmmmmm
time to be stupid
lol
sry, it's getting late here, it's perfect time for stupid ideas
Should we split the gaylib module into submodules
3
4
2
No
1134926343235194933
squirtle
That's why you usually want to make a branch for experimental changes
is that a challenge or a request?
:d
you decide
i did not
only the C is split into multiple C files
cuz it was a mess to manage
just did some refactoring
i am planning on finally porting more draw functions
but to do that
i decided to split drawcalls handling into its own function
@scenic mulch when did u plan to contribute btw?
Oh. Gotta finish this tui framework. Feel free to go ahead and do your own thing.
I was hoping over November
okayyy