Turbo Engine 0.3
A C++ game engine using Allegro 5
turbo::ShaderLibrary Class Reference

Owns named shader programs and materials. More...

#include <ShaderLibrary.hpp>

Public Member Functions

 ShaderLibrary ()=default
Shaderload_source (const std::string &name, const std::string &vertex_src, const std::string &pixel_src)
 Compile GLSL source and register it. Null + logged on failure.
Shaderload_files (const std::string &name, const Path &vertex_path, const Path &pixel_path)
 Compile GLSL from files and register it. Null + logged on failure.
Shaderadd (const std::string &name, Shader *shader)
 Register an already-built shader (takes ownership).
Shaderget (const std::string &name) const
bool has (const std::string &name) const
Shaderdefault_shader ()
 The default Allegro program, created on first use. Always valid.
Materialcreate_material (const std::string &name, const std::string &shader_name)
 Create a material bound to a registered shader (null if missing).
Materialmaterial (const std::string &name) const
std::vector< std::string > shader_names () const
std::vector< std::string > material_names () const

Detailed Description

Owns named shader programs and materials.

This is the registry the engine/editor talk to instead of juggling raw Shader pointers. Shaders are owned here (unique_ptr); materials reference them. Loading reports compile/link failures (and returns null) so a broken shader never silently produces a blank screen.

Constructor & Destructor Documentation

◆ ShaderLibrary()

turbo::ShaderLibrary::ShaderLibrary ( )
default

Member Function Documentation

◆ add()

Shader * turbo::ShaderLibrary::add ( const std::string & name,
Shader * shader )

Register an already-built shader (takes ownership).

◆ create_material()

Material * turbo::ShaderLibrary::create_material ( const std::string & name,
const std::string & shader_name )

Create a material bound to a registered shader (null if missing).

◆ default_shader()

Shader * turbo::ShaderLibrary::default_shader ( )

The default Allegro program, created on first use. Always valid.

◆ get()

Shader * turbo::ShaderLibrary::get ( const std::string & name) const

◆ has()

bool turbo::ShaderLibrary::has ( const std::string & name) const

◆ load_files()

Shader * turbo::ShaderLibrary::load_files ( const std::string & name,
const Path & vertex_path,
const Path & pixel_path )

Compile GLSL from files and register it. Null + logged on failure.

◆ load_source()

Shader * turbo::ShaderLibrary::load_source ( const std::string & name,
const std::string & vertex_src,
const std::string & pixel_src )

Compile GLSL source and register it. Null + logged on failure.

◆ material()

Material * turbo::ShaderLibrary::material ( const std::string & name) const

◆ material_names()

std::vector< std::string > turbo::ShaderLibrary::material_names ( ) const

◆ shader_names()

std::vector< std::string > turbo::ShaderLibrary::shader_names ( ) const

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