Sat, 07 Mar 2020 01:20:36 +0200
negative axes are now drawn in darker color
70 | 1 | #pragma once |
2 | #include "common.h" | |
3 | ||
4 | class AbstractBasicShaderProgram : public QObject, protected QOpenGLFunctions | |
5 | { | |
6 | Q_OBJECT | |
7 | public: | |
8 | AbstractBasicShaderProgram(QObject* parent = nullptr); | |
9 | ~AbstractBasicShaderProgram() = default; | |
10 | void initialize(); | |
11 | Q_SLOT void setViewMatrix(const glm::mat4& newViewMatrix); | |
12 | Q_SLOT void setProjectionMatrix(const glm::mat4& newProjectionMatrix); | |
13 | Q_SLOT void setModelMatrix(const glm::mat4& newModelMatrix); | |
14 | void draw(); | |
15 | void teardown(); | |
16 | protected: | |
17 | void setMatrix(const char* name, const glm::mat4& matrix); | |
18 | void checkForGLErrors(); | |
19 | virtual const char* vertexShaderSource() const = 0; | |
20 | virtual const char* fragmentShaderSource() const = 0; | |
21 | virtual const void* vertexData() const = 0; | |
22 | virtual int vertexSize() const = 0; | |
23 | virtual int vertexCount() const = 0; | |
24 | virtual void setupVertexArrays() = 0; | |
25 | virtual GLenum drawMode() const = 0; | |
26 | bool isInitialized = false; | |
27 | QOpenGLBuffer buffer; | |
28 | QOpenGLShader vertexShader; | |
29 | QOpenGLShader fragmentShader; | |
30 | std::optional<gl::ShaderProgram> program{std::nullopt}; | |
31 | QOpenGLVertexArrayObject vertexArrayObject; | |
32 | }; |