shaderCustomTex.h 1.29 KB
Newer Older
boustila's avatar
boustila committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
#ifndef __SHADER_CUSTOMTEX__
#define __SHADER_CUSTOMTEX__

#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"

#include "Utils/clippingShader.h"
#include "Utils/textures.h"
#include "Utils/gl_def.h"
#include "Geometry/matrix.h"

using namespace CGoGN;

class ShaderCustomTex : public Utils::ClippingShader
{
protected:
	// shader sources
	static std::string vertexShaderText;
	static std::string fragmentShaderText;
	static std::string geometryShaderText;

	CGoGNGLuint m_unif_unit;
	int m_unit;

	Geom::Vec4f m_col;

	Utils::GTexture* m_tex_ptr;
	Utils::VBO* m_vboPos;
	Utils::VBO* m_vboNormal;
	Utils::VBO* m_vboTexCoord;

	void restoreUniformsAttribs();

public:
	ShaderCustomTex();

	/**
	 * choose the texture unit engine to use for this texture
	 */
	void setTextureUnit(GLenum texture_unit);

	/**
	 * set the texture to use
	 */
	void setTexture(Utils::GTexture* tex);

	/**
	 * activation of texture unit with set texture
	 */
	void activeTexture();

	/**
	 * activation of texture unit with texture id
	 */
	void activeTexture(CGoGNGLuint texId);

	unsigned int setAttributePosition(Utils::VBO* vbo);

	unsigned int setAttributeNormal(Utils::VBO* vbo);

	unsigned int setAttributeTexCoord(Utils::VBO* vbo);

	void setBaseColor(Geom::Vec4f col);

	void setTransformation(Geom::Matrix44f t);
};

#endif