Mon, 09 Mar 2020 14:21:54 +0200
ldraw::Id is now templated for extra type safety
#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<gl::ShaderProgram> program{std::nullopt}; QOpenGLVertexArrayObject vertexArrayObject; };