Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/a-big-triangle
Draws a big triangle onto the screen
https://github.com/mikolalysenko/a-big-triangle
Last synced: about 2 months ago
JSON representation
Draws a big triangle onto the screen
- Host: GitHub
- URL: https://github.com/mikolalysenko/a-big-triangle
- Owner: mikolalysenko
- License: mit
- Created: 2013-08-11T14:41:06.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2016-12-07T00:49:27.000Z (about 8 years ago)
- Last Synced: 2024-10-20T14:27:23.774Z (2 months ago)
- Language: JavaScript
- Homepage: http://mikolalysenko.github.io/a-big-triangle/
- Size: 44.9 KB
- Stars: 41
- Watchers: 5
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
a-big-triangle
==============
Draws a big triangle that covers the entire viewport. Useful for GPGPU or when applying fullscreen postprocessing effects.If you're wondering *why* a big triangle and not a big square made from two smaller triangles, there are potentially significant [performance advantages](http://michaldrobot.com/2014/04/01/gcn-execution-patterns-in-full-screen-passes/) in taking the former approach.
## Example
```javascript
var shell = require("gl-now")()
var drawTriangle = require("a-big-triangle")
var createShader = require("gl-shader")var shader
shell.on("gl-init", function() {
shader = createShader(shell.gl,
"precision mediump float;\
attribute vec2 position;\
varying vec2 uv;\
void main() {\
uv = position.xy;\
gl_Position = vec4(position.xy, 0.0, 1.0);\
}",
"precision mediump float;\
varying vec2 uv;\
void main() {\
gl_FragColor = vec4(uv, 0, 1);\
}")
})shell.on("gl-render", function() {
shader.bind()
drawTriangle(shell.gl)
})
```[Check it out in your browser](http://mikolalysenko.github.io/a-big-triangle/)
## Install
```sh
npm install a-big-triangle
```## API
### `require("a-big-triangle")(gl)`
Draws a fullscreen triangle.* `gl` is a WebGL context
## Credits
(c) 2013