2013-12-21 22:48:54 +00:00
|
|
|
#ifndef OPENGLSHADERPROGRAM_H
|
|
|
|
#define OPENGLSHADERPROGRAM_H
|
|
|
|
|
|
|
|
#include "opengl_global.h"
|
|
|
|
|
|
|
|
class QOpenGLShaderProgram;
|
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace opengl {
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
class OPENGLSHARED_EXPORT OpenGLShaderProgram {
|
|
|
|
public:
|
|
|
|
OpenGLShaderProgram(const std::string &name, OpenGLRenderer *renderer);
|
2013-12-21 22:48:54 +00:00
|
|
|
~OpenGLShaderProgram();
|
|
|
|
|
2015-12-07 22:32:55 +00:00
|
|
|
void addVertexSource(const std::string &path);
|
|
|
|
void addFragmentSource(const std::string &path);
|
2015-11-29 18:18:36 +00:00
|
|
|
|
2015-12-07 22:32:55 +00:00
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
2015-12-08 00:28:15 +00:00
|
|
|
void draw(OpenGLVertexArray *vertices, OpenGLSharedState *state = NULL, int start=0, int count=-1);
|
2013-12-24 10:44:39 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
inline QOpenGLShaderProgram *getProgram() const {
|
|
|
|
return program;
|
|
|
|
}
|
2015-12-07 22:32:55 +00:00
|
|
|
inline OpenGLFunctions *getFunctions() const {
|
|
|
|
return functions;
|
|
|
|
}
|
2015-11-09 21:30:46 +00:00
|
|
|
inline OpenGLRenderer *getRenderer() const {
|
|
|
|
return renderer;
|
|
|
|
}
|
2015-11-25 22:15:58 +00:00
|
|
|
inline OpenGLSharedState *getState() const {
|
|
|
|
return state;
|
|
|
|
}
|
2013-12-24 10:44:39 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
protected:
|
2013-12-22 14:04:33 +00:00
|
|
|
friend class OpenGLVariable;
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
2015-12-07 22:32:55 +00:00
|
|
|
bool bind(OpenGLSharedState *state = NULL);
|
|
|
|
void release();
|
2013-12-22 17:47:24 +00:00
|
|
|
void compile();
|
2013-12-21 22:48:54 +00:00
|
|
|
|
2013-12-22 17:47:24 +00:00
|
|
|
bool compiled;
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
OpenGLRenderer *renderer;
|
2013-12-22 14:04:33 +00:00
|
|
|
|
2015-09-14 17:25:54 +00:00
|
|
|
std::string name;
|
2015-11-09 21:30:46 +00:00
|
|
|
QOpenGLShaderProgram *program;
|
|
|
|
OpenGLFunctions *functions;
|
2013-12-22 17:47:24 +00:00
|
|
|
|
2015-11-25 22:15:58 +00:00
|
|
|
OpenGLSharedState *state;
|
|
|
|
|
2013-12-22 17:47:24 +00:00
|
|
|
std::string source_vertex;
|
|
|
|
std::string source_fragment;
|
2013-12-21 22:48:54 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OPENGLSHADERPROGRAM_H
|