Emscripten: WebGL: INVALID_ENUM: readPixels: invalid format

When using vtkOpenGLHardwareSelector one gets two errors

WebGL: INVALID_ENUM: readPixels: invalid format
and
GL_INVALID_OPERATION: Invalid format and type combination.

The errors arise from the javascript call

GLctx.readPixels(x, y, width, height, format, type, heap, pixels >> heapAccessShiftForWebGLHeap(heap))

in the generated code. This is triggered with the call to

vtkOpenGLHardwareSelector * h_sel = //...
// ...
h_sel->CaptureBuffers();

Hence the same error occurs with PickProp on a renderer

vtkRenderer *r = // ...
// ...
r->PickProp(x, y);

The same behavior is observed with vtkOpenGLRenderer.

Please note that everything was compiled in compliance with instructions on the Examples page, and that other features work correctly.

Might anyone offer some insight into what might be happening? The CaptureBuffers method of vtkHardwareSelector invokes render_window->Render() under the hood, but this method seems to work properly outside of the above.

I also encountered the same problem, Mr. Ziga Sajovic, do you have an answer at last?

Any update. I am also getting same error. Thanks

@Sebastien_Jourdain I am developing app where user need to pick actor. However it appears picking operation is not working in web. Can you please suggest any workaround.

Thanks a lot.

vtk.js support actor picking. I think the issue with VTK/wasm is that the code from the GL/C++ is not compatible with its webgl counterpart.

Thanks @Sebastien_Jourdain for quick response. Yes I am working on both VTK.js and VTK/wasm. Picking operations are working fine in VTK.js. But performance of VTK.js decreases as number of actors increases. In my case I have few thousand of actors. On other hand VTK/wasm work like a charm. I tested with 3000 actors and it worked smoothly. However I was disappointed to see picking operation is not working in otherwise a very good product. From your comment it appears to be changing few libraries.

Would it be possible for you or somebody to guide me how to fix this? I shall be very thankful.

To fix that part, the GL code will need to have some ifdef pass specific so the webgl conversion can actually work. But unfortunately, I don’t know who can help right now on that topic. @thewtex would you know?

@thewtex I noticed there is already a issue for this.

Can you please guide in this regard how to address?

Thanks