GWT build issue with Pixmap.createFromFrameBuffer
Issue details
It isn't possible to compile following code on GWT (required for taking screenshots):
Pixmap pixmap = Pixmap.createFromFrameBuffer(0, 0, Gdx.graphics.getBackBufferWidth(), Gdx.graphics.getBackBufferHeight());
ByteBuffer pixels = pixmap.getPixels();
It gives following error when compiling: Type mismatch: cannot convert from Buffer to ByteBuffer
And seems to be caused by this line, with IDE showing the line as syntax error.
It shows also this and this line as syntax error with message Cannot resolve symbol 'pixmap', but I have no idea why and it isn't causing any problems for me (most likely because I am not calling those functions).
Version of libGDX and/or relevant dependencies
1.11.0
Please select the affected platforms
- [ ] Android
- [ ] iOS
- [x] HTML/GWT
- [ ] Windows
- [ ] Linux
- [ ] macOS
The issue is actually with getPixels(), but it's... complicated. On all platforms except GWT, getPixels() returns a ByteBuffer. On GWT, it returns a Buffer, backed by an IntBuffer. There's some reason for this relating to how WebGL works, but I don't know the specifics. GWT has to use different sources for Pixmap and its backing data, because desktop and Android (plus more, probably) can use C++ code with JNI, while GWT cannot, and so has to use JS code to implement Pixmap operations. You can see the relevant sources used by GWT here. Ideally, we would have some way of converting the IntBuffer of pixels to a ByteBuffer like all other platforms use, but it's been a challenge so far.
Same issue. I'm using GifDecoder.