globjects  2.0.0.690708773bba
Strict OpenGL objects wrapper.

Encapsulates OpenGL shaders. More...

#include <globjects/include/globjects/Shader.h>

Inheritance diagram for globjects::Shader:
globjects::Object globjects::ChangeListener globjects::Changeable globjects::Instantiator< Shader >

Public Types

enum  IncludeImplementation { IncludeImplementation::ShadingLanguageIncludeARB, IncludeImplementation::Fallback }
 
using IncludePaths = std::vector< std::string >
 
- Public Types inherited from globjects::Object
enum  NameImplementation { NameImplementation::DebugKHR, NameImplementation::Legacy }
 

Public Member Functions

 Shader (const gl::GLenum type, AbstractStringSource *source, const IncludePaths &includePaths=IncludePaths())
 
 Shader (const gl::GLenum type)
 
virtual ~Shader ()
 
virtual void accept (ObjectVisitor &visitor) override
 
gl::GLenum type () const
 
void setSource (AbstractStringSource *source)
 
const AbstractStringSourcesource () const
 
void updateSource ()
 
const IncludePathsincludePaths () const
 
void setIncludePaths (const IncludePaths &includePaths)
 
bool compile () const
 
bool isCompiled () const
 
void invalidate ()
 
gl::GLint get (gl::GLenum pname) const
 
std::string getSource () const
 
bool checkCompileStatus () const
 
std::string infoLog () const
 
std::string typeString () const
 
virtual gl::GLenum objectType () const override
 
- Public Member Functions inherited from globjects::Object
gl::GLuint id () const
 
std::string name () const
 
void setName (const std::string &name)
 
bool hasName () const
 
bool isDefault () const
 
void detach ()
 
- Public Member Functions inherited from globjects::Changeable
 Changeable ()
 
virtual ~Changeable ()
 
void changed () const
 
void registerListener (ChangeListener *listener)
 
void deregisterListener (ChangeListener *listener)
 

Static Public Member Functions

static void hintIncludeImplementation (IncludeImplementation impl)
 
static void globalReplace (const std::string &search, const std::string &replacement)
 
static void globalReplace (const std::string &search, int i)
 
static void clearGlobalReplacements ()
 
static std::unique_ptr< StaticStringSourcesourceFromString (const std::string &sourceString)
 
static std::unique_ptr< FilesourceFromFile (const std::string &filename)
 
static std::unique_ptr< AbstractStringSourceapplyGlobalReplacements (AbstractStringSource *source)
 
static std::string typeString (gl::GLenum type)
 
- Static Public Member Functions inherited from globjects::Object
static void hintNameImplementation (NameImplementation impl)
 
- Static Public Member Functions inherited from globjects::Instantiator< Shader >
static std::unique_ptr< Shadercreate (Args &&...args)
 
static std::unique_ptr< ShaderfromId (gl::GLuint id, Args &&...args)
 

Protected Member Functions

virtual void notifyChanged (const Changeable *changeable) override
 
std::string shaderString () const
 
- Protected Member Functions inherited from globjects::Object
 Object (std::unique_ptr< IDResource > &&resource)
 
virtual ~Object ()
 
- Protected Member Functions inherited from globjects::ChangeListener
void addSubject (Changeable *subject)
 
virtual void removeSubject (Changeable *subject)
 
virtual ~ChangeListener ()
 
- Protected Member Functions inherited from globjects::Changeable
 Changeable ()
 
virtual ~Changeable ()
 
void changed () const
 
void registerListener (ChangeListener *listener)
 
void deregisterListener (ChangeListener *listener)
 

Protected Attributes

gl::GLenum m_type
 
AbstractStringSourcem_source
 
IncludePaths m_includePaths
 
std::set< Program * > m_programs
 
bool m_compiled
 
bool m_compilationFailed
 
- Protected Attributes inherited from globjects::Object
std::unique_ptr< IDResourcem_resource
 
void * m_objectLabelState
 
- Protected Attributes inherited from globjects::ChangeListener
std::set< Changeable * > m_subjects
 
- Protected Attributes inherited from globjects::Changeable
std::set< ChangeListener * > m_listeners
 

Static Protected Attributes

static std::map< std::string, std::string > s_globalReplacements
 

Friends

class Program
 

Detailed Description

Encapsulates OpenGL shaders.

A shader can be constructed using an AbstractStringSource. A shader can be attached to a program using Program::attach(). A Shader subclasses either ChangeListener and Changeable to react to changing shader sources and to propagate this change to ChangeListeners.

See also
http://www.opengl.org/wiki/Shader
Program
ShaderSource
ChangeListener
Changeable

Member Typedef Documentation

using globjects::Shader::IncludePaths = std::vector<std::string>

Member Enumeration Documentation

Enumerator
ShadingLanguageIncludeARB 
Fallback 

Constructor & Destructor Documentation

globjects::Shader::Shader ( const gl::GLenum  type,
AbstractStringSource source,
const IncludePaths includePaths = IncludePaths() 
)
globjects::Shader::Shader ( const gl::GLenum  type)
virtual globjects::Shader::~Shader ( )
virtual

Member Function Documentation

static void globjects::Shader::hintIncludeImplementation ( IncludeImplementation  impl)
static
static void globjects::Shader::globalReplace ( const std::string &  search,
const std::string &  replacement 
)
static
static void globjects::Shader::globalReplace ( const std::string &  search,
int  i 
)
static
static void globjects::Shader::clearGlobalReplacements ( )
static
static std::unique_ptr<StaticStringSource> globjects::Shader::sourceFromString ( const std::string &  sourceString)
static
static std::unique_ptr<File> globjects::Shader::sourceFromFile ( const std::string &  filename)
static
static std::unique_ptr<AbstractStringSource> globjects::Shader::applyGlobalReplacements ( AbstractStringSource source)
static
virtual void globjects::Shader::accept ( ObjectVisitor visitor)
overridevirtual

Implements globjects::Object.

gl::GLenum globjects::Shader::type ( ) const
void globjects::Shader::setSource ( AbstractStringSource source)
const AbstractStringSource* globjects::Shader::source ( ) const
void globjects::Shader::updateSource ( )
const IncludePaths& globjects::Shader::includePaths ( ) const
void globjects::Shader::setIncludePaths ( const IncludePaths includePaths)
bool globjects::Shader::compile ( ) const
bool globjects::Shader::isCompiled ( ) const
void globjects::Shader::invalidate ( )
gl::GLint globjects::Shader::get ( gl::GLenum  pname) const
std::string globjects::Shader::getSource ( ) const
bool globjects::Shader::checkCompileStatus ( ) const
std::string globjects::Shader::infoLog ( ) const
std::string globjects::Shader::typeString ( ) const
virtual gl::GLenum globjects::Shader::objectType ( ) const
overridevirtual

Implements globjects::Object.

static std::string globjects::Shader::typeString ( gl::GLenum  type)
static
virtual void globjects::Shader::notifyChanged ( const Changeable changeable)
overrideprotectedvirtual

Reimplemented from globjects::ChangeListener.

std::string globjects::Shader::shaderString ( ) const
protected

Friends And Related Function Documentation

friend class Program
friend

Member Data Documentation

gl::GLenum globjects::Shader::m_type
protected
AbstractStringSource* globjects::Shader::m_source
protected
IncludePaths globjects::Shader::m_includePaths
protected
std::set<Program *> globjects::Shader::m_programs
protected
bool globjects::Shader::m_compiled
mutableprotected
bool globjects::Shader::m_compilationFailed
mutableprotected
std::map<std::string, std::string> globjects::Shader::s_globalReplacements
staticprotected

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