krita/ui

KisOpenGLProgram Class Reference

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

#include <kis_opengl_program.h>

Inheritance diagram for KisOpenGLProgram:

List of all members.

Public Member Functions

 KisOpenGLProgram ()
virtual ~KisOpenGLProgram ()
virtual void activate ()
bool active () const
void attachShader (KisOpenGLShader &shader)
void detachShader (KisOpenGLShader &shader)
QString getInfoLog () const
GLhandleARB handle () const
bool isValid () const
void link ()
void setUniformVariable (const GLchar *variableName, GLfloat value) const
void setUniformVariable (const GLchar *variableName, GLint i) const
void setUniformVariable (const GLchar *variableName, const QPointF &value) const
void setUniformVariable (const GLchar *variableName, GLfloat v0, GLfloat v1) const
void setUniformVariable (const GLchar *variableName, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3) const
GLint uniformVariableLocation (const GLchar *variableName) const

Static Public Member Functions

static void deactivate ()

Protected Attributes

bool m_isValid
GLhandleARB m_program

Detailed Description

An encapsulation of an OpenGL Shading Language program object.

Create a KisOpenGLProgram then create one or more KisOpenGLVertexShader and KisOpenGLFragmentShader objects, attach them to the program with attachShader() and link() the program. Check if the link was successful (isValid() returns true), and if not, check the info log (getInfoLog()) for error messages.

When the program is ready to be used, activate() it and set any uniform variables with setUniformVariable(). Call deactivate() when the program has finished being used.

Definition at line 40 of file kis_opengl_program.h.


Constructor & Destructor Documentation

KisOpenGLProgram::KisOpenGLProgram (  ) 

Create a program object.

Definition at line 27 of file kis_opengl_program.cpp.

KisOpenGLProgram::~KisOpenGLProgram (  )  [virtual]

Destructor.

Definition at line 40 of file kis_opengl_program.cpp.


Member Function Documentation

void KisOpenGLProgram::activate (  )  [virtual]

Activate the program, making it the active program object in the render context.

Reimplemented in KisOpenGLHDRExposureProgram.

Definition at line 193 of file kis_opengl_program.cpp.

bool KisOpenGLProgram::active (  )  const

Returns true if this program is the active program object in the render context.

Definition at line 209 of file kis_opengl_program.cpp.

void KisOpenGLProgram::attachShader ( KisOpenGLShader shader  ) 

Attach a shader object to the program.

Parameters:
shader The shader to attach

Definition at line 128 of file kis_opengl_program.cpp.

void KisOpenGLProgram::deactivate (  )  [static]

Deactivate the program so that it is no longer the active program object in the render context.

Definition at line 202 of file kis_opengl_program.cpp.

void KisOpenGLProgram::detachShader ( KisOpenGLShader shader  ) 

Detach a shader object from the program.

Parameters:
shader The shader to detach

Definition at line 137 of file kis_opengl_program.cpp.

QString KisOpenGLProgram::getInfoLog (  )  const

Returns the information log generated by the OpenGL driver while linking the program.

If the link failed, check this for error messages indicating the reason for the failure.

Definition at line 168 of file kis_opengl_program.cpp.

GLhandleARB KisOpenGLProgram::handle (  )  const

Returns the handle of the program object.

Definition at line 49 of file kis_opengl_program.cpp.

bool KisOpenGLProgram::isValid (  )  const

Returns true if the program successfully linked and is ready to be used.

Definition at line 224 of file kis_opengl_program.cpp.

void KisOpenGLProgram::link (  ) 

Link the program.

If isValid() returns false after linking, getInfoLog() can be used to view error messages generated by the OpenGL driver.

Definition at line 146 of file kis_opengl_program.cpp.

void KisOpenGLProgram::setUniformVariable ( const GLchar *  variableName,
GLfloat  value 
) const

Set a float scalar uniform variable value.

The program must be activated before variables can be set.

Parameters:
variableName The name of the variable
value The value to set the variable to

Definition at line 102 of file kis_opengl_program.cpp.

void KisOpenGLProgram::setUniformVariable ( const GLchar *  variableName,
GLint  i 
) const

Set an integer scalar uniform variable value.

The program must be activated before variables can be set.

Parameters:
variableName The name of the variable
i The value to set the variable to

Definition at line 115 of file kis_opengl_program.cpp.

void KisOpenGLProgram::setUniformVariable ( const GLchar *  variableName,
const QPointF value 
) const

Set a vec2 uniform variable value.

The program must be activated before variables can be set.

Parameters:
variableName The name of the variable
value The value to set the variable to

Definition at line 97 of file kis_opengl_program.cpp.

void KisOpenGLProgram::setUniformVariable ( const GLchar *  variableName,
GLfloat  v0,
GLfloat  v1 
) const

Set a vec2 uniform variable value.

The program must be activated before variables can be set.

Parameters:
variableName The name of the variable
v0 The value to set the first component to
v1 The value to set the second component to

Definition at line 84 of file kis_opengl_program.cpp.

void KisOpenGLProgram::setUniformVariable ( const GLchar *  variableName,
GLfloat  v0,
GLfloat  v1,
GLfloat  v2,
GLfloat  v3 
) const

Set a vec4 uniform variable value.

The program must be activated before variables can be set.

Parameters:
variableName The name of the variable
v0 The value to set the first component to
v1 The value to set the second component to
v2 The value to set the third component to
v3 The value to set the fourth component to

Definition at line 71 of file kis_opengl_program.cpp.

GLint KisOpenGLProgram::uniformVariableLocation ( const GLchar *  variableName  )  const

Return the location of a uniform variable.

Parameters:
variableName The name of the variable

Definition at line 54 of file kis_opengl_program.cpp.


Member Data Documentation

bool KisOpenGLProgram::m_isValid [protected]

True if the program has been successfully linked.

Definition at line 166 of file kis_opengl_program.h.

GLhandleARB KisOpenGLProgram::m_program [protected]

The handle of the program object.

Definition at line 161 of file kis_opengl_program.h.


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