Table of Contents

Interface IShaderProgram

Namespace
BSGameLib.Game.Rendering
Assembly
BSGameLib.Game.dll

A compiled shader program: its vertex and fragment stages, and the uniforms that are set on them.

public interface IShaderProgram : IDisposable
Inherited Members

Properties

CompileErrors

The compiler's diagnostics when IsCompiled is false; empty otherwise.

string CompileErrors { get; }

Property Value

string

IsCompiled

Whether the program compiled for the active backend. OpenGL compiles a program when it is created and throws if it cannot, so there this is always true. Vulkan compiles on first use and, if it cannot, logs why and draws without the shader - so a game that loads a shader it did not write (a mod, a server owner's) checks this to tell somebody it is broken.

bool IsCompiled { get; }

Property Value

bool

Methods

GetAttribLocation(string)

Returns the location of the vertex attribute called name.

int GetAttribLocation(string name)

Parameters

name string

Returns

int

GetUniformLocation(string)

Returns the location of the uniform called name.

int GetUniformLocation(string name)

Parameters

name string

Returns

int

SetColor(string, Color)

Sets the colour uniform called name to color.

void SetColor(string name, Color color)

Parameters

name string
color Color

SetFloat(string, float)

Sets the float uniform called name.

void SetFloat(string name, float value)

Parameters

name string
value float

SetInt(string, int)

Sets the int uniform called name.

void SetInt(string name, int value)

Parameters

name string
value int

SetMatrix4(string, Matrix4x4)

Sets the mat4 uniform called name.

void SetMatrix4(string name, Matrix4x4 matrix)

Parameters

name string
matrix Matrix4x4

SetVector2(string, Vector2)

Sets the vec2 uniform called name.

void SetVector2(string name, Vector2 value)

Parameters

name string
value Vector2

SetVector3(string, Vector3)

Sets the vec3 uniform called name.

void SetVector3(string name, Vector3 value)

Parameters

name string
value Vector3

SetVector4(string, Vector4)

Sets the vec4 uniform called name.

void SetVector4(string name, Vector4 value)

Parameters

name string
value Vector4

Use()

Makes this the program that later draws use.

void Use()

Verify()

Checks that the program can be used by the active backend. Throws InvalidOperationException when it cannot.

void Verify()

Exceptions

InvalidOperationException

The program is not valid for the active backend.