Socket
Book a DemoInstallSign in
Socket

gl-toy

Package Overview
Dependencies
Maintainers
8
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-toy

Create quick WebGL demo's using glslify

latest
Source
npmnpm
Version
2.0.3
Version published
Maintainers
8
Created
Source

gl-toy

NPM version Downloads

Create quick GLSL fragment shader demos.

Installation

$ npm install gl-toy

Usage

var glslify = require('glslify')
var toy     = require('gl-toy')

var shader = glslify('./shader.frag')
var start  = Date.now()

toy(shader, function(gl, shader) {
  shader.uniforms.uScreenSize = [gl.drawingBufferWidth, gl.drawingBufferHeight]
  shader.uniforms.uTime = Date.now() - start
})

With beefy installed:

$ beefy ./index.js

toy = glToy(frag, update)

Creates a new shader renderer, attaching it to document.body and making it fill the screen.

frag should be a fragment shader string you'd like to render using a-big-triangle.

update(gl, shader) is called before drawing to the screen so that you can update uniforms being passed into the program. Here, gl is a WebGLRenderingContext and shader is an instance of gl-shader.

toy.update(frag)

Updates the current fragment shader with the new frag string.

toy.resize()

Resizes the canvas to fit within its parent element, using canvas-fit.

toy.canvas

A reference to gl-toy's canvas element.

toy.gl

A reference to gl-toy's WebGLRenderingContext.

toy.shader

A reference to gl-toy's instance of gl-shader.

Why?

WebGL and glslify can be a bit tricky to set up. This makes it easier to get something working quickly. It might not suit all use cases, but then again: neither does shadertoy.

Contributors

License

MIT

Keywords

glslify

FAQs

Package last updated on 01 Jan 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts