Lines Matching refs:gl
3 import { ExpoWebGLRenderingContext, GLView } from 'expo-gl';
8 async function onContextCreate(gl: ExpoWebGLRenderingContext) {
9 const vert = gl.createShader(gl.VERTEX_SHADER)!;
10 gl.shaderSource(
21 gl.compileShader(vert);
22 const frag = gl.createShader(gl.FRAGMENT_SHADER)!;
23 gl.shaderSource(
33 gl.compileShader(frag);
35 const program = gl.createProgram()!;
36 gl.attachShader(program, vert);
37 gl.attachShader(program, frag);
38 gl.linkProgram(program);
39 gl.useProgram(program);
41 const buffer = gl.createBuffer();
42 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
44 gl.bufferData(gl.ARRAY_BUFFER, verts, gl.STATIC_DRAW);
45 const positionAttrib = gl.getAttribLocation(program, 'position');
46 gl.enableVertexAttribArray(positionAttrib);
47 gl.vertexAttribPointer(positionAttrib, 2, gl.FLOAT, false, 0, 0);
51 const texture = gl.createTexture();
52 gl.activeTexture(gl.TEXTURE0);
53 gl.bindTexture(gl.TEXTURE_2D, texture);
54 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
55 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
56 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, asset as any);
57 gl.uniform1i(gl.getUniformLocation(program, 'texture'), 0);
58 gl.clearColor(0, 0, 1, 1);
60 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
61 gl.drawArrays(gl.TRIANGLES, 0, verts.length / 2);
62 gl.endFrameEXP();
143 <Text>no gl view</Text>