![]() |
Scanframe Modular Application 0.1.0
|
Shader program having a default vertex and fragment shader. More...
#include <ShaderProgram.h>
Public Types | |
enum | Attribute { aPosition , aNormal , aColor , aTexCoord } |
Enumeration of available shader attributes to map data in the object buffers. The names of the enumerates need to correspond with the names in the vertex shader source. More... | |
enum | Uniform { uProgram , uPointSize , uModelMatrix , uViewMatrix , uOffsetMatrix , uProjectionMatrix , uLightPosition , uLightDirection , uCutoff , uOuterCutoff , uLightColor , uAmbientStrength , uDiffuseStrength , uSpecularStrength , uShininess , uColor , uTexture , uTextureEnable } |
Enumeration of available shader uniforms. The names of the enumerates need to correspond with the names in the fragment shader source. More... | |
Public Member Functions | |
Q_ENUM (Attribute) | |
Q_ENUM (Uniform) | |
ShaderProgram (QObject *parent=nullptr) | |
Constructs a new shader program and attaches it to parent. The program will be invalid until addShader() is called. The shader program will be associated with the current QOpenGLContext. | |
const QOpenGLContext * | context () const |
Get the OpenGL context of the program. | |
bool | link () override |
Overridden from base class. Adds the shader sources to this instance. | |
int | attributeLocation (Attribute sa) const |
Gets layout input location of the given shader attribute. | |
template<typename T > | |
T | getUniform (Uniform su) |
template<typename T > | |
void | setUniform (Uniform su, const T &value) |
Sets a uniform value by type. | |
void | report (std::ostream &os) const |
Writes information on the shader programs. | |
Shader program having a default vertex and fragment shader.
Enumeration of available shader attributes to map data in the object buffers. The names of the enumerates need to correspond with the names in the vertex shader source.
Enumeration of available shader uniforms. The names of the enumerates need to correspond with the names in the fragment shader source.
Enumerator | |
---|---|
uProgram | Fragment uniform int for selecting the fragment program. Where the default is 'passthrough' and value 1 uses the 'spotlight' program. |
uPointSize | Vertex uniform float for setting the size a point when 'GL_PROGRAM_POINT_SIZE' is enabled. |
uModelMatrix | Vertex uniform mat4 for positioning an object in the 3D space. |
uViewMatrix | Vertex uniform mat4 for view/camera orientation position and passed by the vertex program and retrieved from the uViewMatrix. |
uOffsetMatrix | Vertex uniform mat4 as optional offset matrix for the model view matrix. The matrix translation W-value is the actual usage switch. |
uProjectionMatrix | Vertex and fragment uniform mat4 for the projection matrix set when the window resized using getPerspectiveMatrix(). |
uLightPosition | Fragment uniform vec3 for positioning the spotlight. |
uLightDirection | Fragment uniform vec3 setting the direction of the spotlight. |
uCutoff | Fragment uniform vec3 cutoff angle in radians for the spotlight. |
uOuterCutoff | Fragment uniform float outer cutoff angle in radians for the spotlight. |
uLightColor | Fragment uniform vec4 for the light color in general. |
uAmbientStrength | Fragment uniform vec4 for the ambient light strength. |
uDiffuseStrength | Fragment uniform float for the diffused light strength. |
uSpecularStrength | Fragment uniform float for the specular light strength. |
uShininess | Fragment uniform float for the surface reflection light strength. |
uColor | Vertex uniform vec4 for a fixed color for drawing and is used when the alpha value is non-zero. |
uTexture | Fragment uniform sampler2D for sampling of the texture. |
uTextureEnable | Fragment uniform int to switch to texture for selecting the color. |
|
explicit |
Constructs a new shader program and attaches it to parent. The program will be invalid until addShader() is called. The shader program will be associated with the current QOpenGLContext.
int sf::xgl::ShaderProgram::attributeLocation | ( | Attribute | sa | ) | const |
Gets layout input location of the given shader attribute.
const QOpenGLContext * sf::xgl::ShaderProgram::context | ( | ) | const |
Get the OpenGL context of the program.
T sf::xgl::ShaderProgram::getUniform | ( | Uniform | su | ) |
|
override |
Overridden from base class. Adds the shader sources to this instance.
sf::xgl::ShaderProgram::Q_ENUM | ( | Attribute | ) |
sf::xgl::ShaderProgram::Q_ENUM | ( | Uniform | ) |
void sf::xgl::ShaderProgram::report | ( | std::ostream & | os | ) | const |
Writes information on the shader programs.
os |
void sf::xgl::ShaderProgram::setUniform | ( | Uniform | su, |
const T & | value | ||
) |
Sets a uniform value by type.
T | Type of the passed value. |
su | Uniform to be set. |
value | Value content. |