Menu - Top - Home - Donate to Me

H3DU.ShaderProgram

Back to documentation index.

H3DU.ShaderProgram(context, [vertexShader], [fragmentShader])

Deprecated: This class is likely to become a private class. Use the H3DU.ShaderInfo class instead, which is not coupled to WebGL contexts.

Represents a WebGL shader program. A shader program in WebGL consists of a vertex shader (which processes vertices), and a fragment shader (which processes pixels). Shader programs are specially designed for running on a graphics processing unit, or GPU.

When the H3DU.ShaderProgram constructor is called, it will compile and link a shader program from the source text passed to it, but it won't use that program until the use() method is called. If the program is compiled and linked successfully, the constructor will also gather a list of the program's attributes (vertex-specific variables in vertex buffer objects) and uniforms (variables not specific to a vertex).

If compiling or linking the shader program fails, a diagnostic log is output to the JavaScript console.

Parameters

Methods

H3DU.ShaderProgram#dispose()

Disposes resources from this shader program.

Return Value

This method doesn't return a value. (Type: void)

H3DU.ShaderProgram#get(name)

Gets the location of the given uniform or attribute's name in this program. (Although the location may change each time the shader program is linked, that normally only happens upon construction in the case of H3DU.ShaderInfo.)

Parameters

Return Value

The location of the uniform or attribute name, or null if it doesn't exist. (Type: number | WebGLUniformLocation | null)

H3DU.ShaderProgram#getContext()

Gets the WebGL context associated with this shader program object.

Return Value

Return value. (Type: WebGLRenderingContext | WebGL2RenderingContext)

(static) H3DU.ShaderProgram.getDefaultFragment()

Deprecated: Use H3DU.ShaderInfo.getDefaultFragment instead.

Gets the text of the default fragment shader. Putting "#define SHADING\n" at the start of the return value enables the lighting model. Putting "#define SPECULAR\n" at the start of the return value enables specular highlights (as long as SHADING is also enabled).

Return Value

The resulting shader text. (Type: string)

(static) H3DU.ShaderProgram.getDefaultVertex()

Deprecated: Use H3DU.ShaderInfo.getDefaultVertex instead.

Gets the text of the default vertex shader. Putting "#define SHADING\n" at the start of the return value enables the lighting model.

Return Value

The resulting shader text. (Type: string)

(static) H3DU.ShaderProgram.getEdgeDetectEffect([context])

Deprecated: Use H3DU.ShaderInfo.makeEdgeDetectEffect instead.

Generates a shader program that generates a two-color texture showing the source texture's edges.

Parameters

Return Value

The resulting shader program. (Type: H3DU.ShaderInfo)

(static) H3DU.ShaderProgram.getInvertEffect([context])

Deprecated: Use H3DU.ShaderInfo.makeInvertEffect instead.

Generates a shader program that inverts the colors of a texture.

Parameters

Return Value

The resulting shader program. (Type: H3DU.ShaderInfo)

H3DU.ShaderProgram#getUniform(name)

Gets the value of the given uniform in this program. This method may be called at any time, even if this program is not currently the active program in the WebGL context.

Parameters

Return Value

The uniform's value, or null if it doesn't exist or if an attribute is named, not a uniform. (Type: Number | Array.<number>)

(static) H3DU.ShaderProgram.makeCopyEffect()

Deprecated: Use H3DU.ShaderInfo.makeCopyEffect instead.

Generates a shader program that copies the colors of a texture.

Return Value

The resulting shader program. (Type: H3DU.ShaderInfo)

(static) H3DU.ShaderProgram.makeEffect(context, functionCode)

Deprecated: Use H3DU.ShaderInfo.makeEffect instead.

Generates a shader program for applying a raster effect (postprocessing effect) to a texture.

Parameters

Return Value

The resulting shader program. (Type: H3DU.ShaderInfo)

(static) H3DU.ShaderProgram.makeEffectFragment(functionCode)

Deprecated: Use H3DU.ShaderInfo.makeEffectFragment instead.

Generates source code for a fragment shader for applying a raster effect to a texture.

Parameters

Return Value

The source text of the resulting fragment shader. (Type: string)

H3DU.ShaderProgram#setUniforms(uniforms)

Sets the values of one or more uniforms in this program. If this program is not the active program in the WebGL context, saves their values until the next time this object's "use" method is called.

Parameters

Return Value

This object. (Type: H3DU.ShaderProgram)

H3DU.ShaderProgram#use()

Makes this program the active program in the WebGL context associated with it. If any uniforms were saved to be written later (because this program wasn't active in the WebGL context when the "setUniforms" method was called), sets their values now.

Return Value

This object. (Type: H3DU.ShaderProgram)

Back to documentation index.