Shader

Shader class (vertex and fragment).

Shaders are programs written using a specific language, executed directly by the graphics card and allowing one to apply real-time operations to the rendered entities.

There are two kinds of shaders: - Vertex shaders, that process vertices - Fragment (pixel) shaders, that process pixels

A DSFML Shader can be composed of either a vertex shader alone, a fragment shader alone, or both combined (see the variants of the load functions).

Shaders are written in GLSL, which is a C-like language dedicated to OpenGL shaders. You'll probably need to learn its basics before writing your own shaders for SFML.

Like any D/C/C++ program, a shader has its own variables that you can set from your D application. DSFML's Shader handles 5 different types of variables: - floats - vectors (2, 3, or 4 components) - colors - textures - transforms (matrices)

Constructors

this
this()
Undocumented in source.
this
this(sfShader* shader)
Undocumented in source.

Destructor

~this
~this()
Undocumented in source.

Members

Enums

Type
enum Type

Types of shaders.

Functions

loadFromFile
bool loadFromFile(string filename, Type type)

Load either the vertex or fragment shader from a file.

loadFromFile
bool loadFromFile(string vertexShaderFilename, string fragmentShaderFilename)

Load both the vertex and fragment shaders from files.

loadFromMemory
bool loadFromMemory(string shader, Type type)

Load either the vertex or fragment shader from a source code in memory.

loadFromMemory
bool loadFromMemory(string vertexShader, string fragmentShader)

Load both the vertex and fragment shaders from source codes in memory.

loadFromStream
bool loadFromStream(InputStream stream, Type type)

Load either the vertex or fragment shader from a custom stream.

loadFromStream
bool loadFromStream(InputStream vertexShaderStream, InputStream fragmentShaderStream)

Load both the vertex and fragment shaders from custom streams.

opIndexAssign
void opIndexAssign(float x, string name)

Change a float parameter of the shader.

opIndexAssign
void opIndexAssign(float[] val, string name)

Change variable length vector parameter of the shader. The length of the set of floats must be between 1 and 4.

opIndexAssign
void opIndexAssign(Vector2f vector, string name)

Change a 2-components vector parameter of the shader.

opIndexAssign
void opIndexAssign(Vector3f vector, string name)

Change a 3-components vector parameter of the shader.

opIndexAssign
void opIndexAssign(Color color, string name)

Change a color vector parameter of the shader.

opIndexAssign
void opIndexAssign(Transform transform, string name)

Change a matrix parameter of the shader.

opIndexAssign
void opIndexAssign(const(Texture) texture, string name)

Change a texture parameter of the shader.

opIndexAssign
void opIndexAssign(CurrentTextureType , string name)

Change a texture parameter of the shader.

setParameter
void setParameter(string name, float x)

Change a float parameter of the shader.

setParameter
void setParameter(string name, float x, float y)

Change a 2-components vector parameter of the shader.

setParameter
void setParameter(string name, float x, float y, float z)

Change a 3-components vector parameter of the shader.

setParameter
void setParameter(string name, float x, float y, float z, float w)

Change a 4-components vector parameter of the shader.

setParameter
void setParameter(string name, Vector2f vector)

Change a 2-components vector parameter of the shader.

setParameter
void setParameter(string name, Vector3f vector)

Change a 3-components vector parameter of the shader.

setParameter
void setParameter(string name, Color color)

Change a color vector parameter of the shader.

setParameter
void setParameter(string name, Transform transform)

Change a matrix parameter of the shader.

setParameter
void setParameter(string name, const(Texture) texture)

Change a texture parameter of the shader.

setParameter
void setParameter(string name, CurrentTextureType )

Change a texture parameter of the shader.

Static functions

bind
void bind(Shader shader)

Bind a shader for rendering.

isAvailable
bool isAvailable()

Tell whether or not the system supports shaders.

Static variables

CurrentTexture
CurrentTextureType CurrentTexture;
Undocumented in source.

Structs

CurrentTextureType
struct CurrentTextureType

Special type/value that can be passed to setParameter, and that represents the texture of the object being drawn.

Variables

sfPtr
sfShader* sfPtr;
Undocumented in source.

See Also

Meta

Authors

Laurent Gomila, Jeremy DeHaan