A wrapper around an HTMLCanvasElement providing access to the WebGL rendering context and notifications of context loss and restore. An instance of the Engine will usually be a required parameter for any consumer of WebGL resources.

Hierarchy (view full)

Implements

Constructors

  • Parameters

    • Optionalcanvas: string | WebGL2RenderingContext | HTMLCanvasElement

      The canvas element identifier, or canvas element, or WebGL rendering context.

    • attributes: EngineAttributes = {}

      Allows the context to be configured.

    • Optionaldom: Document

      The document object model that contains the canvas.

    Returns Engine

Accessors

  • get canvas(): HTMLCanvasElement
  • The canvas element associated with the WebGLRenderingContext.

    Returns HTMLCanvasElement

  • get gl(): WebGL2RenderingContext | WebGLRenderingContext
  • The underlying WebGL rendering context.

    Returns WebGL2RenderingContext | WebGLRenderingContext

Methods

  • Sets the graphics buffers to values preselected by clearColor, clearDepth or clearStencil.

    Parameters

    • mask: number = ...

    Returns this

  • Specifies color values to use by the clear method to clear the color buffer.

    Parameters

    • red: number
    • green: number
    • blue: number
    • alpha: number

    Returns this

  • Specifies the clear value for the depth buffer. This specifies what depth value to use when calling the clear() method. The value is clamped between 0 and 1.

    Parameters

    • depth: number

      Specifies the depth value used when the depth buffer is cleared. The default value is 1.

    Returns this

  • Parameters

    • s: number

      Specifies the index used when the stencil buffer is cleared. The default value is 0.

    Returns this

  • Computes the coordinates of a point in the image cube corresponding to device coordinates.

    Parameters

    • deviceX: number

      The x-coordinate of the device event.

    • deviceY: number

      The y-coordinate of the device event.

    • imageZ: number = 0

      The optional value to use as the resulting depth coordinate.

    Returns Readonly<R3>

  • The viewport width and height are clamped to a range that is implementation dependent.

    Returns Int32Array

    e.g. Int32Array[16384, 16384]

  • Returns the current viewport settings.

    Returns Int32Array

    e.g. Int32Array[x, y, width, height]

  • This method is for use within constructors.

    Immediately after a call to the super class constructor, make a call to setLoggingName. This will have the effect of refining the name used for reporting reference counts.

    This method has the secondary purpose of enabling a tally of the number of classes in the constructor chain. This enables the runtime architecture to verify that destructor chains are consistent with constructor chains, which is a good practice for cleaning up resources.

    Notice that this method is intentionally protected to discourage it from being called outside of the constructor.

    Parameters

    • name: string

      This will usually be set to the name of the class.

    Returns void

  • A convenience method for setting the width and height properties of the underlying canvas and for setting the viewport to the drawing buffer height and width.

    Parameters

    • width: number
    • height: number

    Returns this

  • Initializes the WebGLRenderingContext for the specified HTMLCanvasElement.

    Parameters

    • canvas:
          | string
          | WebGL2RenderingContext
          | WebGLRenderingContext
          | HTMLCanvasElement

      The HTML canvas element or canvas element identifier.

    • Optionaldom: Document

      The document object model that contains the canvas identifier.

    Returns this

  • Defines what part of the canvas will be used in rendering the drawing buffer.

    Parameters

    • x: number
    • y: number
    • width: number
    • height: number

    Returns this