3.0.2 • Published 6 months ago

pex-gl v3.0.2

Weekly downloads
34
License
MIT
Repository
github
Last release
6 months ago

pex-gl

npm version stability-stable npm minzipped size dependencies types Conventional Commits styled with prettier linted with eslint license

Create a RenderingContext (2d, webgl, webgl2, bitmaprenderer, webgpu) for use in PEX.

Installation

npm install pex-gl

Usage

import createRenderingContext, { FALLBACKS } from "pex-gl";

// Creates a webgl context filling the window
const context = createRenderingContext();

// Creates a webgl context from an existing canvas and keeps its size
const context = createRenderingContext({ canvas });

// Creates a webgl context on a new canvas with given width and height
const context = createRenderingContext({ width, height });

// Creates a new canvas of type "webgpu"
const context = createRenderingContext({ type: "webgpu" });

// Creates a new canvas of type "webgl" or fallback to experimental-webgl in case it fails
const context = createRenderingContext({ type: "webgl" });

// Disable fallbacks for "webgl2"
FALLBACKS.webgl2 = [];
// Creates a new canvas of type "webgl2" and return null in case it fails
const context = createRenderingContext({ type: "webgl2" });

API

Modules

Typedefs

pex-gl

pex-gl.FALLBACKS

Context fallbacks map

Kind: static constant of pex-gl

pex-gl.default(opts) ⇒ RenderingContext

Creates a rendering context.

Kind: static method of pex-gl

ParamTypeDefault
optsPexGLOptions{}

PexGLOptions : object

Options for context creation. All optional.

Kind: global typedef Properties

NameTypeDefaultDescription
widthnumberwindow.innerWidthRequest an initial canvas width.
heightnumberwindow.innerHeightRequest an initial canvas height.
pixelRatioboolean1Multiply canvas dimensions with a given ratio.
fullscreenboolean!opts.width && !opts.heightMake the canvas fullscreen.
type"2d" | "bitmaprenderer" | "webgl" | "webgl2" | "webgpu""webgl"A "contextType" for getContext.
elementHTMLElementdocument.bodyElement to append the canvas to.
...contextAttributesCanvasRenderingContext2DSettings | WebGLContextAttributes{}Attributes to be passed to getContext.

License

MIT. See license file.

3.0.2

6 months ago

3.0.1

1 year ago

3.0.0

2 years ago

3.0.0-alpha.0

3 years ago

2.7.0

6 years ago

2.6.2

7 years ago

2.6.1

7 years ago

2.6.0

7 years ago

2.5.0

7 years ago

2.4.1

8 years ago

2.4.0

8 years ago

2.3.0

8 years ago

2.2.0

8 years ago

2.1.0

8 years ago

2.0.1

8 years ago

2.0.0

8 years ago

1.4.1

8 years ago

1.4.0

8 years ago

1.3.1

8 years ago

1.3.0

8 years ago

1.2.0

8 years ago

1.1.0

8 years ago

1.0.0

8 years ago

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago