expo-gl compressed 2D texture support
Henry Allen
I am porting a Three.js application to React Native, and I am using expo's GLView for WebGL support. While GLView supports most of my use cases, it is missing support for the
compressedTexImage2D
and compressedTexSubImage2D
WebGL functions, which are required for loading compressed textures. See: https://github.com/expo/expo/blob/10c6a97d115d3f3bcca901f72bd7560d3ccfa0f7/packages/expo-gl/common/EXWebGLMethods.cpp#L600-L602. It should be possible to support the following WebGL function signatures when WebGL2 is supported:
- compressedTexImage2D(target, level, internalformat, width, height, border, srcData)
- compressedTexSubImage2D(target, level, xoffset, yoffset, width, height, format, srcData)
These are the function signatures used in the Three.js compressed texture class, though it may be possible to add support for the other function signatures.
reference:
- https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/compressedTexImage2D
- https://github.com/search?q=repo%3Amrdoob%2Fthree.js%20compressedTexImage2D&type=code
I have a branch adding support for the WEBGL_compressed_texture_etc for the above function signatures, and I would be happy to open a PR to expo if you want to accept this feature. You can view the branch here: https://github.com/expo/expo/compare/main...hmallen99:expo-gl/add-compressed-texture-support?expand=1.
Supporting WEBGL_compressed_texture_astc and WEBGL_compressed_texture_pvrtc would not be too much more work, and I believe it could piggyback off my branch.