krita/ui

KisOpenGLShader Class Reference

An encapsulation of an OpenGL Shading Language shader object. More...

#include <kis_opengl_shader.h>

Inheritance diagram for KisOpenGLShader:

List of all members.

Public Member Functions

virtual ~KisOpenGLShader ()
QString getInfoLog ()
GLuint handle () const
bool isValid () const
void loadSourceCodeFromCStrings (GLsizei numSourceCodeStrings, const GLchar **sourceCodeStrings, const GLint *stringLengths)
void loadSourceCodeFromFile (const QString &sourceCodeFilename)
void loadSourceCodeFromQString (QString sourceCodeString)

Protected Member Functions

 KisOpenGLShader (GLenum shaderType)

Protected Attributes

GLuint m_shader
bool m_valid

Detailed Description

An encapsulation of an OpenGL Shading Language shader object.

Create a shader and load its source code. The code will be compiled and if there are no errors, isValid() will return true. The shader can then be attached to a KisOpenGLProgram for use.

If the compilation failed, error messages generated by the OpenGL driver can be viewed with getInfoLog().

You cannot create a KisOpenGLShader directly, but should use KisOpenGLFragmentShader or KisOpenGLVertexShader instead.

Definition at line 42 of file kis_opengl_shader.h.


Constructor & Destructor Documentation

KisOpenGLShader::~KisOpenGLShader (  )  [virtual]

Definition at line 47 of file kis_opengl_shader.cpp.

KisOpenGLShader::KisOpenGLShader ( GLenum  shaderType  )  [protected]

Definition at line 33 of file kis_opengl_shader.cpp.


Member Function Documentation

QString KisOpenGLShader::getInfoLog (  ) 

Returns the information log obtained from the result of compiling the shader.

Definition at line 141 of file kis_opengl_shader.cpp.

GLuint KisOpenGLShader::handle (  )  const

Returns the handle for this shader object.

Definition at line 136 of file kis_opengl_shader.cpp.

bool KisOpenGLShader::isValid (  )  const

Returns true if the shader is valid and can be attached to a program.

It is valid if its source code was successfully loaded and compiled.

Definition at line 131 of file kis_opengl_shader.cpp.

void KisOpenGLShader::loadSourceCodeFromCStrings ( GLsizei  numSourceCodeStrings,
const GLchar **  sourceCodeStrings,
const GLint *  stringLengths 
)

Load the shader source code from the array of strings specified by sourceCodeStrings.

The number of strings in the array is specified by numSourceCodeStrings. If stringLengths is NULL, each string is assumed to be null terminated. If stringLengths is a value other than NULL, it points to an array containing a string length for each of the corresponding elements of sourceCodeStrings. Each element in the length array may contain the length of the corresponding string (the null character is not counted as part of the string length) or a value less than 0 to indicate that the string is null terminated.

The source code strings and lengths can be freed after loading as the shader makes a copy.

This is a wrapper for the glShaderSource() function.

Parameters:
numSourceCodeStrings The number of source code strings to load
sourceCodeStrings An array of pointers to the source code strings
stringLengths An array containing the lengths of each source code string

Definition at line 56 of file kis_opengl_shader.cpp.

void KisOpenGLShader::loadSourceCodeFromFile ( const QString sourceCodeFilename  ) 

Load the shader source code from the given file, which will be searched for in the 'kis_shaders' resource directory (krita/data/shaders).

Parameters:
sourceCodeFilename The file to read the source code from

Definition at line 80 of file kis_opengl_shader.cpp.

void KisOpenGLShader::loadSourceCodeFromQString ( QString  sourceCodeString  ) 

Load the shader source code from the QString specified by sourceCodeString.

The source code string can be freed after loading as the shader makes a copy.

This is a wrapper for the glShaderSource() function.

Parameters:
sourceCodeStrings An array of pointers to the source code strings

Definition at line 117 of file kis_opengl_shader.cpp.


Member Data Documentation

GLuint KisOpenGLShader::m_shader [protected]

Definition at line 103 of file kis_opengl_shader.h.

bool KisOpenGLShader::m_valid [protected]

Definition at line 104 of file kis_opengl_shader.h.


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