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 };
33
81
87 explicit ShaderProgram(QObject* parent = nullptr);
88
93 const QOpenGLContext* context() const;
94
99 bool link() override;
100
106
107 template<typename T>
109
116 template<typename T>
117 void setUniform(Uniform su, const T& value);
118
123 void report(std::ostream& os) const;
124
125 private:
129 struct TypeInfo
130 {
132 GLint location;
134 GLenum type;
136 GLint depth;
137 };
141 std::map<Uniform, TypeInfo> _uniforms;
142};
143
144}// namespace sf::xgl
145
146// Include all inlined functions and template implementations.
147#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:39
@ uProgram
Definition ShaderProgram.h:44
@ uProjectionMatrix
Definition ShaderProgram.h:54
@ uAmbientStrength
Definition ShaderProgram.h:66
@ uModelMatrix
Definition ShaderProgram.h:48
@ uPointSize
Definition ShaderProgram.h:46
@ uLightPosition
Definition ShaderProgram.h:56
@ uLightDirection
Definition ShaderProgram.h:58
@ uShininess
Definition ShaderProgram.h:72
@ uViewMatrix
Definition ShaderProgram.h:50
@ uOffsetMatrix
Definition ShaderProgram.h:52
@ uCutoff
Definition ShaderProgram.h:60
@ uTexture
Definition ShaderProgram.h:76
@ uOuterCutoff
Definition ShaderProgram.h:62
@ uDiffuseStrength
Definition ShaderProgram.h:68
@ uColor
Definition ShaderProgram.h:74
@ uSpecularStrength
Definition ShaderProgram.h:70
@ uLightColor
Definition ShaderProgram.h:64
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