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

@luma.gl/webgl-state-tracker

v7.3.2

Published

WebGL state manager that saves and restores WebGLRenderingContext state

Downloads

8,662

Readme

@luma.gl/webgl-state-tracker

Provides WebGL context state tracking and a unified API for setting WebGL parameters

State tracking

This module installs overrides on a WebGLRenderingContext that track state changes and allow context state to be saved and restored through push and pop operations.

This is useful when combining code written in different WebGL frameworks or code bases, as each code base can make changes to the global WebGLRenderingContext state and leave it in a state that causes problems for the other code base.

Usage

yarn add @luma.gl/webgl-state-tracker
import trackContextState from '@luma.gl/webgl-state-tracker';

const gl = canvas.getContext('webgl');
trackContextState(gl);

Functions

trackContextState(gl : WebGLRenderingContext, options: Object)

Initialize WebGL state caching on a context. After calling this function, context state will be cached. State caching speeds up parameter access and enables pushContextState and popContextState to efficiently save and restore global WebGL context state.

trackContextState(gl, {enable = true, copyState} = {})

  • gl (WebGLRenderingContext) - gl context
  • enable (Boolean) - whether cache is being used
  • copyState whether the state cache is initialized to WebGL defaults (fast) or read from the context (slow)

Remarks:

  • trackContextState can be called multiple times to enable/disable state cache.
  • copyState-false is fast, and yields correct results for newly created, unmodified contexts. If you are tracking a context created by an external framework, it is likely safest to use copyState=true to ensure the cache corresponds to the context state.

pushContextState(gl : WebGLRenderingContext)

Saves the current state of the context by "pushing" it onto an internal stack, enabling it to be restored later.

pushContextState(gl)

  • gl (WebGLRenderingContext) - gl context Returns: nothing

Remarks:

  • Can be called multiple times, enabling "nested" usage.
  • Each invocation of pushContextState is expected to be matched by a call to popContextState at a later time.

popContextState(gl : WebGLRenderingContext)

Restores the state of the context at the time of the latest call to pushContextState.

popContextState(gl)

  • gl (WebGLRenderingContext) - gl context Returns: nothing

Remarks;

  • Any changes made to the context state after the last call to pushContextState are undone and "discarded".
  • It is an error to call popContextState without first doing a matching call to pushContextState.

Remarks

  • This a helper module for luma.gl, but is designed to be independently usable in other projects.