pub struct Shaders {
pub shader_330: ShaderPair,
pub shader_110: ShaderPair,
pub shader_300_es: ShaderPair,
pub shader_100_es: ShaderPair,
}Expand description
Contains the shader code for a spritesheet.
Passed to the renderer with
SpritesheetBuilder::shaders.
§The GLSL versions
As you might need to include tweaks for every GLSL version, you
can provide versions of your shader code for each. However,
usually the #version 100/#version 110 and #version 300 es/#version 330 shaders are identical aside from the version
string. To make this use-case more ergonomic, you can just leave
the version preprocessor line out, and the relevant one is
inserted during runtime. Then you can use the same
ShaderPair for shader_110 and
shader_100, for example.
Additionally: if you don’t include a version preprocessor,
precision mediump float; is added to the shader’s OpenGL ES
version (in addition to the automatically inserted version
preprocessor), as it’s required in OpenGL ES shaders but not
desktop OpenGL ones.
As an example, the following shader_300_es code:
void main() {}Will be modified into the following in an OpenGL ES 3.0 context:
#version 300 es
precision mediump float;
void main() {}§Example
use fae::{Shaders, SpritesheetBuilder};
// If you want to just change the fragment shaders, create a default Shaders:
let mut shaders = Shaders::default();
// And then apply your changes:
shaders.shader_330.fragment_shader = fragment_shader_code_330.clone();
shaders.shader_300_es.fragment_shader = fragment_shader_code_330;
shaders.shader_110.fragment_shader = fragment_shader_code_110.clone();
shaders.shader_100_es.fragment_shader = fragment_shader_code_110;
// Then you can use the shaders when creating a Spritesheet:
let spritesheet = SpritesheetBuilder::default()
.shaders(shaders)
.build(&mut ctx);Fields§
§shader_330: ShaderPairThe #version 330 version of the shader, for OpenGL 3.3 and above.
shader_110: ShaderPairThe #version 110 version of the shader, for OpenGL versions before 3.3.
shader_300_es: ShaderPairThe #version 300 es version of the shader, for OpenGL ES 3.0 and WebGL 2.0.
shader_100_es: ShaderPairThe #version 100 version of the shader, for OpenGL ES 2.0 and WebGL 1.0.