FastUIDraw
Classes | Public Types | Public Member Functions | List of all members
fastuidraw::glsl::ShaderSource Class Reference

A ShaderSource represents the source code to a GLSL shader, specifying blocks of source code and macros to use. More...

#include <shader_source.hpp>

Classes

class  MacroSet
 

Public Types

enum  add_location_t { push_back, push_front }
 Enumeration to determine if source code or a macro. More...
 
enum  extension_enable_t { require_extension, enable_extension, warn_extension, disable_extension }
 Enumeration to indicate extension enable flags. More...
 
enum  source_t { from_file, from_string, from_resource }
 Enumeration to indiciate the source for a shader. More...
 

Public Member Functions

 ShaderSource (void)
 
 ShaderSource (const ShaderSource &obj)
 
ShaderSourceadd_macro (c_string macro_name, c_string macro_value="", enum add_location_t loc=push_back)
 
ShaderSourceadd_macro (c_string macro_name, uint32_t macro_value, enum add_location_t loc=push_back)
 
ShaderSourceadd_macro (c_string macro_name, int32_t macro_value, enum add_location_t loc=push_back)
 
ShaderSourceadd_macro (c_string macro_name, float macro_value, enum add_location_t loc=push_back)
 
template<typename T >
ShaderSourceadd_macro_float (c_string macro_name, T macro_value)
 
template<typename T >
ShaderSourceadd_macro_i32 (c_string macro_name, T macro_value)
 
template<typename T >
ShaderSourceadd_macro_u32 (c_string macro_name, T macro_value)
 
ShaderSourceadd_macros (const MacroSet &macros, enum add_location_t loc=push_back)
 
ShaderSourceadd_source (c_string str, enum source_t tp=from_file, enum add_location_t loc=push_back)
 
ShaderSourceadd_source (const ShaderSource &obj)
 
c_string assembled_code (bool code_only=false) const
 
ShaderSourceoperator= (const ShaderSource &obj)
 
ShaderSourceremove_macro (c_string macro_name, enum add_location_t loc=push_back)
 
ShaderSourceremove_macros (const MacroSet &macros, enum add_location_t loc=push_back)
 
ShaderSourcespecify_extension (c_string ext_name, enum extension_enable_t tp=enable_extension)
 
ShaderSourcespecify_extensions (const ShaderSource &obj)
 
ShaderSourcespecify_version (c_string v)
 
void swap (ShaderSource &obj)
 
c_string version (void) const
 

Detailed Description

A ShaderSource represents the source code to a GLSL shader, specifying blocks of source code and macros to use.

Definition at line 39 of file shader_source.hpp.

Member Enumeration Documentation

◆ add_location_t

Enumeration to determine if source code or a macro.

Enumerator
push_back 

add the source code or macro to the back.

push_front 

add the source code or macro to the front.

Definition at line 73 of file shader_source.hpp.

◆ extension_enable_t

Enumeration to indicate extension enable flags.

Enumerator
require_extension 

Requires the named GLSL extension, i.e. will add "#extension extension_name: require" to GLSL source code.

enable_extension 

Enables the named GLSL extension, i.e. will add "#extension extension_name: enable" to GLSL source code.

warn_extension 

Enables the named GLSL extension, but request that the GLSL compiler issues warning when the extension is used, i.e. will add "#extension extension_name: warn" to GLSL source code.

disable_extension 

Disables the named GLSL extension, i.e. will add "#extension extension_name: disable" to GLSL source code.

Definition at line 93 of file shader_source.hpp.

◆ source_t

Enumeration to indiciate the source for a shader.

Enumerator
from_file 

Shader source code is taken from the file whose name is the passed string.

from_string 

The passed string is the shader source code.

from_resource 

The passed string is label for a string of text fetched with fastuidraw::fetch_static_resource(). The resource will be IGNORED if the last byte of resource is not 0 (which indicates end-of-string).

Definition at line 46 of file shader_source.hpp.

Constructor & Destructor Documentation

◆ ShaderSource() [1/2]

fastuidraw::glsl::ShaderSource::ShaderSource ( void  )

Ctor.

◆ ShaderSource() [2/2]

fastuidraw::glsl::ShaderSource::ShaderSource ( const ShaderSource obj)

Copy ctor.

Parameters
objvalue from which to copy

Member Function Documentation

◆ add_macro() [1/4]

ShaderSource& fastuidraw::glsl::ShaderSource::add_macro ( c_string  macro_name,
c_string  macro_value = "",
enum add_location_t  loc = push_back 
)

Add a macro to this ShaderSource. Functionally, will insert #define macro_name macro_value in the GLSL source code.

Parameters
macro_namename of macro
macro_valuevalue to which macro is given
loclocation to add macro within code

◆ add_macro() [2/4]

ShaderSource& fastuidraw::glsl::ShaderSource::add_macro ( c_string  macro_name,
uint32_t  macro_value,
enum add_location_t  loc = push_back 
)

Add a macro to this ShaderSource. Functionally, will insert #define macro_name macro_value in the GLSL source code.

Parameters
macro_namename of macro
macro_valuevalue to which macro is given
loclocation to add macro within code

◆ add_macro() [3/4]

ShaderSource& fastuidraw::glsl::ShaderSource::add_macro ( c_string  macro_name,
int32_t  macro_value,
enum add_location_t  loc = push_back 
)

Add a macro to this ShaderSource. Functionally, will insert #define macro_name macro_value in the GLSL source code.

Parameters
macro_namename of macro
macro_valuevalue to which macro is given
loclocation to add macro within code

◆ add_macro() [4/4]

ShaderSource& fastuidraw::glsl::ShaderSource::add_macro ( c_string  macro_name,
float  macro_value,
enum add_location_t  loc = push_back 
)

Add a macro to this ShaderSource. Functionally, will insert #define macro_name macro_value in the GLSL source code.

Parameters
macro_namename of macro
macro_valuevalue to which macro is given
loclocation to add macro within code

◆ add_macro_float()

template<typename T >
ShaderSource& fastuidraw::glsl::ShaderSource::add_macro_float ( c_string  macro_name,
macro_value 
)
inline

Add a macro to this MacroSet for casted to float

Parameters
macro_namename of macro
macro_valuevalue to which macro is given

Definition at line 379 of file shader_source.hpp.

◆ add_macro_i32()

template<typename T >
ShaderSource& fastuidraw::glsl::ShaderSource::add_macro_i32 ( c_string  macro_name,
macro_value 
)
inline

Add a macro to this MacroSet for casted to int32_t

Parameters
macro_namename of macro
macro_valuevalue to which macro is given

Definition at line 366 of file shader_source.hpp.

◆ add_macro_u32()

template<typename T >
ShaderSource& fastuidraw::glsl::ShaderSource::add_macro_u32 ( c_string  macro_name,
macro_value 
)
inline

Add a macro to this MacroSet for casted to uint32_t

Parameters
macro_namename of macro
macro_valuevalue to which macro is given

Definition at line 353 of file shader_source.hpp.

◆ add_macros()

ShaderSource& fastuidraw::glsl::ShaderSource::add_macros ( const MacroSet macros,
enum add_location_t  loc = push_back 
)

Add macros of a MacroSet to this ShaderSource. Functionally, will insert #define macro_name macro_value in the GLSL source code for each macro in the MacroSet.

Parameters
macrosset of macros to add
loclocation to add macro within code

◆ add_source() [1/2]

ShaderSource& fastuidraw::glsl::ShaderSource::add_source ( c_string  str,
enum source_t  tp = from_file,
enum add_location_t  loc = push_back 
)

Add shader source code to this ShaderSource.

Parameters
strstring that is a filename, GLSL source or a resource name
tpinterpretation of str, i.e. determines if str is a filename, raw GLSL source or a resource
loclocation to add source

◆ add_source() [2/2]

ShaderSource& fastuidraw::glsl::ShaderSource::add_source ( const ShaderSource obj)

Add the sources from another ShaderSource object.

Parameters
objShaderSource object from which to absorb

◆ assembled_code()

c_string fastuidraw::glsl::ShaderSource::assembled_code ( bool  code_only = false) const

Returns the GLSL code assembled. The returned string is only gauranteed to be valid up until the ShaderSource object is modified.

Parameters
code_onlyif true only, return the GLSL code without the additions of version, extension and FastUIDraw convenience functions and macros.

◆ operator=()

ShaderSource& fastuidraw::glsl::ShaderSource::operator= ( const ShaderSource obj)

Assignment operator.

Parameters
objvalue from which to copy

◆ remove_macro()

ShaderSource& fastuidraw::glsl::ShaderSource::remove_macro ( c_string  macro_name,
enum add_location_t  loc = push_back 
)

Functionally, will insert #undef macro_name in the GLSL source code.

Parameters
macro_namename of macro
loclocation to add macro within code

◆ remove_macros()

ShaderSource& fastuidraw::glsl::ShaderSource::remove_macros ( const MacroSet macros,
enum add_location_t  loc = push_back 
)

Remove macros of a MacroSet to this ShaderSource. Functionally, will insert #undef macro_name in the GLSL source code for each macro in the MacroSet.

Parameters
macrosset of macros to remove
loclocation to add macro within code

◆ specify_extension()

ShaderSource& fastuidraw::glsl::ShaderSource::specify_extension ( c_string  ext_name,
enum extension_enable_t  tp = enable_extension 
)

Specifiy an extension and usage.

Parameters
ext_namename of GL extension
tpusage of extension

◆ specify_extensions()

ShaderSource& fastuidraw::glsl::ShaderSource::specify_extensions ( const ShaderSource obj)

Add all the extension specifacation from another ShaderSource object to this ShaderSource objects. Extension already set in this ShaderSource that are specified in obj are overwritten to the values specified in obj.

Parameters
objShaderSource object from which to take

◆ specify_version()

ShaderSource& fastuidraw::glsl::ShaderSource::specify_version ( c_string  v)

Specifies the version of GLSL to which to declare the shader. An empty string indicates to not have a "#version" directive in the shader. String is -copied-.

◆ swap()

void fastuidraw::glsl::ShaderSource::swap ( ShaderSource obj)

Swap operation

Parameters
objobject with which to swap

◆ version()

c_string fastuidraw::glsl::ShaderSource::version ( void  ) const

Returns the value set by specify_version(). Returned pointer is only valid until the next time that specify_version() is called.


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