Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bun support #41

Open
Thunderducky opened this issue Sep 8, 2023 · 6 comments
Open

Bun support #41

Thunderducky opened this issue Sep 8, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@Thunderducky
Copy link

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!

@kmamal
Copy link
Owner

kmamal commented Sep 9, 2023

@Thunderducky I'd like to support bun eventually, but right now their support for napi modules is not even finished (oven-sh/bun#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.

@kmamal kmamal added the enhancement New feature or request label Sep 9, 2023
@Thunderducky
Copy link
Author

Thank you! Love the library

@pedroth
Copy link

pedroth commented Mar 3, 2024

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

@kmamal
Copy link
Owner

kmamal commented Mar 3, 2024

Oh interesting, time to have another look then.

@pedroth
Copy link

pedroth commented Mar 5, 2024

Just a note here about using bun to install node-sdl:

oven-sh/bun#9220

One needs to add node-sdl as a trustedDependencies, for bun to install.

@Thunderducky @kmamal

@kmamal
Copy link
Owner

kmamal commented Mar 30, 2024

Linking this issue so I can track it easier: oven-sh/bun#9743

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants