Shader is a class to handle shaders written in GLSL.
More...
#include <Shader.h>
|
| Shader () |
| Default constructor. More...
|
|
| ~Shader () |
| Destructor. More...
|
|
void | enable () const |
| Enable the current shader. More...
|
|
void | release () |
|
void | loadFiles (const std::string &aVertexShaderFilename, const std::string &aFragmentShaderFilename) |
| Load the vertex and fragment shaders from files. More...
|
|
void | loadFile (const std::string &aComputeShaderFilename) |
| Load the compute shader from a file. More...
|
|
void | setLabels (const std::string &aVertexShaderLabel, const std::string &aFragmentShaderLabel) |
| Set the vertex and fragment shader labels. This is useful for debugging. More...
|
|
void | setLabel (const std::string &aComputeShaderLabel) |
| Set the compute shader label. This is useful for debugging. More...
|
|
void | loadVertexShaderFile (const std::string &aVertexShaderFilename) |
| Load the vertex shader from a file. More...
|
|
void | loadFragmentShaderFile (const std::string &aFragmentShaderFilename) |
| Load the fragment shader from a file. More...
|
|
void | loadComputeShaderFile (const std::string &aComputeShaderFilename) |
| Load the compute shader from a file. More...
|
|
void | loadSource (const std::string &aVertexShaderSourceCode, const std::string &aFragmentShaderSourceCode) |
| Load the shader source code. More...
|
|
void | loadSource (const std::string &aComputeShaderSourceCode) |
| Load the shader source code. More...
|
|
void | loadVertexShaderSource (const std::string &aVertexShaderSourceCode) |
| Load the vertex shader from a string. More...
|
|
void | loadFragmentShaderSource (const std::string &aFragmentShaderSourceCode) |
| Load the fragment shader from a string. More...
|
|
void | loadComputeShaderSource (const std::string &aComputeShaderSourceCode) |
| Load the compute shader from a string. More...
|
|
unsigned int | getProgramHandle () const |
| Accessor on the shader program handle. More...
|
|
bool | isValid () const |
| Accessor on the validity status of the shader. More...
|
|
Shader is a class to handle shaders written in GLSL.
Definition at line 87 of file Shader.h.
◆ Shader()
gVirtualXRay::Shader::Shader |
( |
| ) |
|
◆ ~Shader()
gVirtualXRay::Shader::~Shader |
( |
| ) |
|
◆ compileShader()
unsigned int gVirtualXRay::Shader::compileShader |
( |
int |
aShaderType, |
|
|
int |
aLineNumber, |
|
|
char ** |
aShaderSource |
|
) |
| |
|
protected |
Compile the vertex shader or the fragment shader.
- Parameters
-
aShaderType | type of shader (GL_VERTEX_SHADER, GL_FRAGMENT_SHADER or GL_COMPUTE_SHADER) |
aLineNumber | the number of lines of the source code |
aShaderSource | source code of the vertex or fragment shader |
- Returns
- the corresponding ID
◆ disable()
static void gVirtualXRay::Shader::disable |
( |
| ) |
|
|
static |
Disable the current shader (if any)
◆ enable()
void gVirtualXRay::Shader::enable |
( |
| ) |
const |
Enable the current shader.
◆ getProgramHandle()
unsigned int gVirtualXRay::Shader::getProgramHandle |
( |
| ) |
const |
|
inline |
Accessor on the shader program handle.
- Returns
- the shader program handle
Definition at line 87 of file Shader.inl.
◆ isValid()
bool gVirtualXRay::Shader::isValid |
( |
| ) |
const |
|
inline |
Accessor on the validity status of the shader.
- Returns
- true if the shader is valid, false if it is not
Definition at line 95 of file Shader.inl.
◆ linkProgram()
void gVirtualXRay::Shader::linkProgram |
( |
| ) |
|
|
protected |
Link the vertex and fragment programs.
◆ loadComputeShaderFile()
void gVirtualXRay::Shader::loadComputeShaderFile |
( |
const std::string & |
aComputeShaderFilename | ) |
|
Load the compute shader from a file.
- Parameters
-
aComputeShaderFilename | file name of the compute shader |
◆ loadComputeShaderSource()
void gVirtualXRay::Shader::loadComputeShaderSource |
( |
const std::string & |
aComputeShaderSourceCode | ) |
|
Load the compute shader from a string.
- Parameters
-
aComputeShaderSourceCode | the compute shader source code |
◆ loadFile() [1/2]
void gVirtualXRay::Shader::loadFile |
( |
const std::string & |
aComputeShaderFilename | ) |
|
Load the compute shader from a file.
- Parameters
-
aComputeShaderFilename | file name of the compute shader |
◆ loadFile() [2/2]
int gVirtualXRay::Shader::loadFile |
( |
const std::string & |
aShaderFilename, |
|
|
char **& |
aShaderSource |
|
) |
| |
|
protected |
Load a text file and store its content.
- Parameters
-
aShaderFilename | file name of the vertex or fragment shader |
aShaderSource | source code of the vertex or fragment shader |
- Returns
- the number of lines in the file
◆ loadFiles()
void gVirtualXRay::Shader::loadFiles |
( |
const std::string & |
aVertexShaderFilename, |
|
|
const std::string & |
aFragmentShaderFilename |
|
) |
| |
Load the vertex and fragment shaders from files.
- Parameters
-
aVertexShaderFilename | file name of the vertex shader |
aFragmentShaderFilename | file name of the fragment shader |
◆ loadFragmentShaderFile()
void gVirtualXRay::Shader::loadFragmentShaderFile |
( |
const std::string & |
aFragmentShaderFilename | ) |
|
Load the fragment shader from a file.
- Parameters
-
aFragmentShaderFilename | file name of the fragment shader |
◆ loadFragmentShaderSource()
void gVirtualXRay::Shader::loadFragmentShaderSource |
( |
const std::string & |
aFragmentShaderSourceCode | ) |
|
Load the fragment shader from a string.
- Parameters
-
aFragmentShaderSourceCode | the fragment shader source code |
◆ loadSource() [1/2]
void gVirtualXRay::Shader::loadSource |
( |
const std::string & |
aVertexShaderSourceCode, |
|
|
const std::string & |
aFragmentShaderSourceCode |
|
) |
| |
Load the shader source code.
- Parameters
-
aVertexShaderSourceCode | source code of the vertex shader |
aFragmentShaderSourceCode | source code of the fragment shader |
◆ loadSource() [2/2]
void gVirtualXRay::Shader::loadSource |
( |
const std::string & |
aComputeShaderSourceCode | ) |
|
Load the shader source code.
- Parameters
-
aComputeShaderSourceCode | source code of the compute shader |
◆ loadVertexShaderFile()
void gVirtualXRay::Shader::loadVertexShaderFile |
( |
const std::string & |
aVertexShaderFilename | ) |
|
Load the vertex shader from a file.
- Parameters
-
aVertexShaderFilename | file name of the vertex shader |
◆ loadVertexShaderSource()
void gVirtualXRay::Shader::loadVertexShaderSource |
( |
const std::string & |
aVertexShaderSourceCode | ) |
|
Load the vertex shader from a string.
- Parameters
-
aVertexShaderSourceCode | the vertex shader source code |
◆ release()
void gVirtualXRay::Shader::release |
( |
| ) |
|
Reset (delete the current shader if it is loaded, and restore default values).
◆ releaseComputeSourceMemory()
void gVirtualXRay::Shader::releaseComputeSourceMemory |
( |
| ) |
|
|
inlineprotected |
Release the memory held by the compute shader.
Definition at line 119 of file Shader.inl.
◆ releaseFragmentSourceMemory()
void gVirtualXRay::Shader::releaseFragmentSourceMemory |
( |
| ) |
|
|
inlineprotected |
Release the memory held by the fragment shader.
Definition at line 111 of file Shader.inl.
◆ releaseSourceMemory()
void gVirtualXRay::Shader::releaseSourceMemory |
( |
int & |
aLineNumber, |
|
|
char **& |
aShaderSource |
|
) |
| |
|
protected |
Release the memory held by the vertex shader or the fragment shader.
- Parameters
-
aLineNumber | the number of lines of the source code |
aShaderSource | source code of the vertex or fragment shader |
◆ releaseVertexSourceMemory()
void gVirtualXRay::Shader::releaseVertexSourceMemory |
( |
| ) |
|
|
inlineprotected |
Release the memory held by the vertex shader.
Definition at line 103 of file Shader.inl.
◆ setLabel()
void gVirtualXRay::Shader::setLabel |
( |
const std::string & |
aComputeShaderLabel | ) |
|
|
inline |
Set the compute shader label. This is useful for debugging.
- Parameters
-
aComputeShaderLabel | label of the compute shader |
Definition at line 79 of file Shader.inl.
◆ setLabels()
void gVirtualXRay::Shader::setLabels |
( |
const std::string & |
aVertexShaderLabel, |
|
|
const std::string & |
aFragmentShaderLabel |
|
) |
| |
|
inline |
Set the vertex and fragment shader labels. This is useful for debugging.
- Parameters
-
aVertexShaderLabel | label of the vertex shader |
aFragmentShaderLabel | label of the fragment shader |
Definition at line 69 of file Shader.inl.
◆ m_compute_shader_filename
std::string gVirtualXRay::Shader::m_compute_shader_filename |
|
protected |
Name of the file containing the compute shader.
Definition at line 342 of file Shader.h.
◆ m_compute_shader_id
unsigned int gVirtualXRay::Shader::m_compute_shader_id |
|
protected |
ID of the compute shader.
Definition at line 388 of file Shader.h.
◆ m_compute_shader_label
std::string gVirtualXRay::Shader::m_compute_shader_label |
|
protected |
Label of the compute shader.
Definition at line 330 of file Shader.h.
◆ m_compute_source
char** gVirtualXRay::Shader::m_compute_source |
|
protected |
Source code of the vertex shader.
Definition at line 362 of file Shader.h.
◆ m_compute_source_number_of_lines
int gVirtualXRay::Shader::m_compute_source_number_of_lines |
|
protected |
Number of line of the vertex shader.
Definition at line 366 of file Shader.h.
◆ m_fragment_shader_filename
std::string gVirtualXRay::Shader::m_fragment_shader_filename |
|
protected |
Name of the file containing the fragment shader.
Definition at line 338 of file Shader.h.
◆ m_fragment_shader_id
unsigned int gVirtualXRay::Shader::m_fragment_shader_id |
|
protected |
ID of the fragment shader.
Definition at line 384 of file Shader.h.
◆ m_fragment_shader_label
std::string gVirtualXRay::Shader::m_fragment_shader_label |
|
protected |
Label of the fragment shader.
Definition at line 326 of file Shader.h.
◆ m_fragment_source
char** gVirtualXRay::Shader::m_fragment_source |
|
protected |
Source code of the fragment shader.
Definition at line 354 of file Shader.h.
◆ m_fragment_source_number_of_lines
int gVirtualXRay::Shader::m_fragment_source_number_of_lines |
|
protected |
Number of line of the fragment shader.
Definition at line 358 of file Shader.h.
◆ m_shader_capable
bool gVirtualXRay::Shader::m_shader_capable |
|
staticprotected |
Flag set to true when a shader if fully valid.
Definition at line 318 of file Shader.h.
◆ m_shader_program_id
unsigned int gVirtualXRay::Shader::m_shader_program_id |
|
protected |
ID of the shader program.
Definition at line 376 of file Shader.h.
◆ m_valid
bool gVirtualXRay::Shader::m_valid |
|
protected |
Flag set to true if the vertex shader, the fragment shader and the shader program are all valid
Definition at line 372 of file Shader.h.
◆ m_vertex_shader_filename
std::string gVirtualXRay::Shader::m_vertex_shader_filename |
|
protected |
Name of the file containing the vertex shader.
Definition at line 334 of file Shader.h.
◆ m_vertex_shader_id
unsigned int gVirtualXRay::Shader::m_vertex_shader_id |
|
protected |
ID of the vertex shader.
Definition at line 380 of file Shader.h.
◆ m_vertex_shader_label
std::string gVirtualXRay::Shader::m_vertex_shader_label |
|
protected |
Label of the vertex shader.
Definition at line 322 of file Shader.h.
◆ m_vertex_source
char** gVirtualXRay::Shader::m_vertex_source |
|
protected |
Source code of the vertex shader.
Definition at line 346 of file Shader.h.
◆ m_vertex_source_number_of_lines
int gVirtualXRay::Shader::m_vertex_source_number_of_lines |
|
protected |
Number of line of the vertex shader.
Definition at line 350 of file Shader.h.
The documentation for this class was generated from the following files:
- /home/fpvidal/PROGRAMMING/RELEASE/gVirtualXray-2.0.10-Source/gvxr/include/gVirtualXRay/Shader.h
- /home/fpvidal/PROGRAMMING/RELEASE/gVirtualXray-2.0.10-Source/gvxr/include/gVirtualXRay/Shader.inl