Options
All
  • Public
  • Public/Protected
  • All
Menu

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

  • ShareableBase
    • Engine

Implements

Index

Constructors

constructor

  • new Engine(canvas?: string | HTMLCanvasElement | WebGL2RenderingContext, attributes?: EngineAttributes, dom?: Document): Engine
  • Parameters

    • Optional canvas: string | HTMLCanvasElement | WebGL2RenderingContext

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

    • Default value attributes: EngineAttributes = {}

      Allows the context to be configured.

    • Optional dom: Document

      The document object model that contains the canvas.

    Returns Engine

Accessors

canvas

  • get canvas(): HTMLCanvasElement

contextId

  • get contextId(): "webgl2" | "webgl"

drawingBufferHeight

  • get drawingBufferHeight(): number

drawingBufferWidth

  • get drawingBufferWidth(): number

gl

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

    Returns WebGL2RenderingContext | WebGLRenderingContext

Methods

addContextListener

addRef

  • addRef(): number

blendFunc

clear

  • clear(mask?: number): this
  • Sets the graphics buffers to values preselected by clearColor, clearDepth or clearStencil.

    Parameters

    • Default value mask: number = ClearBufferMask.COLOR_BUFFER_BIT | ClearBufferMask.DEPTH_BUFFER_BIT

    Returns this

clearColor

  • clearColor(red: number, green: number, blue: number, alpha: number): 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

clearDepth

  • clearDepth(depth: number): 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

clearStencil

  • clearStencil(s: number): this
  • Parameters

    • s: number

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

    Returns this

depthFunc

depthMask

  • depthMask(flag: boolean): this

deviceToImageCoords

  • deviceToImageCoords(deviceX: number, deviceY: number, imageZ?: number): Readonly<R3>
  • 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.

    • Default value imageZ: number = 0

      The optional value to use as the resulting depth coordinate.

    Returns Readonly<R3>

disable

enable

getLoggingName

  • getLoggingName(): string
  • Returns the name that was assigned by the call to the setLoggingName method.

    Returns string

getMaxViewportDims

  • getMaxViewportDims(): Int32Array
  • The viewport width and height are clamped to a range that is implementation dependent.

    Returns Int32Array

    e.g. Int32Array[16384, 16384]

getViewport

  • getViewport(): Int32Array
  • Returns the current viewport settings.

    Returns Int32Array

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

isZombie

  • isZombie(): boolean
  • An object is a zombie if it has been released by all who have held references. In some cases it may be possible to recycle a zombie.

    Returns boolean

readPixels

  • readPixels(x: number, y: number, width: number, height: number, format: PixelFormat, type: PixelType, pixels: ArrayBufferView): void

release

  • release(): number

removeContextListener

Protected setLoggingName

  • setLoggingName(name: string): void
  • 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

size

  • size(width: number, height: number): this
  • 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

start

  • start(canvas: string | HTMLCanvasElement | WebGL2RenderingContext | WebGLRenderingContext, dom?: Document): this
  • Initializes the WebGLRenderingContext for the specified HTMLCanvasElement.

    Parameters

    • canvas: string | HTMLCanvasElement | WebGL2RenderingContext | WebGLRenderingContext

      The HTML canvas element or canvas element identifier.

    • Optional dom: Document

      The document object model that contains the canvas identifier.

    Returns this

stop

  • stop(): this

synchronize

viewport

  • viewport(x: number, y: number, width: number, height: number): 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

Legend

  • Constructor
  • Property
  • Method
  • Accessor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Property
  • Method
  • Protected property
  • Protected method
  • Static property
  • Static method

Generated using TypeDoc