Shader source code and infos. More...
#include <ShaderSource.hpp>
Classes | |
class | LineInfo |
Information about a specific line in ShaderSource. More... | |
Public Member Functions | |
ShaderSource (const std::string &src, const std::string &_sourceName="", int startLine=1, const std::map< int, LineInfo > &_linesInfo=std::map< int, LineInfo >()) | |
Constructor of ShaderSource, load from a standard string or a file. More... | |
ShaderSource (const ShaderSource &ss) | |
ShaderSource Construtor. More... | |
ShaderSource & | operator= (const ShaderSource &c) |
Copy operator. More... | |
bool | empty (void) const |
Test if the source is empty. More... | |
const std::string & | getSource (void) const |
Returns the source as a standard string. More... | |
const std::string & | getSourceName (void) const |
Return the name of the source : the one given with the constructor if any, the filename if it was loaded from a file or a blank string otherwise. More... | |
const char * | getSourceCstr (void) const |
Returns the source as a characters table. More... | |
int | getNumLines (void) const |
Get the number of lines in this source. More... | |
std::string | getLine (int l, bool withNewLine=true) const |
Get a specific line from the source. More... | |
LineInfo | getLineInfo (int l) const |
Get information about the line at the given index. More... | |
Exception | errorLog (const std::string &log) const |
Add some source code information to the output shader compilation log. More... | |
bool | requiresCompatibility (void) const |
Returns true if this Shader is using gl_FragColor and no out vec4 variables (e.g. Mesa <9.0 compatibility for Intel Core I7 with HD Graphics (>2nd Generation)); no call to glBindFragDataLocation is needed). If true, the input vars are indexed on their order of appearance in the shader source. More... | |
int | getVersion (void) const |
Returns the shader version defined in the source (with #version) as an integer. More... | |
const std::vector< std::string > & | getInputVars (void) const |
Return a vector containing the name of all the input textures (uniform sampler*). More... | |
const std::vector< std::string > & | getOutputVars (void) const |
Return a vector containing the name of all the output textures (uniform {vec2, vec3, vec4, ...}). More... | |
const std::vector< std::string > & | getUniformVars (void) const |
Return a vector containing the name of all the uniform variables which are not 2D samplers. More... | |
const std::vector< GLenum > & | getUniformTypes (void) const |
Return a vector containing the type of the uniform variables which are not 2D samplers (see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for a table of possible values). More... | |
Public Attributes | |
std::map< int, LineInfo > | linesInfo |
Map containing information about specific lines of this source. The key represent the line number starting at 1. | |
Static Public Attributes | |
static std::string | portNameForFragColor = "outputTexture" |
Name for the port mapping to gl_FragColor, if used. | |
Shader source code and infos.
Loading a shader from a standard string or a file :
The shader source will be parsed to find input and output ports name. In the case that you are using gl_FragColor, the name of the output port will be the one contained by string ShaderSource::portNameForFragColor.
ShaderSource::ShaderSource | ( | const std::string & | src, |
const std::string & | _sourceName = "" , |
||
int | _startLine = 1 , |
||
const std::map< int, LineInfo > & | _linesInfo = std::map<int,LineInfo>() |
||
) |
Constructor of ShaderSource, load from a standard string or a file.
src | Source data (must have at least one ' ') or filename (without ' '). |
_sourceName | Name of the source. |
_startLine | Correction added to the debugger info (also if loaded from a Layout File for example). |
_linesInfo | Specific information about lines, see ShaderSource::linesInfo and ShaderSource::LineInfo. |
If the source name is left blank and the src parameter is actually a filename, it will be copied as the source name.
ShaderSource::ShaderSource | ( | const ShaderSource & | ss | ) |
ShaderSource Construtor.
ss | Source code of the shader, as a copy. |
bool ShaderSource::empty | ( | void | ) | const |
Test if the source is empty.
Exception ShaderSource::errorLog | ( | const std::string & | log | ) | const |
Add some source code information to the output shader compilation log.
log | Input log to be mixed with source code. |
const std::vector< std::string > & ShaderSource::getInputVars | ( | void | ) | const |
Return a vector containing the name of all the input textures (uniform sampler*).
std::string ShaderSource::getLine | ( | int | l, |
bool | withNewLine = true |
||
) | const |
Get a specific line from the source.
l | The line index. The indices start at 1. |
withNewLine | Set to true if the returned string must contain the new-line character. |
ShaderSource::LineInfo ShaderSource::getLineInfo | ( | int | l | ) | const |
Get information about the line at the given index.
l | The line index. The indices start at 1. |
See ShaderSource::linesInfo on how to supply specific line information.
int ShaderSource::getNumLines | ( | void | ) | const |
Get the number of lines in this source.
const std::vector< std::string > & ShaderSource::getOutputVars | ( | void | ) | const |
Return a vector containing the name of all the output textures (uniform {vec2, vec3, vec4, ...}).
const std::string & ShaderSource::getSource | ( | void | ) | const |
Returns the source as a standard string.
const char * ShaderSource::getSourceCstr | ( | void | ) | const |
Returns the source as a characters table.
const std::string & ShaderSource::getSourceName | ( | void | ) | const |
Return the name of the source : the one given with the constructor if any, the filename if it was loaded from a file or a blank string otherwise.
const std::vector< GLenum > & ShaderSource::getUniformTypes | ( | void | ) | const |
Return a vector containing the type of the uniform variables which are not 2D samplers (see http://www.opengl.org/sdk/docs/man/xhtml/glGetActiveUniform.xml for a table of possible values).
const std::vector< std::string > & ShaderSource::getUniformVars | ( | void | ) | const |
Return a vector containing the name of all the uniform variables which are not 2D samplers.
int ShaderSource::getVersion | ( | void | ) | const |
Returns the shader version defined in the source (with #version) as an integer.
ShaderSource & ShaderSource::operator= | ( | const ShaderSource & | c | ) |
Copy operator.
c | Source. |
bool ShaderSource::requiresCompatibility | ( | void | ) | const |
Returns true if this Shader is using gl_FragColor and no out vec4 variables (e.g. Mesa <9.0 compatibility for Intel Core I7 with HD Graphics (>2nd Generation)); no call to glBindFragDataLocation is needed). If true, the input vars are indexed on their order of appearance in the shader source.