Skip to content

Instantly share code, notes, and snippets.

@vlandham
Last active May 27, 2017 22:54
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save vlandham/315500b61d28eb0bba8959ca66a68e37 to your computer and use it in GitHub Desktop.
regl triangle in a loop
<!DOCTYPE html>
<title>Simple regl Triangle Example in a loop </title>
<body>
<script src="https://npmcdn.com/regl@1.3.0/dist/regl.js"></script>
<script src="index.js"></script>
</body>
// In development, you would probably import/require regl
// const regl = require('regl')();
// In this block, it is already loaded, so we just
// initialize it. For more info, see:
// https://github.com/regl-project/regl#standalone-script-tag
var regl = createREGL();
var drawTriangle = 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, 0, 1);
}`,
attributes: {
position: [
[-1, 0],
[0, -1],
[1, 1]
]
},
uniforms: {
color: [1, 0, 0, 1]
},
count: 3,
})
// Here we put our draw command in a loop!
regl.frame(function(context) {
drawTriangle();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment