KGLLib
Public Member Functions | Protected Member Functions | Protected Attributes
KGLLib::Shader Class Reference

Shader class. More...

#include <shader.h>

Inheritance diagram for KGLLib::Shader:
KGLLib::FragmentShader KGLLib::VertexShader

List of all members.

Public Member Functions

 Shader (GLenum type)
 Shader (GLenum type, const QString &filename)
virtual ~Shader ()
void setSource (const QString &source)
void setSource (const QByteArray &source)
bool compile ()
bool isValid () const
bool isCompiled () const
char * compileLog () const
GLenum type () const
GLuint glId () const

Protected Member Functions

void init (GLenum type)

Protected Attributes

GLuint mGLId
GLenum mType
bool mValid
bool mCompiled
char * mCompileLog

Detailed Description

Shader class.

Encapsulates a shader object. Note that shaders are only intermediate objects used to create Program objects. For simple use cases, you can use Program class which can automatically create and use necessary Shader objects.

See also:
Program

Constructor & Destructor Documentation

KGLLib::Shader::Shader ( GLenum  type)

Creates a shader of given type. You need to manually call setSource() and compile() before the shader can be added to a Program.

KGLLib::Shader::Shader ( GLenum  type,
const QString &  filename 
)

Loads shader of given type from given file. Loaded shader is automatically compiled, so if the compilation succeeds, you can add it to a Program object.

References compile(), and setSource().

KGLLib::Shader::~Shader ( ) [virtual]

Deletes a shader. Shaders can be deleted after they are added to a Program and the program is linked.


Member Function Documentation

bool KGLLib::Shader::compile ( )

Compiles the shader. If compilation succeeds, you can add it to a Program object. If compilation fails, you can see the error using compileLog() method.

Referenced by Shader().

char* KGLLib::Shader::compileLog ( ) const [inline]
Returns:
Compile log of the shader or null if there was none or the shader hasn't been compiled. Note that Shader keeps ownership of the returned string, so you mustn't delete it. TODO: maybe return QString?
void KGLLib::Shader::setSource ( const QString &  source)

Sets shader source to source. Next you will need to compile the shader.

Referenced by Shader().


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