A render buffer class that represents a renderable texture buffer used for off-screen rendering. This class manages GPU resources for render targets, depth buffers, and MSAA (Multi-Sample Anti-Aliasing) buffers. It implements the IRenderable interface and extends RnObject for resource management.

Hierarchy (view full)

Implements

Constructors

Properties

_tags: RnTags = {}

Collection of tags associated with this object

_textureResourceUid: number = -1

The unique identifier for the texture resource in the graphics API

_textureViewAsRenderTargetResourceUid: number = -1

The unique identifier for the texture view used as a render target

_textureViewResourceUid: number = -1

The unique identifier for the texture view resource

height: number = 0

The height of the render buffer in pixels

width: number = 0

The width of the render buffer in pixels

InvalidObjectUID: -1 = -1

Invalid object UID constant

currentMaxObjectCount: number = 0

Current maximum object count for UID generation

Accessors

  • get objectUID(): number
  • Gets the unique object identifier

    Returns number

    The object's UID

  • get sampleCount(): number
  • Gets the MSAA sample count for this render buffer.

    Returns number

    The number of samples used for multi-sample anti-aliasing

  • get uniqueName(): string
  • Gets the unique name of this object

    Returns string

    The unique name string

Methods

  • Creates and initializes the render buffer with the specified parameters. This method allocates GPU resources and sets up the render buffer for rendering operations.

    Parameters

    • width: number

      The width of the render buffer in pixels

    • height: number

      The height of the render buffer in pixels

    • internalFormat: TextureParameterEnum

      The internal texture format for the render buffer

    • options: {
          isMSAA: undefined | boolean;
          sampleCountMSAA: undefined | number;
      } = {}

      Optional configuration object

      • isMSAA: undefined | boolean

        Whether to enable multi-sample anti-aliasing (default: false)

      • sampleCountMSAA: undefined | number

        The number of MSAA samples (default: current sample count)

    Returns void

  • Creates a cube texture view as a render target for a specific face and mip level. This method is currently not implemented and serves as a placeholder for future functionality.

    Parameters

    • faceIdx: number

      The index of the cube face (0-5)

    • mipLevel: number

      The mip level to create the view for

    Returns void

  • Destroys all GPU resources associated with this render buffer. This method releases the allocated graphics API resources and resets the buffer state. Should be called when the render buffer is no longer needed to prevent memory leaks.

    Returns boolean

    True if the resources were successfully destroyed

  • Retrieves a complete tag object (name and value) for the specified tag name

    Parameters

    • tagName: string

      The name of the tag to retrieve

    Returns Tag

    A Tag object containing the name and value

  • Retrieves the value associated with a specific tag name

    Parameters

    • tagName: string

      The name of the tag whose value to retrieve

    Returns any

    The tag value, or undefined if the tag doesn't exist

  • Checks whether this object has a tag with the specified name

    Parameters

    • tagName: string

      The name of the tag to check for

    Returns boolean

    True if the tag exists (value is not null/undefined), false otherwise

  • Checks if this object has a tag with the specified name and value

    Parameters

    • tagName: string

      The tag name to match

    • tagValue: string

      The tag value to match

    Returns boolean

    True if the object has a matching tag, false otherwise

  • Checks if this object has all the specified tags with exactly matching values

    Parameters

    • tags: RnTags

      Object containing tag names as keys and expected values

    Returns boolean

    True if all specified tags exist with matching values, false otherwise

  • Checks if the object's combined tag string contains all the provided search strings. This allows for flexible searching within tag names and values.

    Parameters

    • stringArray: string[]

      Array of strings that must all be present in the combined tag string

    Returns boolean

    True if all strings are found in the combined tag string, false otherwise

  • Resizes the render buffer to new dimensions. This method destroys the current GPU resources and recreates them with the new size, preserving the original format and MSAA settings.

    Parameters

    • width: number

      The new width in pixels

    • height: number

      The new height in pixels

    Returns void

  • Attempts to set a tag on this object. If the tag already exists, it will be replaced.

    Parameters

    • tag: Tag

      The tag object containing the name and value to set

    Returns boolean

    True if the tag was successfully set, false if the tag name contains invalid characters

  • Attempts to set a unique name for this object

    Parameters

    • name: string

      The desired unique name

    • toAddNameIfConflict: boolean

      If true, appends UID to make name unique when conflicts occur; if false, fails on conflict

    Returns boolean

    True if the name was successfully set, false if there was a conflict and toAddNameIfConflict was false

  • Validates that a tag string contains only allowed characters (alphanumeric and underscore)

    Parameters

    • val: string

      The string to validate

    Returns boolean

    True if the string contains only valid characters, false if it contains invalid characters

  • Retrieves an RnObject instance by its unique identifier

    Parameters

    • objectUid: number

      The unique identifier of the object to retrieve

    Returns undefined | RnObject

    The RnObject instance or undefined if not found or garbage collected

  • Searches for the first object that has a specific tag with the given value

    Parameters

    • tag: string

      The tag name to search for

    • value: string

      The tag value to match

    Returns undefined | WeakRef<RnObject>

    WeakRef to the first matching object, or undefined if not found