Skip to content

Setup

createContext() ​

ts
function createContext(options?): WebGL2RenderingContext;

Defined in: createContext.js:32

Creates a WebGL2 context and keeps the canvas's pixel size in step with its CSS size. Throws if WebGL2 isn't available.

With no options it creates a canvas that fills the window. Pass canvas to use your own (size it with CSS), or container to append a new canvas that fills that element.

Parameters ​

ParameterTypeDescription
options?ContextOptionsSee ContextOptions.

Returns ​

WebGL2RenderingContext

Example ​

ts
const gl = createContext({ canvas: document.querySelector("canvas") });