Antkeeper  0.0.1
Public Member Functions | Friends | List of all members
gl::shader_program Class Reference

Shader program which can be linked to shader objects and executed. More...

#include <shader-program.hpp>

Public Member Functions

 shader_program ()
 Creates an empty shader program. More...
 
 ~shader_program ()
 Destroys a shader program. More...
 
 shader_program (const shader_program &)=delete
 
 shader_program (shader_program &&)=delete
 
shader_programoperator= (const shader_program &)=delete
 
shader_programoperator= (shader_program &&)=delete
 
void attach (const shader_object &object)
 Attaches a shader object to the shader program. More...
 
void detach (const shader_object &object)
 Detaches a shader object from the shader program. More...
 
void detach_all ()
 Detaches all shader objects from the shader program. More...
 
bool link ()
 Links all attached shader objects to create an executable shader program. More...
 
bool linked () const noexcept
 Returns true if the shader program has been successfully linked, false otherwise. More...
 
const std::unordered_map< hash::fnv1a32_t, const std::unique_ptr< const shader_variable > > & variables () const noexcept
 Returns all active shader variables in the shader program. More...
 
const shader_variablevariable (hash::fnv1a32_t key) const
 Returns a pointer to an active shader variable with the given name, or nullptr if not found. More...
 
const std::string & info () const noexcept
 Returns the info log that contains debug information when linking fails. More...
 

Friends

class pipeline
 

Detailed Description

Shader program which can be linked to shader objects and executed.

See also
gl::shader_object

Definition at line 40 of file shader-program.hpp.

Constructor & Destructor Documentation

◆ shader_program() [1/3]

gl::shader_program::shader_program ( )

Creates an empty shader program.

Exceptions
std::runtime_errorAn error occurred while creating an OpenGL shader program.

Definition at line 29 of file shader-program.cpp.

◆ ~shader_program()

gl::shader_program::~shader_program ( )

Destroys a shader program.

Definition at line 41 of file shader-program.cpp.

◆ shader_program() [2/3]

gl::shader_program::shader_program ( const shader_program )
delete

◆ shader_program() [3/3]

gl::shader_program::shader_program ( shader_program &&  )
delete

Member Function Documentation

◆ attach()

void gl::shader_program::attach ( const shader_object object)

Attaches a shader object to the shader program.

Attaching a shader object has no effect on a shader program until shader_program::link() is called.

Parameters
objectShader object to attach.
Exceptions
std::runtime_errorShader object is already attached to the shader program.
std::runtime_errorOpenGL shader program is not a valid program object.
std::runtime_errorOpenGL shader object is not a valid shader object.
std::runtime_errorOpenGL shader object is already attached to the shader program.
See also
shader_program::link()

Definition at line 50 of file shader-program.cpp.

◆ detach()

void gl::shader_program::detach ( const shader_object object)

Detaches a shader object from the shader program.

Detaching a shader object has no effect on a shader program until shader_program::link() is called.

Parameters
objectShader object to detach.
Exceptions
std::runtime_errorShader object is not attached to the shader program.
std::runtime_errorOpenGL shader program is not a valid program object.
std::runtime_errorOpenGL shader object is not a valid shader object.
std::runtime_errorOpenGL shader object is not attached to the shader program.
See also
shader_program::link()

Definition at line 76 of file shader-program.cpp.

◆ detach_all()

void gl::shader_program::detach_all ( )

Detaches all shader objects from the shader program.

Exceptions
std::runtime_errorShader object is not attached to the shader program.
std::runtime_errorOpenGL shader program is not a valid program object.
std::runtime_errorOpenGL shader object is not a valid shader object.
std::runtime_errorOpenGL shader object is not attached to the shader program.
See also
shader_program::detach(const shader_object*)

Definition at line 102 of file shader-program.cpp.

◆ info()

const std::string& gl::shader_program::info ( ) const
inlinenoexcept

Returns the info log that contains debug information when linking fails.

Definition at line 145 of file shader-program.hpp.

◆ link()

bool gl::shader_program::link ( )

Links all attached shader objects to create an executable shader program.

Returns
true if the attached shader objects were successfully linked into the shader program, false otherwise.
Warning
All existing of the shader program's variables will be invalidated if the program is re-linked.

Definition at line 110 of file shader-program.cpp.

◆ linked()

bool gl::shader_program::linked ( ) const
inlinenoexcept

Returns true if the shader program has been successfully linked, false otherwise.

Definition at line 110 of file shader-program.hpp.

◆ operator=() [1/2]

shader_program& gl::shader_program::operator= ( const shader_program )
delete

◆ operator=() [2/2]

shader_program& gl::shader_program::operator= ( shader_program &&  )
delete

◆ variable()

const shader_variable* gl::shader_program::variable ( hash::fnv1a32_t  key) const
inline

Returns a pointer to an active shader variable with the given name, or nullptr if not found.

Parameters
key32-bit FNV-1a hash value of a shader variable name.
Returns
Pointer to the active shader variable with the given name, or nullptr if not found.

Definition at line 132 of file shader-program.hpp.

◆ variables()

const std::unordered_map<hash::fnv1a32_t, const std::unique_ptr<const shader_variable> >& gl::shader_program::variables ( ) const
inlinenoexcept

Returns all active shader variables in the shader program.

Returns
Map of 32-bit FNV-1a hash values of shader variable names to shader variables.

Definition at line 120 of file shader-program.hpp.

Friends And Related Function Documentation

◆ pipeline

friend class pipeline
friend

Definition at line 151 of file shader-program.hpp.


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