Skip to content

Commit

Permalink
docs: update example
Browse files Browse the repository at this point in the history
  • Loading branch information
mmmurray committed Feb 19, 2020
1 parent 7ee71a9 commit 71854f0
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,16 @@ const positionBuffer = gl.createAttributeBuffer('vec2', [0, 1, 1, -1, -1, -1])
const program = gl.createProgram({
attributes: { position: 'vec2' },
uniforms: {},
varying: {},
vertexShaderSource: ({ attributes }) => `
varying: { color: 'vec2' },
vertexShaderSource: ({ attributes, varying }) => `
void main() {
gl_Position = vec4(${attributes.position}.xy, 0, 1);
${varying.color} = (gl_Position.xy + vec2(1,1)) / vec2(2,2);
}
`,
fragmentShaderSource: () => `
fragmentShaderSource: ({ varying }) => `
void main() {
gl_FragColor = vec4(0, 1, 0, 1);
gl_FragColor = vec4(0, ${varying.color}, 1);
}
`,
})
Expand All @@ -49,3 +50,5 @@ program.drawTriangles({
attributeBuffers: { position: positionBuffer },
})
```

[![Edit triangular-example-1](https://codesandbox.io/static/img/play-codesandbox.svg)](https://codesandbox.io/s/triangular-example-1-d77h6?fontsize=14&hidenavigation=1&theme=dark)

0 comments on commit 71854f0

Please sign in to comment.