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

get_parameter_framebuffer panics when the current framebuffer is the default one #334

Open
AlexandruIca opened this issue Jan 7, 2025 · 4 comments

Comments

@AlexandruIca
Copy link

So I noticed that glow tracks framebuffers created by the user, and then one is able to call get_parameter_framebuffer(glow::DRAWING_FRAMEBUFFER_BINDING) to get the framebuffer currently in use.

But it only tracks framebuffers created by create_framebuffer. This is a problem if I call get_parameter_framebuffer without creating a framebuffer myself: it will return the default one, which is perfectly valid, but glow panics because it doesn't have it in its registry. It's easy to work around it though.

IIRC this should only happen on the WebGL back-end.

@AlexandruIca
Copy link
Author

I also notice that if I call create_framebuffer, then bind it, and then do get_parameter(glow::DRAWING_FRAMEBUFFER_BINDING), I always get 0:

let fbo = gl.get_parameter_i32(glow::DRAW_FRAMEBUFFER_BINDING);
let current_framebuffer = gl.get_parameter_framebuffer(glow::DRAW_FRAMEBUFFER_BINDING);

let framebuffer = gl.create_framebuffer()?;
gl.bind_framebuffer(glow::FRAMEBUFFER, Some(framebuffer));
let new_fbo = gl.get_parameter_i32(glow::DRAW_FRAMEBUFFER_BINDING);

(Ignoring error handling for clarity.)

fbo and new_fbo are always both 0, even if I try to create multiple framebuffers. Unless I'm misunderstanding the WebGL/OpenGL API, I'm pretty sure this shouldn't happen. I mean if fbo is 0 then glow panics, but let's pretend I have previously created at least another framebuffer.

@sanbox-irl
Copy link

Also running into this issue unfortunately!

@grovesNL
Copy link
Owner

@AlexandruIca I think we could fix the first issue by tracking the default framebuffer on the WebGL backend when we're creating the context initially.

I'm not sure about the second issue, those should basically be raw OpenGL calls unless there's something else going on here.

@AlexandruIca
Copy link
Author

Unfortunately I had integrated it directly in a pretty complex project so I don't have a reproducible example on hand, but it was only happening on the WebGL back-end. I don't think the calls themselves are a problem, I think it's a problem related to tracking resources (maybe the key comparison isn't right?). Though I haven't looked in detail into it.

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

No branches or pull requests

3 participants