![Introducing Enhanced Alert Actions and Triage Functionality](https://cdn.sanity.io/images/cgdhsj6q/production/fe71306d515f85de6139b46745ea7180362324f0-2530x946.png?w=800&fit=max&auto=format)
Product
Introducing Enhanced Alert Actions and Triage Functionality
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
regl
Advanced tools
Changelog
0.5.0
Context variables
Use this
argument effectively
Make scopes and dynamic attributes take same argument
Combine batchId with stats argument
Pass this
to draw commands so that they can be stored as members
Readme
This repo is an attempt at building new functional abstractions for working with WebGL. It is still experimental, so expect things to change a lot in the near future! If you want to know more about why I am writing this thing and why it looks the way it does, take a look at the rationale.
regl
offers the following advantages over raw WebGL code:
bind()
In regl, shaders, buffers, textures and fbos are specified declaratively, so there is no need to ever bind()
them or unbind them.regl
commands have more structure, we can do more validation up front without the run time performance cost.border
in gl.texImage2D
or transpose
in gl.uniformMatrix4fv
). regl
wraps these APIs in such a way that you will never have to see this mess.In regl
, there are two fundamental abstractions, resources and commands:
To define a command you specify a mixture of static and dynamic data for the object. Once this is done, regl
takes this description and then compiles it into optimized JavaScript code. For example, here is a simple regl
program to draw a colored triangle:
// Calling the regl module with no arguments creates a full screen canvas and
// WebGL context, and then uses this context to initialize a new REGL instance
const regl = require('regl')()
// Calling regl() creates a new partially evaluated draw command
const drawTriangle = regl({
// Shaders in regl are just strings. You can use glslify or whatever you want
// to define them. No need to manually create shader objects.
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);
}`,
// Here we define the vertex attributes for the above shader
attributes: {
// regl.buffer creates a new array buffer object
position: regl.buffer([
[-2, -2], // no need to flatten nested arrays, regl automatically
[4, -2], // unrolls them into a typedarray (default Float32)
[4, 4]
]))
// regl automatically infers sane defaults for the vertex attribute pointers
},
uniforms: {
// This defines the color of the triangle to be a dynamic variable
color: regl.prop('color')
},
// This tells regl the number of vertices to draw in this command
count: 3
})
regl.frame(() => {
// clear contents of the drawing buffer
regl.clear({
color: [0, 0, 0, 0],
depth: 1
})
// draw a triangle using the command defined above
drawTriangle({
color: [
Math.cos(Date.now() * 0.001),
Math.sin(Date.now() * 0.0008),
Math.cos(Date.now() * 0.003),
1
]
})
})
regl has no dependencies, so setting it up is pretty easy
To try out regl right away, you can use RequireBin or codepen. The following links should help get you started:
The easiest way to use regl
in a project is via npm. Once you have node set up, you can install and use regl
in your project using the following command:
npm i -S regl
For more info on how to use npm, check out the official docs.
You can also use regl
as a standalone script if you are really stubborn. The most recent versions can be found under the releases tab. To do this, add the following script tag to your HTML:
<script src="[some cdn tbd]/regl.min.js"></script>
TODO implement spinning textured cube in each of the following frameworks
You can run benchmarks locally using npm run bench
or check them out here:
For info on how to build and test headless, see the contributing guide here
All code (c) 2016 MIT License
Development supported by the Freeman Lab and the Howard Hughes Medical Institute (@freeman-lab on GitHub)
Many examples use creative commons or public domain artwork for illustrative purposes. These assets are not included in any of the redistributable packages of regl.
FAQs
regl is a fast functional WebGL framework.
The npm package regl receives a total of 213,736 weekly downloads. As such, regl popularity was classified as popular.
We found that regl demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 open source maintainers collaborating on the project.
Did you know?
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.
Product
Socket now supports four distinct alert actions instead of the previous two, and alert triaging allows users to override the actions taken for all individual alerts.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.