This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
YASMIN/map/Renderable.h
2016-09-11 12:11:54 +02:00

41 lines
778 B
C++

#ifndef RENDERABLE_H
#define RENDERABLE_H
#include <QOpenGLShaderProgram>
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