rnc-archive / react-native-webgl

DEPRECATED: use expo-gl – Implements WebGL for react-native
295 stars 73 forks source link

Preloading textures #58

Closed AlexDM0 closed 6 years ago

AlexDM0 commented 6 years ago

Hi,

I'd like to have more control on when exactly images are preloaded for textures. I use webGL to make a picture black&white is the user is not present. This image is on the background of a view. When the view animates in, it takes a second for the texture to load. How can I preload this?

I tried to implement a preloader but I can't seem to do this without a contextId. Can I make a standalone preloader that manages which textures are kept in memory and clean them accordingly? Any fragment shader requiring them is then just synchronous.

Cheers

gre commented 6 years ago

mmh yeah you should be able to do this actually, for instance, gl-react uses these libraries that implement various texture loaders https://github.com/gre/webgltexture-loader/tree/master/packages

and for instance https://github.com/gre/webgltexture-loader/blob/master/packages/webgltexture-loader-react-native-imagesource/src/ImageSourceTextureLoader.js

AlexDM0 commented 6 years ago

Thanks! I'll give it a go. You can close this issue if you want.

AlexDM0 commented 6 years ago

Hi, I can't seem to find how I use the webgltexture-loader without a gl context. I have a view which has the webGL context but before this view is loaded, I want to preload the textures. This means the onContextCreate method has not been called yet.

Is there an example on this?

robertjuh commented 6 years ago

This is exactly what i'm trying as well.

robertjuh commented 6 years ago

can this be reopened because we cant use textureloaders without a RNGL

and we cant directly make THREE.Textures without the DOM. (Tried to fill it with a native react Image but it's still different from a HTML image and thus shows black textures).