WebGL Program wrapper encapsulating program creation, shader attachment, linking, binding, as well as attribute and uniform location retrieval. A program is intended to be used as follows:
const vert = new Shader(this._context, gl.VERTEX_SHADER, 'ndcvertices.vert (blit)'); vert.initialize(require('./shaders/ndcvertices.vert')); const frag = new Shader(this._context, gl.FRAGMENT_SHADER, 'blit.frag'); frag.initialize(require('./shaders/blit.frag')); this._program = new Program(this._context, 'BlitProgram'); this._program.initialize([vert, frag]); this.aVertex = this._program.attribute('a_vertex'); const uTexture = this._program.uniform('u_texture'); this._program.bind(); gl.uniform1i(uTexture, 0); // ... draw this._program.unbind();
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.
Default program, e.g., used for unbind.
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 access the the program's link status. True if last linking was successful.
Read-only access to the WebGL object handle.
Provides access (leaky abstraction) to all shaders attached to this program.
Cached object status used to derive validity when initialized.
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.
Attaches and references all given shaders. Attach is expected to be called once within creation of a Program. Shaders that are not initialized will be skipped/not attached.
All shaders to be attached to the program for linking.
Whether or not to link the program again after attaching the shader(s).
Requests the location of an attribute of the program.
Attribute identifier to request location of.
Attribute location (if WebGL2 location is used)
Activates this program for use.
Creates a WebGLProgram object and attaches, and references all shaders to it. The program is then linked. All shaders have to be initialized in order to be attached and at least on vertex and one fragment shader has to be present. Note that the shaders are not detached by default. If neither the shader objects nor recompilation is required all shaders should be detached manually after initialization/creation.
Vertex and fragment shaders that are to be attached to the program.
Whether or not to immediately link the program iff provided shader(s) are attached successfully.
Delete the program object on the GPU. This should have the reverse effect of
Links the program with all its already attached shaders. If linking fails, a developer log with additional information is provided.
Increment the reference count of this object.
Deactivates this/any program for use.
Requests the location of a uniform of the program.
Uniform identifier to request location of.
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 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
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
assertUninitialized they are
dynamically bound to a static, always-failing assert and an empty/undefined function respectively.