openGL work and other parts

This commit is contained in:
2016-09-11 12:11:54 +02:00
parent 69dfbe6693
commit d910e88220
43 changed files with 4813 additions and 261 deletions

40
map/Renderable.h Normal file
View File

@@ -0,0 +1,40 @@
#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