Class Avogadro::Rendering::Shader#

class Shader#

Vertex or Fragment shader, combined into a ShaderProgram.

This class creates a Vertex or Fragment shader, that can be attached to a ShaderProgram in order to render geometry etc.

Author

Marcus D. Hanwell

Public Types

enum Type#

Available shader types.

Values:

enumerator Vertex#

Vertex shader

enumerator Fragment#

Fragment shader

enumerator Unknown#

Unknown (default)

Public Functions

explicit Shader(Type type = Unknown, const std::string &source = "")#
~Shader()#
void setType(Type type)#

Set the shader type.

inline Type type() const#

Get the shader type, typically Vertex or Fragment.

void setSource(const std::string &source)#

Set the shader source to the supplied string.

inline std::string source() const#

Get the source for the shader.

inline std::string error() const#

Get the error message (empty if none) for the shader.

inline Index handle() const#

Get the handle of the shader.

bool compile()#

Compile the shader.

Note

A valid context must to current in order to compile the shader.

void cleanup()#

Delete the shader.

Note

This should only be done once the ShaderProgram is done with the Shader.

Protected Attributes

Type m_type#
Index m_handle#
bool m_dirty#
std::string m_source#
std::string m_error#