2013-12-22 14:04:33 +00:00
|
|
|
#ifndef OPENGLVARIABLE_H
|
|
|
|
#define OPENGLVARIABLE_H
|
|
|
|
|
|
|
|
#include "opengl_global.h"
|
|
|
|
|
2015-12-07 22:32:55 +00:00
|
|
|
class QColor;
|
|
|
|
class QVector3D;
|
|
|
|
class QMatrix4x4;
|
|
|
|
class QImage;
|
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,
|
2015-11-25 22:15:58 +00:00
|
|
|
TYPE_INTEGER,
|
2013-12-22 14:04:33 +00:00
|
|
|
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);
|
2015-12-07 22:32:55 +00:00
|
|
|
~OpenGLVariable();
|
2013-12-22 14:04:33 +00:00
|
|
|
|
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);
|
2015-12-07 22:32:55 +00:00
|
|
|
void set(const QImage &texture, bool repeat = false, bool color = true);
|
2015-11-09 21:30:46 +00:00
|
|
|
void set(const Texture3D *texture, bool repeat = false, bool color = true);
|
|
|
|
void set(const Texture4D *texture, bool repeat = false, bool color = true);
|
2015-11-25 22:15:58 +00:00
|
|
|
void set(int value);
|
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;
|
|
|
|
|
2015-11-25 22:15:58 +00:00
|
|
|
int value_int;
|
2013-12-22 14:04:33 +00:00
|
|
|
float value_float;
|
2015-12-07 22:32:55 +00:00
|
|
|
QColor *value_color;
|
|
|
|
QVector3D *value_vector3;
|
|
|
|
QMatrix4x4 *value_matrix4;
|
|
|
|
float *value_texture_data;
|
2013-12-22 17:05:11 +00:00
|
|
|
|
2015-12-07 22:32:55 +00:00
|
|
|
int texture_size_x;
|
|
|
|
int texture_size_y;
|
|
|
|
int texture_size_z;
|
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
|