Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
ShaderProgram.h
Go to the documentation of this file.
1#pragma once
2#include <QOpenGLShaderProgram>
3#include <xgl/Types.h>
4#include <xgl/global.h>
5
6namespace sf::xgl
7{
8
12class _XGL_CLASS ShaderProgram final : public QOpenGLShaderProgram
13{
14 Q_OBJECT
15
16 public:
22 {
30 aTexCoord
31 };
32
34
81
83
89 explicit ShaderProgram(QObject* parent = nullptr);
90
95 const QOpenGLContext* context() const;
96
101 bool link() override;
102
108
109 template<typename T>
111
118 template<typename T>
119 void setUniform(Uniform su, const T& value);
120
125 void report(std::ostream& os) const;
126
127 private:
131 struct TypeInfo
132 {
134 GLint location;
136 GLenum type;
138 GLint depth;
139 };
140
144 std::map<Uniform, TypeInfo> _uniforms;
145};
146
147}// namespace sf::xgl
148
149// Include all inlined functions and template implementations.
150#include <xgl/ShaderProgram.hpp>
Shader program having a default vertex and fragment shader.
Definition ShaderProgram.h:13
ShaderProgram(QObject *parent=nullptr)
Constructs a new shader program and attaches it to parent. The program will be invalid until addShade...
const QOpenGLContext * context() const
Get the OpenGL context of the program.
Uniform
Enumeration of available shader uniforms. The names of the enumerates need to correspond with the nam...
Definition ShaderProgram.h:40
@ uProgram
Definition ShaderProgram.h:45
@ uProjectionMatrix
Definition ShaderProgram.h:55
@ uAmbientStrength
Definition ShaderProgram.h:67
@ uModelMatrix
Definition ShaderProgram.h:49
@ uPointSize
Definition ShaderProgram.h:47
@ uLightPosition
Definition ShaderProgram.h:57
@ uLightDirection
Definition ShaderProgram.h:59
@ uShininess
Definition ShaderProgram.h:73
@ uViewMatrix
Definition ShaderProgram.h:51
@ uOffsetMatrix
Definition ShaderProgram.h:53
@ uCutoff
Definition ShaderProgram.h:61
@ uTexture
Definition ShaderProgram.h:77
@ uOuterCutoff
Definition ShaderProgram.h:63
@ uDiffuseStrength
Definition ShaderProgram.h:69
@ uColor
Definition ShaderProgram.h:75
@ uSpecularStrength
Definition ShaderProgram.h:71
@ uLightColor
Definition ShaderProgram.h:65
bool link() override
Overridden from base class. Adds the shader sources to this instance.
T getUniform(Uniform su)
Attribute
Enumeration of available shader attributes to map data in the object buffers. The names of the enumer...
Definition ShaderProgram.h:22
@ aNormal
Definition ShaderProgram.h:26
@ aColor
Definition ShaderProgram.h:28
@ aPosition
Definition ShaderProgram.h:24
int attributeLocation(Attribute sa) const
Gets layout input location of the given shader attribute.
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.
Definition DemoRenderer.h:6
#define _XGL_CLASS
Definition xgl/global.h:35