render_target not working in wgsl
minimal reproduction here: https://github.com/ddmills/quads-gl-wasm
use macroquad::prelude::*;
fn window_conf() -> Conf {
Conf::default()
}
#[macroquad::main(window_conf)]
async fn main() {
println!("Hello, world!");
// [warning] "Missed function: glCheckFramebufferStatus"
// [panic] .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/miniquad-0.4.8/src/graphics/gl.rs, line: 1144, column: 21
render_target(100, 100);
loop {
draw_fps();
next_frame().await;
}
}
[warning] "Missed function: glCheckFramebufferStatus"
[panic] .cargo/registry/src/index.crates.io-1949cf8c6b5b557f/miniquad-0.4.8/src/graphics/gl.rs, line: 1144, column: 21
Looks like render target support needs a few more functions than just glCheckFramebufferStatus - I needed to add the following to mq_js_bundle.js to make the wasm build work with render targets:
var importObject = {
env: {
// Begin lines to add
glCheckFramebufferStatus: function (e) {
return gl.checkFramebufferStatus(e);
},
glReadBuffer: function (e) {
gl.readBuffer(e);
},
glBlitFramebuffer: function (
srcX0,
srcY0,
srcX1,
srcY1,
dstX0,
dstY0,
dstX1,
dstY1,
mask,
filter
) {
gl.blitFramebuffer(
srcX0,
srcY0,
srcX1,
srcY1,
dstX0,
dstY0,
dstX1,
dstY1,
mask,
filter
);
},
// End lines to add
console_debug: function (ptr) {
console.debug(UTF8ToString(ptr));
},
With that in place, the lighting prototype for my noita-like works on the wasm build.
For the benefit of others (/future me), here's an easy to repro example: copy-paste examples/post_processing.rs, update the provided index.html to load the patched mq_js_bundle.js, serve it up some way (e.g. python -m http.server) and then it'll run in the browser:
Looks like render target support needs a few more functions than just
glCheckFramebufferStatus- I needed to add the following tomq_js_bundle.jsto make the wasm build work with render targets:var importObject = { env: { // Begin lines to add glCheckFramebufferStatus: function (e) { return gl.checkFramebufferStatus(e); }, glReadBuffer: function (e) { gl.readBuffer(e); }, glBlitFramebuffer: function ( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter ) { gl.blitFramebuffer( srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter ); }, // End lines to add console_debug: function (ptr) { console.debug(UTF8ToString(ptr)); },With that in place, the lighting prototype for my noita-like works on the wasm build.
For the benefit of others (/future me), here's an easy to repro example: copy-paste
examples/post_processing.rs, update the provided index.html to load the patched mq_js_bundle.js, serve it up some way (e.g. python -m http.server) and then it'll run in the browser:
Thanks for your code. Thanks to you, I was finally able to fix this bug.
