Home -> IProgramNode -> BindShaderProgram

Description

The BindShaderProgram method specifies the IShaderProgram object to use as the shader program for all renderable content under this node. All binding commands or state values which are set under this node must refer to IDs returned by the shader program specified here.

ImportantImportant

Changing the bound shader program used for rendering is an expensive operation, which is why this information is set at a high level in the render tree. Applications should aim for the absolute minimum number of changes to the shader program, so you should attempt to group all your content which shares the same shader program under the one render pass in the same IProgramNode node, and rely on child IStateGroupNode objects to divide content further if needed.

ImportantImportant

It is strongly recommended to minimize the number of separate shaders your application uses. Shader programs can be very large and involve many conditional tests, and still be much more efficient than using sets of separate smaller shaders and having to change programs multiple times during the rendering process. For this reason, your application should aim to use large shader programs which provide state values to enable different kinds of operations as needed, such as texturing, stippling, lighting, or shading effects.

WarningWarning

The associated IShaderProgram for a program node can only be set once. Since all bindings and state changes associated with a program depend on the particular program that has been bound, changing the program would necessitate changing all the content which has been added to it in some way. If a new program is required, a new node must be constructed to use it.

Usage

SuccessToken BindShaderProgram(IShaderProgram* program);

Argument list

program [IShaderProgram*]
The IShaderProgram to use for content under this node

Return value

[SuccessToken]
True if the enumeration process was successful, false otherwise. An assertion will be raised in debug builds if the result isn't tested.

See also