node-sdl
node-sdl copied to clipboard
Bun support
I tried running the base examples with bun and got segmentation errors when calling window.render
.
I suspect it's related to differences in how the buffer is handled.
If there is a way around this/workaround that'd be great!
@Thunderducky I'd like to support bun eventually, but right now their support for napi modules is not even finished (https://github.com/oven-sh/bun/issues/158) and I am encountering too many weird bugs when trying to run the examples. I'd suggest leaving the issue open and I'll revisit it as bun becomes more stable in the future.
Thank you! Love the library
I could run a small example with bun
// index.js
import sdl from '@kmamal/sdl'
// Setup
const window = sdl.video.createWindow({ title: "Canvas" })
window.setFullscreen(true);
const { pixelWidth: width, pixelHeight: height } = window
const buffer = Buffer.alloc(width * height * 4).fill(0);
for (let n = 0; n < buffer.length; n += 4) {
const i = Math.floor(n / (4 * width));
const j = Math.floor((n / 4) % width);
const x = j;
const y = height - 1 - i;
buffer[n] = Math.min(255, (x / width) * 255);
buffer[n + 1] = Math.min(255, (y / height) * 255);
buffer[n + 2] = 0;
buffer[n + 3] = 255;
}
console.log("debug ", buffer)
window.render(width, height, width * 4, 'rgba32', buffer);
Then ran bun index.js
, with bun
version 1.0.28
.
Great lib btw, thank you @kmamal
Oh interesting, time to have another look then.
Just a note here about using bun
to install node-sdl
:
https://github.com/oven-sh/bun/issues/9220
One needs to add node-sdl
as a trustedDependencies
, for bun to install.
@Thunderducky @kmamal
Linking this issue so I can track it easier: https://github.com/oven-sh/bun/issues/9743