Number of references to this object. If at least a single reference was counted, this object can neither be initialized (and thus created) nor uninitialized (and thus deleted). The reference count is controlled via ref() and unref() functions.
Map of replacement strings and the value to replace them with.
Asserts the objects initialization status to be true. Note that the implementation is cached and forwarded to either an empty function when initialized and to an acutal assert(false) otherwise.
Asserts the objects initialization status to be false. Note that the implementation is cached and forwarded to either an empty function when uninitialized and to an acutal assert(false) otherwise.
Read access the the shader's compile status. True if last compilation was successful.
Read-only access to the objects context, used to get context information and WebGL API access.
Every GPU asset that allocates memory should provide a human readable identifier for GPU allocation tracking and debugging purposes. Please note that the identifier might changed on initialization due to the generation and assignment of a unique identifier.
Property getter for readonly access to the initialization status of an initializable instance.
Read-only access to the WebGL object handle.
Read access to the shader's source (without replacements applied).
Allows to change the shader's source. Note that this will not recompile the shader.
Processes all search values and replaces them with the replace value on the source.
The source with all replacements applied.
Either VERTEX_SHADER or FRAGMENT_SHADER.
Cached object status used to derive validity when initialized.
Triggers recompilation of a shader. This is usually used internally automatically, but exposed here for leaky abstraction. It should not be required to invoke this manually in most cases. The shader object is marked as compiled iff the source compiled successfully. Note that invalidation of all programs this shader is attached to needs to be done manually.
Creates a shader, sets the shader source, and compiles the shader. If the shader source cannot be compiled, the identifier and an info log are logged to console and the shader object is deleted. Note that a '#version 300 es' is added in case the shader source is compiled in a WebGL2 context.
Shader source.
Whether or not to compile the shader immediately if a source is provided.
Delete the shader object. This should have the reverse effect of create
.
Increment the reference count of this object.
Adds a search-replacement-pair that is processed every time the shaders is recompiled. Note that recompilation has to be triggered manually. Internally, all replacements are stored as a Map of search and replacement values. Thus, specifying a replacement value overrides an existing search value.
String that is to be searched (all occurrences) and replaced by replace value.
The value to be used as replacement for all search value occurrences.
Decrement the reference count of this object.
Method decorator for asserting the initialization status of an initializable to be true.
Method decorator for asserting the initialization status of an initializable to be false.
Method decorator for discarding of Initializable inheritors. This decorator asserts the initialization
status of the instance that is to be discarded, invokes its uninitialization, and falsifies the
initialization status. In order to encourage the use of assertInitialized
and assertUninitialized
they are
dynamically bound to a static, always-failing assert and an empty/undefined function respectively.
Method decorator for initialization of Initializable inheritors. This decorator asserts the initialization status
of the instance that is to be initialized, invokes its initialization with arbitrary number of parameters,
and sets the initialization status to the initialization success (either false or true).
In order to encourage the use of assertInitialized
and assertUninitialized
they are dynamically
bound to either a static, always-failing assert or an empty/undefined function.
Method decorator for uninitialization of Initializable inheritors. This decorator asserts the initialization
status of the instance that is to be uninitialized, invokes its uninitialization, and falsifies the
initialization status. In order to encourage the use of assertInitialized
and assertUninitialized
they are
dynamically bound to a static, always-failing assert and an empty/undefined function respectively.
WebGL shader wrapper encapsulating shader creation, compilation, and deletion. A shader can be attached to multiple Programs for linking, and can be deleted if detached from all (linked) programs. The expected default behavior is to create a shader, attach it to programs, and discard is immediately after all programs are created (linked). If, however, the source of a shader needs to be changed, e.g., for replacements or other modifications, the shader object should be kept and, on change, all programs that have the shader attached have to be invalidated/relinked manually.