jGL
Loading...
Searching...
No Matches
Public Member Functions | List of all members
jGL::GL::glShader Struct Reference

An OpenGL implementation of Shader. More...

#include <glShader.h>

Inheritance diagram for jGL::GL::glShader:
Inheritance graph
[legend]
Collaboration diagram for jGL::GL::glShader:
Collaboration graph
[legend]

Public Member Functions

 glShader (const char *v, const char *f)
 Construct a glShader from a vertex and fragment source.
 
 glShader ()
 Construct an empty glShader.
 
 glShader (std::string path, std::string name)
 Construct a glShader from source given by paths.
 
 ~glShader ()
 
void create ()
 Create the shader program.
 
void release ()
 Destroy the shader program.
 
void compile ()
 Compile the shader program.
 
void use ()
 Use the shader program (and compile if required).
 
bool isCompiled ()
 Checks if the glShader is compiled.
 
bool isProgram ()
 Checks if an OpenGL program is created.
 
- Public Member Functions inherited from jGL::Shader
 Shader (const char *v, const char *f)
 Construct a Shader from a vertex and fragment source.
 
 Shader ()
 Construct an empty Shader.
 
 Shader (std::string path, std::string name)
 Construct a Shader from source given by paths.
 
virtual ~Shader ()=default
 
bool operator== (const Shader &s)
 
bool lint ()
 Check for common shader errors.
 
template<class T >
void setUniform (std::string name, T value)
 Set a Uniform to a value.
 
const std::string & getVertex () const
 
const std::string & getFragment () const
 
template<class T >
jGLUniform< T > getUniform (std::string name)
 Get a Uniform by name.
 
std::vector< std::string > getUniformNames ()
 Get all the parsed uniforms in the Shader.
 
std::string displayVertexSource () const
 Display the vertex shader with line numbers.
 
std::string displayFragmentSource () const
 Display the fragment shader with line numbers.
 

Additional Inherited Members

- Protected Member Functions inherited from jGL::Shader
std::string parseShaderSource (std::ifstream &file)
 
bool parseUniforms ()
 
std::string formatWithLineNumbers (std::string shader) const
 
template<class T >
void detectUniformsAndCreate (std::string code)
 
- Protected Attributes inherited from jGL::Shader
std::string vertex
 
std::string fragment
 
std::unordered_map< std::string, std::shared_ptr< AbstractjGLUniform > > uniforms
 

Detailed Description

An OpenGL implementation of Shader.

Constructor & Destructor Documentation

◆ glShader() [1/3]

jGL::GL::glShader::glShader ( const char *  v,
const char *  f 
)
inline

Construct a glShader from a vertex and fragment source.

Parameters
vvertex shader source.
ffragment shader source.

◆ glShader() [2/3]

jGL::GL::glShader::glShader ( )
inline

Construct an empty glShader.

◆ glShader() [3/3]

jGL::GL::glShader::glShader ( std::string  path,
std::string  name 
)
inline

Construct a glShader from source given by paths.

Parameters
pathpath the .vs and .fs shader sources.
namename of sources in path: name.vs and name.fs

◆ ~glShader()

jGL::GL::glShader::~glShader ( )
inline

Member Function Documentation

◆ compile()

void jGL::GL::glShader::compile ( )
virtual

Compile the shader program.

Remarks
If not a program, call glShader::create.

Implements jGL::Shader.

◆ create()

void jGL::GL::glShader::create ( )

Create the shader program.

◆ isCompiled()

bool jGL::GL::glShader::isCompiled ( )
inline

Checks if the glShader is compiled.

Returns
true it is compiled.
false it is not compiled.

◆ isProgram()

bool jGL::GL::glShader::isProgram ( )
inline

Checks if an OpenGL program is created.

Returns
true a program has been created.
false a program has not been created.

◆ release()

void jGL::GL::glShader::release ( )

Destroy the shader program.

◆ use()

void jGL::GL::glShader::use ( )
virtual

Use the shader program (and compile if required).

Remarks
If not compiled call glShader::compile.

Implements jGL::Shader.


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