SHARE
TWEET

Untitled

a guest Jul 16th, 2019 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // vertex setup
  2. const buffer = gl.createBuffer();
  3. const vertices = new Float32Array([
  4.     1,  -1, -1,     1,   1.3, 1.5,  1,
  5.     1,  -1,  1,     1.3, 1,   1.5,  1,
  6.     0,   1,  0,     1,   1,   1.75, 1
  7. ]);
  8.  
  9. gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
  10. gl.bufferData(gl.ARRAY_BUFFER, vertices, gl.STATIC_DRAW);
  11.  
  12. const length = vertices.length / 7;
  13. const mode = gl.TRIANGLE_STRIP;
  14.  
  15. return {buffer, length, mode};
  16.      
  17. // render frame
  18. gl.bindBuffer(gl.ARRAY_BUFFER, shape.buffer);
  19. gl.vertexAttribPointer(attribs.position, 3, gl.FLOAT, false, 28, 0);
  20. gl.vertexAttribPointer(attribs.color, 4, gl.FLOAT, false, 28, 12);
  21. gl.enableVertexAttribArray(attribs.position);
  22. gl.enableVertexAttribArray(attribs.color);
  23. gl.useProgram(programs.colored);
  24. gl.uniformMatrix4fv(uniforms.projection, false, projection);
  25. gl.uniformMatrix4fv(uniforms.modelView, false, modelView);
  26. gl.drawArrays(shape.mode, 0, shape.length);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top