SLProject 4.0.000
SLGLShader Class Reference

Encapsulation of an OpenGL shader object. More...

#include <SLGLShader.h>

Inheritance diagram for SLGLShader:
[legend]

Public Member Functions

 SLGLShader ()
 Default constructor. More...
 
 SLGLShader (const SLstring &filename, SLShaderType type)
 Ctor with shader filename & shader type. More...
 
 ~SLGLShader () override
 
void load (const SLstring &filename)
 SLGLShader::load loads a shader file into string _shaderSource. More...
 
void loadFromMemory (const SLstring &program)
 SLGLShader::load loads a shader file from memory into memory. More...
 
SLstring typeName ()
 Returns the shader type as string. More...
 
SLShaderType type ()
 
SLuint shaderID () const
 
SLstring code ()
 
void code (SLstring strCode)
 
void file (SLstring strFile)
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 

Static Public Member Functions

static SLstring removeComments (SLstring src)
 SLGLShader::removeComments for C/C++ comments removal from shader code. More...
 

Protected Attributes

SLShaderType _type
 Shader type enumeration. More...
 
SLuint _shaderID
 Program Object. More...
 
SLstring _code
 ASCII Source-Code. More...
 
SLstring _file
 Path & filename of shader. More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Private Member Functions

SLbool createAndCompile (SLVLight *lights)
 SLGLShader::createAndCompile creates & compiles the OpenGL shader object. More...
 
SLstring preprocessPragmas (SLstring code, SLVLight *lights)
 Replaces our own pragma directives in GLSL code. More...
 

Friends

class SLGLProgram
 

Detailed Description

Encapsulation of an OpenGL shader object.

The SLGLShader class represents a shader object of the OpenGL Shading Language (GLSL). It can load & compile an GLSL shader file and is later on attached to an OpenGL program (SLGLProgram). Instances of SLShader are owned and deleted by their program (SLGLProgram).

Constructor & Destructor Documentation

◆ SLGLShader() [1/2]

SLGLShader::SLGLShader ( )

Default constructor.

◆ SLGLShader() [2/2]

SLGLShader::SLGLShader ( const SLstring filename,
SLShaderType  shaderType 
)

Ctor with shader filename & shader type.

If the shader filename does not belong to an existing file the shader code will be generated at a later stage by SLGLProgramGenerated.

Parameters
filenamePath and filename of the shader to be loaded or generated.
shaderTypeShader type: ST_vertex, ST_fragment and ST_geometry.

◆ ~SLGLShader()

SLGLShader::~SLGLShader ( )
override

Member Function Documentation

◆ code() [1/2]

SLstring SLGLShader::code ( )
inline

◆ code() [2/2]

void SLGLShader::code ( SLstring  strCode)
inline

◆ createAndCompile()

SLbool SLGLShader::createAndCompile ( SLVLight lights)
private

SLGLShader::createAndCompile creates & compiles the OpenGL shader object.

Returns
true if compilation was successful

◆ file()

void SLGLShader::file ( SLstring  strFile)
inline

◆ load()

void SLGLShader::load ( const SLstring filename)

SLGLShader::load loads a shader file into string _shaderSource.

◆ loadFromMemory()

void SLGLShader::loadFromMemory ( const SLstring program)

SLGLShader::load loads a shader file from memory into memory.

◆ preprocessPragmas()

SLstring SLGLShader::preprocessPragmas ( SLstring  code,
SLVLight lights 
)
private

Replaces our own pragma directives in GLSL code.

◆ removeComments()

SLstring SLGLShader::removeComments ( SLstring  src)
static

SLGLShader::removeComments for C/C++ comments removal from shader code.

◆ shaderID()

SLuint SLGLShader::shaderID ( ) const
inline

◆ type()

SLShaderType SLGLShader::type ( )
inline

◆ typeName()

SLstring SLGLShader::typeName ( )

Returns the shader type as string.

Friends And Related Function Documentation

◆ SLGLProgram

friend class SLGLProgram
friend

Member Data Documentation

◆ _code

SLstring SLGLShader::_code
protected

ASCII Source-Code.

◆ _file

SLstring SLGLShader::_file
protected

Path & filename of shader.

◆ _shaderID

SLuint SLGLShader::_shaderID
protected

Program Object.

◆ _type

SLShaderType SLGLShader::_type
protected

Shader type enumeration.


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