I would love to use SDL directly in my hashlink program. My needs are very minimal so I don’t want to involve the whole Heaps in it. I just need to be able to render a surface, capture some user input, play some PCM audio, basic stuff. I struggle to figure out how to actually do it due to lack of any documentation or examples. Looks like the only resource of learning the ways of interacting with SDL is Heaps source code but it’s also not an easy task to parse though all the abstractions involved there.
Any suggestion? Maybe somebody has already made some simple SDL applications using only the bare Hashlink?
So far I managed to create a window and an event catching loop but not much else. I see there are methods to create Surfaces but can’t find anything on how to actually render them.
I also tried to get a use of the OpenGL context and to at least see the clearColor
on my screen but no luck as well.
Sdl.init();
final window = new Window('Window', 512, 512);
window.renderTo();
GL.init();
GL.clearColor(1.0, 0.0, 0.0, 1.0);
final pixels = Bytes.alloc(512 * 512 * 4);
for (n in 0...pixels.length) {
pixels.set(n, Math.floor(Math.random() * 256));
}
final surf = Surface.fromBGRA(pixels, 512, 512);
while (Sdl.processEvents((event) -> {
switch (event.type) {
case Quit:
return false;
case _:
}
return true;
})) {
GL.clear(GL.COLOR_BUFFER_BIT);
Sdl.delay(Std.int(1000 / 60));
}
Sdl.quit();