PokéRogue
    Preparing search index...

    DrawingContext

    Index
    alphaStrategy: AlphaStrategy

    The alpha strategy to use when rendering. Shaders can opt in to alpha strategies via this value. Typically, this is used to switch from floating-point alpha to a fragment discard strategy for use in stencil rendering.

    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.

    camera: Camera | null

    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.

    enableMipmap: boolean

    Whether to enable mipmaps on the framebuffer texture, if it exists. The game must still be set to use mipmaps for this to work.

    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.

    texture: WebGLTextureWrapper | null

    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.

    • Begin drawing with the DrawingContext.

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

      Returns void

    • Clear the framebuffer. This will bind the framebuffer.

      Parameters

      • Optionalbits: number

        A bitmask of WebGL buffer bits to clear (e.g. gl.COLOR_BUFFER_BIT, gl.DEPTH_BUFFER_BIT, gl.STENCIL_BUFFER_BIT). Defaults to the autoClear value of this context.

      Returns void

    • Copy the state of another DrawingContext.

      Parameters

      Returns void

    • Destroys the DrawingContext and its resources.

      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

      The cloned DrawingContext.

    • Check whether the DrawingContext is locked.undefined

      Returns boolean

      Whether the DrawingContext is locked.

    • 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.

      If no framebuffer exists yet, a new texture and framebuffer are created at the given dimensions. If a framebuffer already exists, it is resized in place. 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 alpha strategy for the DrawingContext.

      Parameters

      • alphaStrategy: AlphaStrategy

        The alpha strategy to use when rendering.

      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 camera for the DrawingContext.

      Parameters

      • camera: Camera

        The camera to set.

      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 color writemask for the DrawingContext.

      Parameters

      • r: boolean

        Whether to write the red channel.

      • g: boolean

        Whether to write the green channel.

      • b: boolean

        Whether to write the blue channel.

      • a: boolean

        Whether to write the alpha channel.

      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

    • Set the stencil parameters for the DrawingContext.

      Parameters

      • Optionalenabled: boolean

        Whether the stencil test is enabled. Default true.

      • Optionalfunc: number

        The stencil comparison function used to compare the reference value against the current stencil buffer value. Default GL_EQUAL.

      • OptionalfuncRef: number

        The reference value against which the stencil buffer value is compared during the stencil test. Default 0.

      • OptionalfuncMask: number

        The bitwise mask applied to both the reference value and the stencil buffer value before they are compared. Default 0xFF.

      • OptionalopFail: number

        The operation to perform if the stencil test fails. Default GL_KEEP.

      • OptionalopZfail: number

        The operation to perform if the stencil test passes but the depth test fails. Default GL_KEEP.

      • OptionalopZpass: number

        The operation to perform if the stencil test passes and the depth test passes or is disabled. Default GL_KEEP.

      • Optionalclear: number

        The value to clear the stencil buffer to. Default 0.

      • OptionalwriteMask: number

        The mask applied to the stencil buffer value when it is written. Set to 0 to prevent writing. Set to 0xFF to allow full writing. Default 0x00.

      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