Skip to main content

GLSLShader

Struct GLSLShader 

Source
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: GLSLVersion

Target GLSL version.

§stage: GLSLShaderStage

Pipeline 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

Source

pub fn new(version: GLSLVersion, stage: GLSLShaderStage) -> Self

Create a new, empty shader for the given version and stage.

Source

pub fn add_extension(&mut self, ext: impl Into<String>)

Add an extension directive.

Source

pub fn add_define(&mut self, name: impl Into<String>)

Add a #define macro without a value.

Source

pub fn add_define_value( &mut self, name: impl Into<String>, value: impl Into<String>, )

Add a #define macro with a value.

Source

pub fn add_struct(&mut self, s: GLSLStruct)

Add a struct definition.

Source

pub fn add_input(&mut self, v: GLSLVariable)

Add a stage input.

Source

pub fn add_output(&mut self, v: GLSLVariable)

Add a stage output.

Source

pub fn add_uniform(&mut self, v: GLSLVariable)

Add a uniform variable.

Source

pub fn add_global(&mut self, v: GLSLVariable)

Add a global variable.

Source

pub fn add_function(&mut self, f: GLSLFunction)

Add a helper function.

Source

pub fn add_main_statement(&mut self, stmt: impl Into<String>)

Append a statement to main.

Trait Implementations§

Source§

impl Clone for GLSLShader

Source§

fn clone(&self) -> GLSLShader

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GLSLShader

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.