q5js / q5.js

A sequel to p5.js that's smaller, faster, and optimized for interactive art!
https://q5js.org
GNU Lesser General Public License v3.0
89 stars 7 forks source link

react-native support #54

Closed qalqi closed 3 weeks ago

qalqi commented 3 weeks ago

Can you please provide support for react native. react native is vibrant community vith 700,000+ developers. Attaching expo-processing vhich is about 6 years old! I am a JavaScript/TypeScript developer and can add support for React Native if you provide guidance.

quinton-ashley commented 3 weeks ago

@qalqi I would like for q5 to support react-native. What would need to be done?

qalqi commented 3 weeks ago

Thanks alot for considering react native. In react native we don't have any dom to attach the canvas. Instead there is GlView. Any WebGL-supporting library that expects a WebGLRenderingContext could be used. https://docs.expo.dev/versions/latest/sdk/gl-view/

import { GLView } from 'expo-gl';

Using this GLView we need to polyfill the renderer similar to https://github.com/expo/expo/blob/main/packages%2Fexpo-processing%2Findex.js

On Mon, 8 Jul, 2024, 8:16 am Quinton Ashley, @.***> wrote:

@qalqi https://github.com/qalqi I would like for q5 to support react-native. What would need to be done?

— Reply to this email directly, view it on GitHub https://github.com/q5js/q5.js/issues/54#issuecomment-2212876659, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANS2OHRW7UZG2O6LWI6P6TZLH4RLAVCNFSM6AAAAABKPRNAYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJSHA3TMNRVHE . You are receiving this because you were mentioned.Message ID: <q5js/q5. @.***>

quinton-ashley commented 3 weeks ago

@qalqi That won't be possible since q5 doesn't support webgl, though webgpu rendering will be supported in the future.

I think the GLView is probably just a wrapper around a webview internally.

Perhaps you could just use q5 in a webview then? https://docs.expo.dev/versions/latest/sdk/webview/

qalqi commented 3 weeks ago

expo-gl provides a View that acts as an OpenGL ES render target, useful for rendering 2D and 3D graphics. 

expo-gl uses same webgpl APIs definitions and under the hood maps opengl ES render for Android, iPhone and webgpl for web.

WebView is not a great developer experience and prone to many errors. For e.g in WebView, async libraries and calls fail sometimes and need custom webpack bundling etc..

Adding expo-gl support to q5.js would be 50 lines of code and most about polyfills. If you add this support, react native community can greatly benefit with p5play and q5 in making beautiful react native based games.

quinton-ashley commented 3 weeks ago

50 lines of code and most about polyfills

Thank you for the clarification but if it's so easy you're welcome to try implementing it yourself.

Since OpenGL ES is 20 years old though, personally I'm more interested in adding support for WebGPU.

I'm closing this issue but you can continue to comment on your progress and lmk if you have any questions.

qalqi commented 3 weeks ago

Thanks! I will try and will share my progress

On Mon, 8 Jul, 2024, 8:59 pm Quinton Ashley, @.***> wrote:

50 lines of code and most about polyfills

Thank you for the clarification but if it's so easy you're welcome to try implementing it yourself.

Since OpenGL ES is 20 years old though, personally I'm more interested in adding support for WebGPU.

I'm closing this issue but you can continue to comment on your progress and lmk if you have any questions.

— Reply to this email directly, view it on GitHub https://github.com/q5js/q5.js/issues/54#issuecomment-2214446772, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANS2ODO7GR2BVOY5K7LLHDZLKV43AVCNFSM6AAAAABKPRNAYSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDEMJUGQ2DMNZXGI . You are receiving this because you were mentioned.Message ID: <q5js/q5. @.***>