qxLib
Public Member Functions | Static Public Member Functions | List of all members
qx::base_shader_program Class Reference

Shader program class. More...

#include <shader_program.h>

Public Member Functions

void Init () noexcept
 Init shader program.
 
template<GLenum ShaderType>
void AttachShader (shader_base< ShaderType > *pShader) noexcept
 Attach shader to the program. More...
 
string Link () noexcept
 Link attached shaders. More...
 
void Use () const noexcept
 Use shader program.
 
void Unuse () const noexcept
 Drop current shader.
 
GLint GetParameter (GLenum eParameter) const noexcept
 Get shader program parameter. More...
 
GLuint GetBufferName () const noexcept
 Get shader buffer name. More...
 
template<class T >
void SetUniform (GLint nUniformLocation, const T *pValue, GLsizei nCount) noexcept
 Specify the value of a uniform variable. More...
 
template<class T >
void SetUniform (const GLchar *pszName, const T *pValue, GLsizei nCount) noexcept
 Specify the value of a uniform variable. More...
 
template<class T >
void SetUniform (GLint nUniformLocation, const T &value) noexcept
 Specify the value of a uniform variable. More...
 
template<class T >
void SetUniform (const GLchar *pszName, const T &value) noexcept
 Specify the value of a uniform variable. More...
 
GLint GetUniformLocation (const GLchar *pszName) const noexcept
 Get uniform location based on it's name. More...
 

Static Public Member Functions

static bool AddInclude (const char *pszName, GLint nNameLength, const char *pszText, GLint nTextLength) noexcept
 Add include string. More...
 
static void DispatchCompute (GLuint nGroupsX, GLuint nGroupsY, GLuint nGroupsZ) noexcept
 Dispatch program compute. More...
 

Detailed Description

Shader program class.

~

Author
Khrapov
Date
16.01.2020

Definition at line 28 of file shader_program.h.

Member Function Documentation

◆ AddInclude()

bool qx::base_shader_program::AddInclude ( const char *  pszName,
GLint  nNameLength,
const char *  pszText,
GLint  nTextLength 
)
inlinestaticnoexcept

Add include string.

ARB_shading_language_include is required for this function calling of this function must be before shader's compilation usage example: #version 440 core #extension GL_ARB_shading_language_include : require #include "/header.h"

Parameters
pszName- name that you will #include in shader (should be with leading '/')
nNameLength- name length
pszText- text that will be placed in shader instead of #include
nTextLength- text length
Return values
-true if include extension is supported and successfully added

Definition at line 214 of file shader_program.inl.

◆ AttachShader()

template<GLenum ShaderType>
void qx::base_shader_program::AttachShader ( shader_base< ShaderType > *  pShader)
inlinenoexcept

Attach shader to the program.

Template Parameters
ShaderType- shader type
Parameters
pShader- shader object pointer

Definition at line 30 of file shader_program.inl.

◆ DispatchCompute()

void qx::base_shader_program::DispatchCompute ( GLuint  nGroupsX,
GLuint  nGroupsY,
GLuint  nGroupsZ 
)
inlinestaticnoexcept

Dispatch program compute.

Parameters
nGroupsX- The number of work groups to be launched in the X dimension
nGroupsY- The number of work groups to be launched in the Y dimension
nGroupsZ- The number of work groups to be launched in the Z dimension

Definition at line 229 of file shader_program.inl.

◆ GetBufferName()

GLuint qx::base_shader_program::GetBufferName ( ) const
inlinenoexcept

Get shader buffer name.

Return values
-shader buffer name

Definition at line 69 of file shader_program.inl.

◆ GetParameter()

GLint qx::base_shader_program::GetParameter ( GLenum  eParameter) const
inlinenoexcept

Get shader program parameter.

Parameters
eParameter- shader program parameter
See also
https://www.khronos.org/registry/OpenGL-Refpages/gl4/html/glGetProgram.xhtml
Return values
-shader program parameter

Definition at line 62 of file shader_program.inl.

◆ GetUniformLocation()

GLint qx::base_shader_program::GetUniformLocation ( const GLchar *  pszName) const
inlinenoexcept

Get uniform location based on it's name.

Parameters
pszName- uniform string name
Return values
-location number

Definition at line 209 of file shader_program.inl.

◆ Link()

string qx::base_shader_program::Link ( )
inlinenoexcept

Link attached shaders.

Return values
-error string or empty string if success

Definition at line 35 of file shader_program.inl.

◆ SetUniform() [1/4]

template<class T >
void qx::base_shader_program::SetUniform ( const GLchar *  pszName,
const T &  value 
)
inlinenoexcept

Specify the value of a uniform variable.

Template Parameters
T- parameter type
Parameters
pszName- the name of the uniform variable to be modified
value- the value of a uniform variable.

Definition at line 204 of file shader_program.inl.

◆ SetUniform() [2/4]

template<class T >
void qx::base_shader_program::SetUniform ( const GLchar *  pszName,
const T *  pValue,
GLsizei  nCount 
)
inlinenoexcept

Specify the value of a uniform variable.

Template Parameters
T- parameter type
Parameters
pszName- the name of the uniform variable to be modified.
pValue- a pointer to an array of count values that will be used to update the specified uniform variable.
nCount- number of values that are to be modified.

Definition at line 172 of file shader_program.inl.

◆ SetUniform() [3/4]

template<class T >
void qx::base_shader_program::SetUniform ( GLint  nUniformLocation,
const T &  value 
)
inlinenoexcept

Specify the value of a uniform variable.

Template Parameters
T- parameter type
Parameters
nUniformLocation- the location of the uniform variable to be modified
value- the value of a uniform variable

Definition at line 178 of file shader_program.inl.

◆ SetUniform() [4/4]

template<class T >
void qx::base_shader_program::SetUniform ( GLint  nUniformLocation,
const T *  pValue,
GLsizei  nCount 
)
inlinenoexcept

Specify the value of a uniform variable.

Template Parameters
T- parameter type
Parameters
nUniformLocation- the location of the uniform variable to be modified
pValue- a pointer to an array of count values that will be used to update the specified uniform variable.
nCount- number of values that are to be modified.

Definition at line 75 of file shader_program.inl.


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