2013-12-22 14:04:33 +00:00
|
|
|
#ifndef OPENGLVARIABLE_H
|
|
|
|
#define OPENGLVARIABLE_H
|
|
|
|
|
|
|
|
#include "opengl_global.h"
|
|
|
|
|
|
|
|
#include <QColor>
|
|
|
|
#include <QVector3D>
|
2013-12-22 16:30:48 +00:00
|
|
|
#include <QMatrix4x4>
|
2013-12-22 14:04:33 +00:00
|
|
|
|
|
|
|
namespace paysages {
|
|
|
|
namespace opengl {
|
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief OpenGL variable that can be bound to a uniform for shaders.
|
|
|
|
*/
|
2015-11-09 21:30:46 +00:00
|
|
|
class OpenGLVariable {
|
|
|
|
public:
|
2013-12-22 14:04:33 +00:00
|
|
|
typedef enum {
|
|
|
|
TYPE_NONE,
|
|
|
|
TYPE_TEXTURE_2D,
|
|
|
|
TYPE_TEXTURE_3D,
|
|
|
|
TYPE_TEXTURE_4D,
|
|
|
|
TYPE_FLOAT,
|
|
|
|
TYPE_VECTOR3,
|
|
|
|
TYPE_MATRIX4,
|
|
|
|
TYPE_COLOR
|
|
|
|
} OpenGLVariableType;
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
public:
|
2013-12-22 14:04:33 +00:00
|
|
|
OpenGLVariable(const std::string &name);
|
|
|
|
|
2013-12-22 17:05:11 +00:00
|
|
|
void apply(OpenGLShaderProgram *program, int &texture_unit);
|
2013-12-22 14:04:33 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
void set(const Texture2D *texture, bool repeat = false, bool color = true);
|
|
|
|
void set(const Texture3D *texture, bool repeat = false, bool color = true);
|
|
|
|
void set(const Texture4D *texture, bool repeat = false, bool color = true);
|
2013-12-22 14:04:33 +00:00
|
|
|
void set(float value);
|
|
|
|
void set(const Vector3 &vector);
|
2013-12-22 16:30:48 +00:00
|
|
|
void set(const QVector3D &vector);
|
2013-12-22 14:04:33 +00:00
|
|
|
void set(const Matrix4 &matrix);
|
2013-12-22 16:30:48 +00:00
|
|
|
void set(const QMatrix4x4 &matrix);
|
2013-12-22 14:04:33 +00:00
|
|
|
void set(const Color &color);
|
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
protected:
|
|
|
|
void uploadTexture(OpenGLRenderer *renderer);
|
2013-12-22 17:05:11 +00:00
|
|
|
|
2015-11-09 21:30:46 +00:00
|
|
|
private:
|
2013-12-22 14:04:33 +00:00
|
|
|
std::string name;
|
|
|
|
OpenGLVariableType type;
|
|
|
|
|
|
|
|
float value_float;
|
|
|
|
QColor value_color;
|
|
|
|
QVector3D value_vector3;
|
2013-12-22 16:30:48 +00:00
|
|
|
QMatrix4x4 value_matrix4;
|
2015-11-09 21:30:46 +00:00
|
|
|
const Texture2D *value_tex2d;
|
|
|
|
const Texture3D *value_tex3d;
|
|
|
|
const Texture4D *value_tex4d;
|
2013-12-22 17:05:11 +00:00
|
|
|
|
|
|
|
bool texture_toupload;
|
2014-01-05 19:37:51 +00:00
|
|
|
bool texture_repeat;
|
|
|
|
bool texture_color;
|
2013-12-22 17:05:11 +00:00
|
|
|
unsigned int texture_id;
|
2013-12-22 14:04:33 +00:00
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif // OPENGLVARIABLE_H
|