SenOGL  0.2
Library aiming to ease the use of OpenGL
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Shader Class Referenceabstract

Base class for all types of shaders. More...

#include <Shader.hpp>

Inheritance diagram for Shader:
OpenGLObject ComputeShader FragmentShader GeometryShader TesselationControlShader TesselationEvaluationShader VertexShader

Public Member Functions

 Shader ()=default
 Default constructor. More...
 
virtual ~Shader ()
 Destructor. More...
 
virtual void init () override
 Generates a OpenGL object name to manage. More...
 
virtual void cleanup () override
 Deletes the managed OpenGL object. More...
 
void loadFromFile (const std::string &path)
 Loads the source for this shader from the file at path. More...
 
void reload ()
 Reloads shader from file. More...
 
void compile ()
 Compiles this shader. More...
 
bool isValid () const override
 
- Public Member Functions inherited from OpenGLObject
 OpenGLObject ()
 
 OpenGLObject (GLuint handle)
 Constructs a instance managing an existing OpenGL Object. More...
 
 OpenGLObject (const OpenGLObject &)=default
 
 OpenGLObject (OpenGLObject &&)=default
 
OpenGLObjectoperator= (const OpenGLObject &)=default
 
OpenGLObjectoperator= (OpenGLObject &&)=default
 
virtual ~OpenGLObject ()
 
GLuint getName () const
 Returns OpenGL name of the object. More...
 
void setName (GLuint n)
 Sets the OpenGL name of the object managed by this instance /!\ Use with caution ! (assignment operator is probably what you're looking for) More...
 
 operator bool () const
 Syntactic sugar for isValid(). More...
 

Protected Member Functions

virtual GLenum getType () const =0
 

Protected Attributes

std::string _srcPath = ""
 Path to the last file read by loadFromFile. More...
 
bool _compiled = false
 Says if the shader have already been successfully compiled. More...
 
- Protected Attributes inherited from OpenGLObject
GLuint _handle
 OpenGL name of the managed object. More...
 

Detailed Description

Base class for all types of shaders.

Todo:
Add a way to set the source without a file.

Constructor & Destructor Documentation

Shader::Shader ( )
default

Default constructor.

Shader::~Shader ( )
virtual

Destructor.

Member Function Documentation

void Shader::cleanup ( )
overridevirtual

Deletes the managed OpenGL object.

Implements OpenGLObject.

void Shader::compile ( )

Compiles this shader.

Source for the shader must have been set before.

virtual GLenum Shader::getType ( ) const
protectedpure virtual
Returns
Type of the managed shader.
void Shader::init ( )
overridevirtual

Generates a OpenGL object name to manage.

Implements OpenGLObject.

bool Shader::isValid ( ) const
inlineoverridevirtual
Returns
True if properly initialized and compiled, false otherwise.

Reimplemented from OpenGLObject.

void Shader::loadFromFile ( const std::string &  path)

Loads the source for this shader from the file at path.

Parameters
pathPath to the file containing the source for the shader.
void Shader::reload ( )

Reloads shader from file.

(Should be used only after a successfull call to loadFromFile).

See also
loadFromFile

Member Data Documentation

bool Shader::_compiled = false
protected

Says if the shader have already been successfully compiled.

std::string Shader::_srcPath = ""
protected

Path to the last file read by loadFromFile.


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