How to use the expo-gl.GLView.createContextAsync function in expo-gl

To help you get started, we’ve selected a few expo-gl examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github tensorflow / tfjs / tfjs-react-native / src / platform_react_native.ts View on Github external
tf.registerBackend('rn-webgl', async () => {
      const glContext = await GLView.createContextAsync();

      // ExpoGl getBufferSubData is not implemented yet (throws an exception).
      tf.ENV.set('WEBGL_BUFFER_SUPPORTED', false);

      //
      // Mock extension support for EXT_color_buffer_float and
      // EXT_color_buffer_half_float on the expo-gl context object.
      // In react native we do not have to get a handle to the extension
      // in order to use the functionality of that extension on the device.
      //
      // This code block makes iOS and Android devices pass the extension checks
      // used in core. After those are done core will actually test whether
      // we can render/download float or half float textures.
      //
      // We can remove this block once we upstream checking for these
      // extensions in expo.
github gpujs / expo-gl / kernel.js View on Github external
const { WebGL2Kernel } = require('gpu.js/src/backend/web-gl2/kernel');
const { GLView } = require('expo-gl');

let isSupported = null;
let testContext = null;
let testCanvas = {}; // not yet supported
let testExtensions = null;
let features = null;

GLView.createContextAsync()
  .then(context => testContext = context);

class ExpoGLKernel extends WebGL2Kernel {
  static get isSupported() {
    if (isSupported !== null) {
      return isSupported;
    }
    this.setupFeatureChecks();
    isSupported = this.isContextMatch(testContext);
    return isSupported;
  }

  static get testContext() {
    return testContext;
  }
github expo / expo / apps / native-component-list / src / screens / GL / GLHeadlessRenderingScreen.tsx View on Github external
in vec2 textureCoord;
out vec4 fragColor;

void main() {
  vec4 textureColor = texture(inputImageTexture, textureCoord);
  vec3 rgb = (textureColor.rgb - vec3(0.5)) * contrast + vec3(0.5);

  fragColor = vec4(rgb, textureColor.a);
}`;

// location to contrast uniform
let contrastLocation: WebGLUniformLocation | null;

// create and prepare GL context
const glPromise = GLView.createContextAsync().then(async gl => {
  // Compile vertex and fragment shaders
  const vertShader = gl.createShader(gl.VERTEX_SHADER)!;
  gl.shaderSource(vertShader, vertShaderSource);
  gl.compileShader(vertShader);

  const fragShader = gl.createShader(gl.FRAGMENT_SHADER)!;
  gl.shaderSource(fragShader, fragShaderSource);
  gl.compileShader(fragShader);

  // Link, use program, save and enable attributes
  const program = gl.createProgram()!;
  gl.attachShader(program, vertShader);
  gl.attachShader(program, fragShader);
  gl.linkProgram(program);
  gl.validateProgram(program);

expo-gl

Provides GLView that acts as OpenGL ES render target and gives GL context object implementing WebGL 2.0 specification.

MIT
Latest version published 24 days ago

Package Health Score

90 / 100
Full package analysis