Otter  0.9.8.91
2d Game Development Framework based on SFML.Net
 All Classes Namespaces Functions Variables Enumerations Properties
Otter.Shader Class Reference

Class representing a shader written in GLSL. Warning: Visual Studio encoding must be set to Western European (Windows) Codepage 1252 when editing shaders! More details here: http://blog.pixelingene.com/2008/07/file-encodings-matter-when-writing-pixel-shaders/ More...

Public Member Functions

 Shader (string vertexFile, string fragmentFile)
 Creates a Shader using a file as the source for the vertex and fragment shader. More...
 
 Shader (Stream vertexStream, Stream fragmentStream)
 Create a Shader using a stream as the source of the vertex and fragment shader. More...
 
 Shader (ShaderType shaderType, Stream source)
 Create a shader using a stream as the source and a ShaderType parameter. More...
 
 Shader (string source)
 Creates a Shader using a file path source, and auto detects which type of shader it is. If the file path contains ".frag" or ".fs" it is assumed to be a fragment shader. More...
 
 Shader (Shader copy)
 Creates a shader using a copy of another shader. More...
 
 Shader (ShaderType shaderType, string source)
 Creates a shader using a file path and a ShaderType parameter. More...
 
void SetParameter (string name, Color color)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, Color color)
 Set a parameter on the shader. More...
 
void SetParameter (string name, float x)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, float x)
 Set a parameter on the shader. More...
 
void SetParameter (string name, float x, float y)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, float x, float y)
 Set a parameter on the shader. More...
 
void SetParameter (string name, Vector2 xy)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, Vector2 xy)
 Set a parameter on the shader. More...
 
void SetParameter (string name, Vector3 xyz)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, Vector3 xyz)
 Set a parameter on the shader. More...
 
void SetParameter (string name, Vector4 xyzw)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, Vector4 xyzw)
 Set a parameter on the shader. More...
 
void SetParameter (string name, float x, float y, float z)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, float x, float y, float z)
 Set a parameter on the shader. More...
 
void SetParameter (string name, float x, float y, float z, float w)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, float x, float y, float z, float w)
 Set a parameter on the shader. More...
 
void SetParameter (string name, Texture texture)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, Texture texture)
 Set a parameter on the shader. More...
 
void SetParameter (string name, string textureSource)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, string textureSource)
 Set a parameter on the shader. More...
 
void SetParameter (string name, Matrix matrix)
 Set a parameter on the shader. More...
 
void SetParameter (Enum name, Matrix matrix)
 Set a parameter on the shader. More...
 

Static Public Member Functions

static SFML.Graphics.Shader FromString (string vertexShader, string fragmentShader)
 Load both the vertex and fragment shaders from source codes in memory More...
 
static Shader FromString (ShaderType shaderType, string shader)
 Creates a Shader using source code in memory More...
 
static void AddParameter (Enum name, string nameInShader)
 Store a shader parameter name by an Enum value. After storing a parameter this way you can use SetParameter on shader instances with the Enum value and it will retrieve the parameter name string. More...
 
static string Parameter (Enum name)
 Get the parameter string stored with the Enum key. More...
 

Detailed Description

Class representing a shader written in GLSL. Warning: Visual Studio encoding must be set to Western European (Windows) Codepage 1252 when editing shaders! More details here: http://blog.pixelingene.com/2008/07/file-encodings-matter-when-writing-pixel-shaders/

Constructor & Destructor Documentation

Otter.Shader.Shader ( string  vertexFile,
string  fragmentFile 
)

Creates a Shader using a file as the source for the vertex and fragment shader.

Parameters
vertexFileThe file path to the vertex shader.
fragmentFileThe file path to the fragment shader.
Otter.Shader.Shader ( Stream  vertexStream,
Stream  fragmentStream 
)

Create a Shader using a stream as the source of the vertex and fragment shader.

Parameters
vertexStreamThe stream for the vertex shader.
fragmentStreamThe stream for the fragment shader.
Otter.Shader.Shader ( ShaderType  shaderType,
Stream  source 
)

Create a shader using a stream as the source and a ShaderType parameter.

Parameters
shaderTypeThe shader type (fragment or vertex)
sourceThe stream for the shader.
Otter.Shader.Shader ( string  source)

Creates a Shader using a file path source, and auto detects which type of shader it is. If the file path contains ".frag" or ".fs" it is assumed to be a fragment shader.

Parameters
sourceThe file path.
Otter.Shader.Shader ( Shader  copy)

Creates a shader using a copy of another shader.

Parameters
copyThe shader to copy.
Otter.Shader.Shader ( ShaderType  shaderType,
string  source 
)

Creates a shader using a file path and a ShaderType parameter.

Parameters
shaderTypeThe shader type (fragment or vertex)
sourceThe file path.

Member Function Documentation

static void Otter.Shader.AddParameter ( Enum  name,
string  nameInShader 
)
static

Store a shader parameter name by an Enum value. After storing a parameter this way you can use SetParameter on shader instances with the Enum value and it will retrieve the parameter name string.

If your shader has a parameter named "overlayColor" you can do this: Shader.SetParameter(ShaderParams.OverlayColor, "overlayColor"); And then on a shader instance you can do this: someImageWithAShader.Shader.SetParameter(ShaderParams.OverlayColor, Color.Red);

Parameters
nameThe Enum value to use as the key for the shader parameter name.
nameInShaderThe name of the parameter in the shader code.
static SFML.Graphics.Shader Otter.Shader.FromString ( string  vertexShader,
string  fragmentShader 
)
static

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

This function can load both the vertex and the fragment shaders, or only one of them: pass NULL if you don't want to load either the vertex shader or the fragment shader. The sources must be valid shaders in GLSL language. GLSL is a C-like language dedicated to OpenGL shaders; you'll probably need to read a good documentation for it before writing your own shaders.

Parameters
vertexShaderString containing the source code of the vertex shader
fragmentShaderString containing the source code of the fragment shader
Returns
New shader instance
static Shader Otter.Shader.FromString ( ShaderType  shaderType,
string  shader 
)
static

Creates a Shader using source code in memory

Parameters
shaderTypeType of Shader
shaderGLSL code in memory
Returns
New Shader
static string Otter.Shader.Parameter ( Enum  name)
static

Get the parameter string stored with the Enum key.

Parameters
nameThe Enum name that is the key for the string parameter.
Returns
The string parameter.
void Otter.Shader.SetParameter ( string  name,
Color  color 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
colorThe color to set it to.
void Otter.Shader.SetParameter ( Enum  name,
Color  color 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
colorThe color to set it to.
void Otter.Shader.SetParameter ( string  name,
float  x 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe value to set it to.
void Otter.Shader.SetParameter ( Enum  name,
float  x 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe value to set it to.
void Otter.Shader.SetParameter ( string  name,
float  x,
float  y 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe first value of a vec2.
yThe first value of a vec2.
void Otter.Shader.SetParameter ( Enum  name,
float  x,
float  y 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe first value of a vec2.
yThe first value of a vec2.
void Otter.Shader.SetParameter ( string  name,
Vector2  xy 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xyA Vector2 to set.
void Otter.Shader.SetParameter ( Enum  name,
Vector2  xy 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xyA Vector2 to set.
void Otter.Shader.SetParameter ( string  name,
Vector3  xyz 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xyzA Vector3 to set.
void Otter.Shader.SetParameter ( Enum  name,
Vector3  xyz 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xyzA Vector3 to set.
void Otter.Shader.SetParameter ( string  name,
Vector4  xyzw 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xyzwA Vector4 to set.
void Otter.Shader.SetParameter ( Enum  name,
Vector4  xyzw 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xyzwA Vector4 to set.
void Otter.Shader.SetParameter ( string  name,
float  x,
float  y,
float  z 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe first value of a vec3.
yThe second value of a vec3.
zThe third value of a vec3.
void Otter.Shader.SetParameter ( Enum  name,
float  x,
float  y,
float  z 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe first value of a vec3.
yThe second value of a vec3.
zThe third value of a vec3.
void Otter.Shader.SetParameter ( string  name,
float  x,
float  y,
float  z,
float  w 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe first value of a vec4.
yThe second value of a vec4.
zThe third value of a vec4.
wThe fourth value of a vec4.
void Otter.Shader.SetParameter ( Enum  name,
float  x,
float  y,
float  z,
float  w 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
xThe first value of a vec4.
yThe second value of a vec4.
zThe third value of a vec4.
wThe fourth value of a vec4.
void Otter.Shader.SetParameter ( string  name,
Texture  texture 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
textureThe texture to set it to.
void Otter.Shader.SetParameter ( Enum  name,
Texture  texture 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
textureThe texture to set it to.
void Otter.Shader.SetParameter ( string  name,
string  textureSource 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
textureSourceThe path to an image to load as a texture.
void Otter.Shader.SetParameter ( Enum  name,
string  textureSource 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
textureSourceThe path to an image to load as a texture.
void Otter.Shader.SetParameter ( string  name,
Matrix  matrix 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
matrixThe matrix to use. SFML internally uses 3x3 matrices, but you need to use a mat4 in the shader.
void Otter.Shader.SetParameter ( Enum  name,
Matrix  matrix 
)

Set a parameter on the shader.

Parameters
nameThe parameter in the shader to set.
matrixThe matrix to use. SFML internally uses 3x3 matrices, but you need to use a mat4 in the shader.

The documentation for this class was generated from the following file: