globjects  1.1.0.2f0c753c8647
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::Referenced globjects::HeapOnly

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)
 
 Shader (const gl::GLenum type, AbstractStringSource *source, const IncludePaths &includePaths=IncludePaths())
 
virtual void accept (ObjectVisitor &visitor) override
 
gl::GLenum type () const
 
void setSource (AbstractStringSource *source)
 
void setSource (const std::string &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::Referenced
 Referenced ()
 
void ref () const
 
void unref () const
 
int refCounter () const
 
- Public Member Functions inherited from globjects::HeapOnly
 HeapOnly ()
 
void destroy () const
 
- Public Member Functions inherited from globjects::Changeable
void changed () const
 
void registerListener (ChangeListener *listener)
 
void deregisterListener (ChangeListener *listener)
 

Static Public Member Functions

static void hintIncludeImplementation (IncludeImplementation impl)
 
static ShaderfromString (const gl::GLenum type, const std::string &sourceString, const IncludePaths &includePaths=IncludePaths())
 
static ShaderfromFile (const gl::GLenum type, const std::string &filename, const IncludePaths &includePaths=IncludePaths())
 
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::string typeString (gl::GLenum type)
 
- Static Public Member Functions inherited from globjects::Object
static void hintNameImplementation (NameImplementation impl)
 

Protected Member Functions

virtual ~Shader ()
 
virtual void notifyChanged (const Changeable *changeable) override
 
std::string shaderString () const
 
- Protected Member Functions inherited from globjects::Object
 Object (IDResource *resource)
 
virtual ~Object ()
 
- Protected Member Functions inherited from globjects::Referenced
virtual ~Referenced ()
 
- Protected Member Functions inherited from globjects::HeapOnly
virtual ~HeapOnly ()
 
- Protected Member Functions inherited from globjects::ChangeListener
virtual ~ChangeListener ()
 
- Protected Member Functions inherited from globjects::Changeable
void changed () const
 
void registerListener (ChangeListener *listener)
 
void deregisterListener (ChangeListener *listener)
 

Protected Attributes

gl::GLenum m_type
 
ref_ptr< AbstractStringSourcem_source
 
IncludePaths m_includePaths
 
bool m_compiled
 
bool m_compilationFailed
 
- Protected Attributes inherited from globjects::Object
IDResource * m_resource
 
void * m_objectLabelState
 

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)
globjects::Shader::Shader ( const gl::GLenum  type,
AbstractStringSource source,
const IncludePaths includePaths = IncludePaths() 
)
virtual globjects::Shader::~Shader ( )
protectedvirtual

Member Function Documentation

static void globjects::Shader::hintIncludeImplementation ( IncludeImplementation  impl)
static
static Shader* globjects::Shader::fromString ( const gl::GLenum  type,
const std::string &  sourceString,
const IncludePaths includePaths = IncludePaths() 
)
static
static Shader* globjects::Shader::fromFile ( const gl::GLenum  type,
const std::string &  filename,
const IncludePaths includePaths = IncludePaths() 
)
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
virtual void globjects::Shader::accept ( ObjectVisitor visitor)
overridevirtual

Implements globjects::Object.

gl::GLenum globjects::Shader::type ( ) const
void globjects::Shader::setSource ( AbstractStringSource source)
void globjects::Shader::setSource ( const std::string &  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
ref_ptr<AbstractStringSource> globjects::Shader::m_source
protected
IncludePaths globjects::Shader::m_includePaths
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: