npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

webglutenfree

v0.0.13

Published

We serve your draw calls type-safe and gluten-free

Downloads

14

Readme

webglutenfree

Build Status

We serve your draw calls type-safe and gluten-free.

Webglutenfree is a lightweight, comfort focused abstraction on top of WebGL2. It abstracts away state manipulation, uses parameters instead of state-setting calls, and encapsulates all GPU resident resources within helpful handles.

On the scale from low-level and flexible to high-level and opinionated, Webglutenfree leans towards flexibility. In general, 80-90% of the sensible things possible with raw WebGL should be possible to do. If you are missing a feature, please file an issue.

However, the library is opinionated in the sense that some things are just "not a good idea" and strives to make invalid operations unexpressable both via compile time checks and runtime assertions (the latter in dev mode only).

While it can be consumed directly from JavaScript, using TypeScript adds compile time safety in terms of value dependent type parameters. For instance, it won't allow you to store Float32Array data in a texture with RGBA32UI internal format.

Current State

We want to get to a 0.1.0 (meaning generally usable) eventually, but there are still things missing:

  • Documentation: we need a tutorial and API documentation,
  • API stability: the API is still in flux,
  • Features: we are missing at least Cubemaps, Texture Arrays, and Renderbuffers.

Gallery

Have a look at our gallery (For the moment the gallery works only on browsers supporting both WebGL2 and ES modules, e.g. Firefox and Chrome)

Hello Triangle

Usually, you would acquire a Device (WebGL context) and create Commands at init time. To draw, request a render target from the device and execute draw commands with it.

import { Device, ElementPrimitive } from "webglutenfree";

const dev = Device.create();
const cmd = dev.createCommand(
    `#version 300 es
    precision mediump float;

    layout (location = 0) in vec2 a_position;
    layout (location = 1) in vec4 a_color;

    out vec4 v_color;

    void main() {
        v_color = a_color;
        gl_Position = vec4(a_position, 0.0, 1.0);
    }
    `,
    `#version 300 es
    precision mediump float;

    in vec4 v_color;

    layout (location = 0) out vec4 f_color;

    void main() {
        f_color = v_color;
    }
    `,
);

const attrs = dev.createAttributes(ElementPrimitive.TRIANGLE_LIST, {
    0: [
        [-0.3, -0.5],
        [0.3, -0.5],
        [0, 0.5],
    ],
    1: [
        [1, 0, 0, 1],
        [0, 1, 0, 1],
        [0, 0, 1, 1],
    ],
});

dev.target((rt) => {
    rt.draw(cmd, attrs);
});

Triangle

Installation

npm install --save webglutenfree or yarn add webglutenfree

Development

First time setup:

Install node and yarn, e.g. with Volta (volta pins are saved in package.json).

Developing

  • Run yarn to install libraries,
  • Run yarn serve to run a local server with the project,
  • Run yarn build to build the project,
  • Run yarn build-all to build the project for all targets,
  • Run yarn test to run tests (must be built first: yarn build or yarn compile),
  • Run yarn lint to run a linter on the project source.

Sources

Webglutenfree is inspired by:

We found the following docs and tutorials helpful: