diff -r a36913fc552a -r f21b800b02a4 src/gl/basicshaderprogram.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/gl/basicshaderprogram.h Fri Mar 06 20:13:10 2020 +0200 @@ -0,0 +1,32 @@ +#pragma once +#include "common.h" + +class AbstractBasicShaderProgram : public QObject, protected QOpenGLFunctions +{ + Q_OBJECT +public: + AbstractBasicShaderProgram(QObject* parent = nullptr); + ~AbstractBasicShaderProgram() = default; + void initialize(); + Q_SLOT void setViewMatrix(const glm::mat4& newViewMatrix); + Q_SLOT void setProjectionMatrix(const glm::mat4& newProjectionMatrix); + Q_SLOT void setModelMatrix(const glm::mat4& newModelMatrix); + void draw(); + void teardown(); +protected: + void setMatrix(const char* name, const glm::mat4& matrix); + void checkForGLErrors(); + virtual const char* vertexShaderSource() const = 0; + virtual const char* fragmentShaderSource() const = 0; + virtual const void* vertexData() const = 0; + virtual int vertexSize() const = 0; + virtual int vertexCount() const = 0; + virtual void setupVertexArrays() = 0; + virtual GLenum drawMode() const = 0; + bool isInitialized = false; + QOpenGLBuffer buffer; + QOpenGLShader vertexShader; + QOpenGLShader fragmentShader; + std::optional program{std::nullopt}; + QOpenGLVertexArrayObject vertexArrayObject; +};