Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gl-util

Package Overview
Dependencies
Maintainers
1
Versions
35
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gl-util - npm Package Compare versions

Comparing version 1.0.3 to 1.0.4

2

package.json
{
"name": "gl-util",
"version": "1.0.3",
"version": "1.0.4",
"description": "Set of practical webgl utils",

@@ -5,0 +5,0 @@ "main": "index.js",

'use strict'
let programsCache = setProgram.programsCache = new WeakMap();
module.exports = setProgram;

@@ -11,2 +9,5 @@

//TODO: delete program by passing null
//TODO: keep track of used programs to avoid this request below, think how
//if just getProgram

@@ -13,0 +14,0 @@ if (!vSrc && !fSrc) {

@@ -28,10 +28,10 @@ # gl-util [![unstable](http://badges.github.io/stability-badges/dist/unstable.svg)](http://github.com/badges/stability-badges)

| `filter` | Sets texture scaling for both min and mag. Can be defined as two separate properties `minFilter` and `magFilter`. By default `gl.LINEAR`. |
| `wrap` | Defines texture tiling vertically and horizontally. Can be defined precisely as `wrapS` and `wrapT`. By default `gl.MIRRORED_REPEAT`. |
| `wrap` | Defines texture tiling vertically and horizontally. Can be defined precisely as `wrapS` and `wrapT`. By default `gl.CLAMP_TO_EDGE`, can be `gl.MIRRORED_REPEAT` or `gl.`. |
| `width` | In pixels |
| `height` | In pixels |
| `format` | By default `gl.RGBA` |
| `format` | `gl.ALPHA`, `gl.RGB`, `gl.RGBA` (default), `gl.LUMINANCE`, `gl.LUMINANCE_ALPHA`, `gl.DEPTH_COMPONENT`, `gl.DEPTH_STENCIL`, [etc](https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/texImage2D) |
| `type` | `gl.UNSIGNED_BYTE`, can be `gl.FLOAT` with proper extension enabled |
| `level` | `0`, mipmap level. |
Returns object with texture properties `{data, index, location, minFilter, magFilter, wrapS, wrapT, width, height, format, type}`.
Returns object with texture properties `{data, index, location, minFilter, magFilter, wrapS, wrapT, width, height, format, type, texture}`.

@@ -60,6 +60,6 @@ ### `attribute(gl, name?, data|parameters?, program?)`

There are [regl](https://github.com/regl-project/regl), [stack.gl](https://github.com/stackgl/) and other assorted libs, so why bother?
There are [regl](https://github.com/regl-project/regl) and other [stack.gl](https://github.com/stackgl/) components like _gl-texture_, _gl-shader_ etc, so why bother?
Because I have hard time remembering their API or pure webgl API. Also they supersede webgl API, so that if one would like to debug vanilla webgl for a moment it would be utterly impossible. Also oftentimes I need minimalistic webgl setup, but regl or stack.gl components tend to be relatively massive.
Because their API may give hard time remembering, same as pure webgl methods. Also _gl-utils_ do not supersede webgl API, so that allows for debugging pure webgl for a moment if one need to. Also if one need minimalistic webgl setup it may be better to opt for a couple of functions over relatively massive stack.gl components.
_gl-util_ is like functions from any webgl tutorial. Tiny, handy and already familiar, so.

@@ -56,2 +56,3 @@ const gl = require('webgl-context')()

uniform vec4 viewport;
uniform float x;

@@ -78,2 +79,3 @@ void main () {

util.program(gl, p3);
util.uniform(gl, 'x', 1);
util.attribute(gl, 'position', {data: [0,0,1,0,0,1]});

@@ -80,0 +82,0 @@ util.texture(gl, 'color', './texture.gif');

@@ -118,3 +118,3 @@ /* @module gl-util/unifrom */

//put data to shader
if (uniform.location && uniform.data) {
if (uniform.location && uniform.data != null) {
switch (uniform.type) {

@@ -141,6 +141,6 @@ case gl.FLOAT_VEC4:

case gl.FLOAT:
gl.uniform2f(uniform.location, uniform.data);
gl.uniform1f(uniform.location, uniform.data);
break;
case gl.INT:
gl.uniform2i(uniform.location, uniform.data);
gl.uniform1i(uniform.location, uniform.data);
break;

@@ -147,0 +147,0 @@ }

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc