Last active
June 3, 2018 19:56
-
-
Save ndugger/a036073d645d8071aac49112a4b6335f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import { Renderer, Shader } from 'picasso'; | |
| const canvas = document.getElementById('canvas'); | |
| const fragment = new Shader('fragment', ` | |
| precision mediump float; | |
| out vec4 color; | |
| void main () { | |
| color = vec4(1.0, 0.0, 0.5, 1.0); | |
| } | |
| `); | |
| const vertex = new Shader('vertex', ` | |
| in vec2 position; | |
| uniform vec2 resolution; | |
| void main () { | |
| vec2 one = position / resolution; | |
| vec2 two = one * 2.0; | |
| vec2 clip = two - 1.0; | |
| gl_Position = vec4(clip * vec2(1, -1), 0, 1); | |
| } | |
| `); | |
| const renderer = new Renderer(canvas); | |
| renderer.initialize('default', [ fragment, vertex ]); | |
| renderer.setAttribute('position', [ | |
| 32, 32, | |
| 64, 32, | |
| 32, 64, | |
| 32, 64, | |
| 64, 32, | |
| 64, 64, | |
| ]); | |
| renderer.setUniform('resolution', [ canvas.width, canvas.height ]); | |
| renderer.draw(6); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment