#ifndef RENDERABLE_H #define RENDERABLE_H #include class Renderable { protected: QOpenGLShaderProgram program; public: /** get the renderable's shader */ QOpenGLShaderProgram& getProgram() {return program;} /** render the renderable */ void render() { program.bind(); _render(); } virtual void initGL() = 0; virtual void _render() = 0; protected: /** helper method to build the shader */ void loadShader(const QString& vertex, const QString& fragment) { if (!program.addShaderFromSourceFile(QOpenGLShader::Vertex, vertex)) {throw "1";} if (!program.addShaderFromSourceFile(QOpenGLShader::Fragment, fragment)) {throw "2";} if (!program.link()) {throw "3";} if (!program.bind()) {throw "4";} } }; #endif // RENDERABLE_H