paysages3d/src/render/opengl/OpenGLShaderProgram.h
Michaël Lemaire 9196be4c05 Merge branch 'master' into vegetation
Conflicts:
	src/render/opengl/OpenGLShaderProgram.cpp
	src/render/opengl/OpenGLShaderProgram.h
	src/render/opengl/opengl_global.h
2015-12-08 01:28:15 +01:00

67 lines
1.5 KiB
C++

#ifndef OPENGLSHADERPROGRAM_H
#define OPENGLSHADERPROGRAM_H
#include "opengl_global.h"
class QOpenGLShaderProgram;
namespace paysages {
namespace opengl {
class OPENGLSHARED_EXPORT OpenGLShaderProgram {
public:
OpenGLShaderProgram(const std::string &name, OpenGLRenderer *renderer);
~OpenGLShaderProgram();
void addVertexSource(const std::string &path);
void addFragmentSource(const std::string &path);
/**
* Draw a VertexArray object.
*
* This will bind the program (compile it if needed), set the uniform variables, and
* ask the array object to bind its VAO and render itself.
*
* *state* is optional and may add ponctual variables to the global state.
*/
void draw(OpenGLVertexArray *vertices, OpenGLSharedState *state = NULL, int start=0, int count=-1);
inline QOpenGLShaderProgram *getProgram() const {
return program;
}
inline OpenGLFunctions *getFunctions() const {
return functions;
}
inline OpenGLRenderer *getRenderer() const {
return renderer;
}
inline OpenGLSharedState *getState() const {
return state;
}
protected:
friend class OpenGLVariable;
private:
bool bind(OpenGLSharedState *state = NULL);
void release();
void compile();
bool compiled;
OpenGLRenderer *renderer;
std::string name;
QOpenGLShaderProgram *program;
OpenGLFunctions *functions;
OpenGLSharedState *state;
std::string source_vertex;
std::string source_fragment;
};
}
}
#endif // OPENGLSHADERPROGRAM_H