https://kotlinlang.org logo
#compose-android
Title
# compose-android
x

xoangon

11/02/2023, 8:12 AM
Hi there guys! I have a design use case that seems like a perfect fit to use a shader with
AGSL
. I have it defined and working, but the required API level 33 for the
RuntimeShader
is a big limitation. Is there any workaround? Are there any plans for back-porting shaders to previous versions? @romainguy
s

Stylianos Gakis

11/02/2023, 11:34 AM
I don't think that'd be possible. Otherwise we'd have things like blur etc working on old API versions
👍 1
🫠 1
h

Hristijan

11/02/2023, 1:13 PM
It's not possible for older versions as it's added in the OS itself
s

Sergey Y.

11/02/2023, 2:11 PM
OpenGL gives you the ability to control every pixel and design your shaders, basically on any Android version supported by JP Compose. Just a heads-up, to ensure smooth integration with the rest of Compose UI, you'll have to create an OpenGL backend for Compose. But, I'm quite confident it'll add only an extra layer of enjoyment to your development process. 😄
x

xoangon

11/02/2023, 2:16 PM
That's interesting @Sergey Y., do you have any documentation on how to use OpenGL on Android?
s

Sergey Y.

11/02/2023, 2:21 PM
On Android you need to use OpenGL ES, which is essentially a variant of regular OpenGL with some minor differences. To learn how to program with OpenGL, you can utilize most of the existing literature available for OpenGL 3.x. To get started with Android development, you can check this out: https://developer.android.com/develop/ui/views/graphics/opengl
May your journey into the world of Graphics Programming be filled with creativity, discovery, and endless inspiration. 🎉
take what I'm saying with a pinch of salt 😅
😂 1
r

romainguy

11/02/2023, 2:33 PM
Note that while you can use Open GL directly, you won't be able to apply shaders to Composables without first capturing them into bitmaps/textures.
❤️ 1
We could backport RenderEffect as-is but it would require bundling Skia (large binary size) and it would break View/Compose interop
❤️ 1
s

Sergey Y.

11/02/2023, 2:38 PM
What I wanted to say. To implement OpenGL abstractions at Compose foundation level, and make special build of Compose OpenGL. Currently, I'm trying to do it, for fun 😄
r

romainguy

11/02/2023, 2:39 PM
Having done this myself for Android 3.0 to Abdroid P, don't :)
🚀 3
🤣 3
s

Sergey Y.

11/02/2023, 2:39 PM
But it is fun
r

romainguy

11/02/2023, 2:39 PM
You can "just" use Skiko instead like Jetbrains does for Desktop and iOS
x

xoangon

11/02/2023, 2:39 PM
Oh, I wasn't aware of the interop limitations associated with RenderEffect. As much as I'd love to go deeper in this knowledge, any of these approaches is rather overengineering for my use case. This being my first time using AGSL, I can say that it's being a really fun experience 🙂 (Of course, I haven't gone to the real "fun" that you're saying @Sergey Y. 😂 )
2 Views