Looking for examples of GLView.createContextAsync() in expo-gl

Is there a way to pass the context created via GLView.createContextAsync() to the GLView component instead of GLVIew’s onContextCreate?

I was looking at GLView.createContextAsync() and the description sounds exactly what I am looking for, but I have failed to find any example or steps for referencing.

Thank you.

createContextAsync is creating headless context, useful if you want to do some animation without displaying it and pass it somewhere else. If you want to display sth use onContextCreate prop in GLView.

The only difference between those 2 functions is that one is backed by a view, so if you could pass gl object from createContextAsync to the GLView it would be equivalent of onContextCreate

Thanks for the notes,
“It’s useful for headless rendering or in case you want to keep just one context per application and share it between multiple components.”
The latter usecase is what I am looking for, The point I am currently stucks is I am not sure how do I do with the context after calling createContextAsync in order to render the scene.

t’s useful for headless rendering or in case you want to keep just one context per application and share it between multiple components

I’m not sure from where that quote is but it’s not really true, it’s intended only for headless rendering, if you want to display the result you need somehow snapshot every frame and display it in other places. It should double from the native code but not from js.

Example use from expo repo

One other use case I used headless context in the past is to render animation into an mp4 recording, (but this was mostly native code).

Good to know, thank you very much.
The quote is from the official documentation of the latest version of expo-gl. So there might be something to update.

however it may require you to take a snapshot in order to present its results

next sentence in the same docs

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.