phaser - v4.0.0-rc.4
    Preparing search index...

    DrawingContext

    Index

    Constructors

    Properties

    autoClear: number

    Which renderbuffers in the framebuffer to clear when the DrawingContext comes into use. This is the mask of buffers to clear: gl.COLOR_BUFFER_BIT, gl.DEPTH_BUFFER_BIT, gl.STENCIL_BUFFER_BIT.

    blendMode: number

    The blend mode to use when rendering. This is an index into the renderer's blendModes array. It is faster to check than the state object.

    The camera used by this context. Set this using setCamera to ensure the view matrix is updated. Ensure that this is not null before rendering.

    The WebGLFramebufferWrapper which will hold the framebuffer output. This may contain the canvas.

    height: number

    The height of the framebuffer.

    lastUsed: number

    The last time the DrawingContext was used. This is used to determine whether the context is a candidate for reuse in a pool.

    The pool to return to when this context is no longer needed. Used only for temporary contexts.

    renderer: WebGLRenderer

    The renderer that owns this context.

    Relevant WebGL state for the DrawingContext. Contains the framebuffer, scissor box, and viewport.

    The WebGLTextureWrapper which will hold the framebuffer output. This is only used if useCanvas is false.

    useCanvas: boolean

    Whether to use the canvas as the framebuffer.

    width: number

    The width of the framebuffer.

    Methods

    • Begin drawing with the DrawingContext.

      This should be called before rendering to set up the framebuffer and other WebGL state.

      Returns void

    • Create a clone of the DrawingContext. This is intended to be mutated for temporary use, and then thrown away.

      The autoClear setting is set to false unless specified. This is because most clones reference an existing framebuffer, which is intended to accumulate drawing operations.

      Parameters

      • OptionalpreserveAutoClear: boolean

        Whether to preserve the autoClear setting. Default false.

      Returns DrawingContext

    • Lock the DrawingContext to be in use. This prevents release from returning it to its pool until unlock is called with the appropriate key. This is used for temporary DrawingContexts, which may be returned to a pool.

      Parameters

      • key: any

        The key to lock the DrawingContext with.

      Returns void

    • End using the DrawingContext. This marks the context as not in use, so its framebuffer and texture are not needed any more and may be cleared at any time. This will finish any outstanding batches.

      If there are no locks on the DrawingContext, and it comes from a pool, it will be returned to its pool.

      Returns void

    • Resize the DrawingContext.

      Delete the framebuffer and texture, and create new ones with the new size. The scissor box and viewport are reset to match the new size.

      Parameters

      • width: number

        The new width of the framebuffer.

      • height: number

        The new height of the framebuffer.

      Returns void

    • Set the buffers to clear when the DrawingContext comes into use.

      Parameters

      • color: boolean

        Whether to clear the color buffer.

      • depth: boolean

        Whether to clear the depth buffer.

      • stencil: boolean

        Whether to clear the stencil buffer.

      Returns void

    • Set the blend mode for the DrawingContext.

      Parameters

      • blendMode: number

        The blend mode to set.

      • OptionalblendColor: number[]

        The blend color to set. This is an array of 4 values: red, green, blue, alpha.

      Returns void

    • Set the clear color for the DrawingContext. No changes will be made if the color is the same as the current clear color.

      Parameters

      • r: number

        The red component of the color to clear with.

      • g: number

        The green component of the color to clear with.

      • b: number

        The blue component of the color to clear with.

      • a: number

        The alpha component of the color to clear with.

      Returns void

    • Set the scissor box for the DrawingContext.

      Parameters

      • x: number

        The x coordinate of the scissor box.

      • y: number

        The y coordinate of the scissor box.

      • width: number

        The width of the scissor box.

      • height: number

        The height of the scissor box.

      Returns void

    • Enable or disable the scissor box for the DrawingContext.

      Parameters

      • enable: boolean

        Whether to enable the scissor box.

      Returns void

    • Unlock the DrawingContext. This allows release to return it to its pool.

      Parameters

      • key: any

        The key to unlock the DrawingContext with. This must be the same key used to lock it.

      • Optionalrelease: boolean

        Whether to release the DrawingContext immediately. This will only happen if there are no other locks on it.

      Returns void

    • Begin using the DrawingContext. This will finish any outstanding batches and run any autoClear.

      Returns void