Skip to content

Instantly share code, notes, and snippets.

@vorg
Created September 22, 2016 16:39
Show Gist options
  • Save vorg/8ef68bc8fa769c21d3d97ea753147029 to your computer and use it in GitHub Desktop.
Save vorg/8ef68bc8fa769c21d3d97ea753147029 to your computer and use it in GitHub Desktop.
regl vertex attribute size dependency
var regl = require('regl')()
regl.clear({
color: [0, 0, 0, 1],
depth: 1
})
// In regl, draw operations are specified declaratively using. Each JSON
// command is a complete description of all state. This removes the need to
// .bind() things like buffers or shaders. All the boilerplate of setting up
// and tearing down state is automated.
regl({
// In a draw call, we can pass the shader source code to regl
frag: `
precision mediump float;
uniform vec4 color;
void main () {
gl_FragColor = color;
}`,
vert: `
precision mediump float;
attribute vec2 position;
void main () {
gl_Position = vec4(position.xy, 0.0, 1.0);
}`,
attributes: {
position: regl.buffer({
size: 2,
data: [
[-1, 0],
[0, -1],
[1, 1]
]
})
},
uniforms: {
color: [1, 0, 0, 1]
},
count: 3
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment