pub struct GLSLShader {
pub version: GLSLVersion,
pub stage: GLSLShaderStage,
pub extensions: Vec<String>,
pub defines: Vec<(String, Option<String>)>,
pub structs: Vec<GLSLStruct>,
pub inputs: Vec<GLSLVariable>,
pub outputs: Vec<GLSLVariable>,
pub uniforms: Vec<GLSLVariable>,
pub globals: Vec<GLSLVariable>,
pub functions: Vec<GLSLFunction>,
pub main_body: Vec<String>,
}Expand description
A complete GLSL shader for a single pipeline stage.
Fields§
§version: GLSLVersionTarget GLSL version.
stage: GLSLShaderStagePipeline stage.
extensions: Vec<String>Extension enable directives (e.g. "GL_ARB_shader_storage_buffer_object").
defines: Vec<(String, Option<String>)>Global #define macros (name, optional value).
structs: Vec<GLSLStruct>Struct type definitions (emitted before globals).
inputs: Vec<GLSLVariable>Global in variables (stage inputs).
outputs: Vec<GLSLVariable>Global out variables (stage outputs).
uniforms: Vec<GLSLVariable>Global uniform variables.
globals: Vec<GLSLVariable>Additional global variables (e.g. shared memory in compute).
functions: Vec<GLSLFunction>Helper functions (emitted before main).
main_body: Vec<String>Body statements of the implicit void main() function.
Implementations§
Source§impl GLSLShader
impl GLSLShader
Sourcepub fn new(version: GLSLVersion, stage: GLSLShaderStage) -> Self
pub fn new(version: GLSLVersion, stage: GLSLShaderStage) -> Self
Create a new, empty shader for the given version and stage.
Sourcepub fn add_extension(&mut self, ext: impl Into<String>)
pub fn add_extension(&mut self, ext: impl Into<String>)
Add an extension directive.
Sourcepub fn add_define(&mut self, name: impl Into<String>)
pub fn add_define(&mut self, name: impl Into<String>)
Add a #define macro without a value.
Sourcepub fn add_define_value(
&mut self,
name: impl Into<String>,
value: impl Into<String>,
)
pub fn add_define_value( &mut self, name: impl Into<String>, value: impl Into<String>, )
Add a #define macro with a value.
Sourcepub fn add_struct(&mut self, s: GLSLStruct)
pub fn add_struct(&mut self, s: GLSLStruct)
Add a struct definition.
Sourcepub fn add_input(&mut self, v: GLSLVariable)
pub fn add_input(&mut self, v: GLSLVariable)
Add a stage input.
Sourcepub fn add_output(&mut self, v: GLSLVariable)
pub fn add_output(&mut self, v: GLSLVariable)
Add a stage output.
Sourcepub fn add_uniform(&mut self, v: GLSLVariable)
pub fn add_uniform(&mut self, v: GLSLVariable)
Add a uniform variable.
Sourcepub fn add_global(&mut self, v: GLSLVariable)
pub fn add_global(&mut self, v: GLSLVariable)
Add a global variable.
Sourcepub fn add_function(&mut self, f: GLSLFunction)
pub fn add_function(&mut self, f: GLSLFunction)
Add a helper function.
Sourcepub fn add_main_statement(&mut self, stmt: impl Into<String>)
pub fn add_main_statement(&mut self, stmt: impl Into<String>)
Append a statement to main.
Trait Implementations§
Source§impl Clone for GLSLShader
impl Clone for GLSLShader
Source§fn clone(&self) -> GLSLShader
fn clone(&self) -> GLSLShader
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more