How to enable GLSL extensions like `OES_standard_derivatives`?
subblue opened this issue · comments
Feature
How to enable GLSL extensions like OES_standard_derivatives
?
library version
├── gl-react@3.15.0
└── gl-react-dom@3.15.0
Expected behavior
I tried using the onContextCreate
function of the gl-react-dom Surface which exposes the gl
instance to enable the extension via gl.getExtension('OES_standard_derivatives')
Actual behavior
Assigning a custom function to onContextCreate actually silently prevents any rendering from happening!
Is there another way to enable additional WebGL extensions?
Thx
Hi @subblue
Had the same issue as yourself.
This worked however:
const gl = ref.glView.canvas.getContext('webgl');
gl.getExtension('OES_standard_derivatives');
With "ref" being the Surface element's ref.
Thanks @brysonandrew, good to know that works.
In the end I found a way to do what I needed without the derivatives extension, but good to know for the future 👍
Very welcome @subblue sir. Your question helped me find the solution.
BTW the above works with gl-react-dom
For a Surface from gl-react-expo
, onCreateContext
will work.
@brysonandrew Thanks for the tip, but where exactly do you run this code?
I've tried in componentDidMount()
and the surfaces preLoad()
callback but I'm still getting the error that the extension is not supported.
@efirdc You're welcome, yes, componentDidMount.
Here is a gist of the whole component
Do you have something like this is your shader -
#ifdef GL_OES_standard_derivatives
#extension GL_OES_standard_derivatives : enable
#endif
?