Table of Contents

Class Shader

Namespace
Bonsai.Shaders
Assembly
Bonsai.Shaders.dll

Provides common functionality for executing and updating the state of compiled shader programs.

public abstract class Shader : IDisposable
Inheritance
Shader
Implements
Derived
Inherited Members

Properties

Name

Gets the name of the shader.

public string Name { get; }

Property Value

string

Program

Gets the handle to the shader program object.

public int Program { get; }

Property Value

int

Window

Gets the window containing the graphics context on which to render the shader program.

public ShaderWindow Window { get; }

Property Value

ShaderWindow

Methods

CreateShader()

When overridden in a derived class, compiles the shader program and returns the program object handle.

protected abstract int CreateShader()

Returns

int

A handle to the shader program object.

CreateShaderState(IEnumerable<StateConfiguration>, IEnumerable<UniformConfiguration>, IEnumerable<BufferBindingConfiguration>, FramebufferConfiguration)

Initializes the shader state object used to specify the render state, uniform values, buffer bindings and framebuffer configuration to use when running the shader program.

protected void CreateShaderState(IEnumerable<StateConfiguration> renderState, IEnumerable<UniformConfiguration> shaderUniforms, IEnumerable<BufferBindingConfiguration> bufferBindings, FramebufferConfiguration framebuffer)

Parameters

renderState IEnumerable<StateConfiguration>

The collection of configuration objects specifying the render states required for running the shader program.

shaderUniforms IEnumerable<UniformConfiguration>

The collection of configuration objects specifying the default values of uniform variables in the shader program.

bufferBindings IEnumerable<BufferBindingConfiguration>

The collection of configuration objects specifying the buffer bindings to set before running the shader.

framebuffer FramebufferConfiguration

The configuration state of the framebuffer object used for render to texture passes.

Dispatch()

Loads the shader program into the current render state and dispatches all pending render operations.

public void Dispatch()

Dispose()

Releases all resources used by the Shader class.

public void Dispose()

Dispose(bool)

Releases all resources used by the Shader class.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources.

OnDispatch()

Returns any actions that should be executed before running the shader program.

protected virtual Action OnDispatch()

Returns

Action

An Action object to be called before running the shader program. If the return value is null, no action will be executed.

Update(Action)

Schedules an action for execution when running the shader program. Any render operations called as part of the action will execute in the context of this shader program.

public void Update(Action action)

Parameters

action Action

The Action to invoke when running the shader program.