Coupure prévue mardi 3 Août au matin pour maintenance du serveur. Nous faisons au mieux pour que celle-ci soit la plus brève possible.

shaderFlat.h 3.02 KB
Newer Older
Pierre Kraemer's avatar
Pierre Kraemer committed
1
2
3
/*******************************************************************************
* CGoGN: Combinatorial and Geometric modeling with Generic N-dimensional Maps  *
* version 0.1                                                                  *
4
* Copyright (C) 2009-2012, IGG Team, LSIIT, University of Strasbourg           *
Pierre Kraemer's avatar
Pierre Kraemer committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*                                                                              *
* This library is free software; you can redistribute it and/or modify it      *
* under the terms of the GNU Lesser General Public License as published by the *
* Free Software Foundation; either version 2.1 of the License, or (at your     *
* option) any later version.                                                   *
*                                                                              *
* This library is distributed in the hope that it will be useful, but WITHOUT  *
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or        *
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License  *
* for more details.                                                            *
*                                                                              *
* You should have received a copy of the GNU Lesser General Public License     *
* along with this library; if not, write to the Free Software Foundation,      *
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301 USA.           *
*                                                                              *
20
* Web site: http://cgogn.unistra.fr/                                           *
Pierre Kraemer's avatar
Pierre Kraemer committed
21
22
23
24
* Contact information: cgogn@unistra.fr                                        *
*                                                                              *
*******************************************************************************/

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
25
26
#ifndef __CGOGN_SHADER_FLAT__
#define __CGOGN_SHADER_FLAT__
Pierre Kraemer's avatar
Pierre Kraemer committed
27

Sylvain Thery's avatar
Sylvain Thery committed
28
29
#include "Utils/GLSLShader.h"
#include "Geometry/vector_gen.h"
Pierre Kraemer's avatar
Pierre Kraemer committed
30

Sylvain Thery's avatar
Sylvain Thery committed
31
namespace CGoGN
Pierre Kraemer's avatar
Pierre Kraemer committed
32
{
Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
33

Sylvain Thery's avatar
Sylvain Thery committed
34
namespace Utils
Pierre Kraemer's avatar
Pierre Kraemer committed
35
36
{

Sylvain Thery's avatar
Sylvain Thery committed
37
class ShaderFlat : public GLSLShader
Pierre Kraemer's avatar
Pierre Kraemer committed
38
{
Sylvain Thery's avatar
Sylvain Thery committed
39
40
41
42
43
protected:
	// shader sources
    static std::string vertexShaderText;
    static std::string fragmentShaderText;
    static std::string geometryShaderText;
44

Sylvain Thery's avatar
Sylvain Thery committed
45
    // uniform locations
46
47
	CGoGNGLuint m_unif_ambiant;
	CGoGNGLuint m_unif_diffuse;
Sylvain Thery's avatar
Sylvain Thery committed
48
	CGoGNGLuint m_unif_diffuseback;
49
50
	CGoGNGLuint m_unif_lightPos;
	CGoGNGLuint m_unif_explode;
Pierre Kraemer's avatar
Pierre Kraemer committed
51

52
53
54
	float m_explode;
	Geom::Vec4f m_ambiant;
	Geom::Vec4f m_diffuse;
Sylvain Thery's avatar
Sylvain Thery committed
55
	Geom::Vec4f m_diffuseBack;
56
57
58
59
60
61
62
63
	Geom::Vec3f m_light_pos;

	VBO* m_vboPos;

	void getLocations();

	void restoreUniformsAttribs();

Sylvain Thery's avatar
Sylvain Thery committed
64
65
public:
	ShaderFlat();
66
67
68
69
70
71
72

	void setExplode(float explode);

	void setAmbiant(const Geom::Vec4f& ambiant);

	void setDiffuse(const Geom::Vec4f& diffuse);

Sylvain Thery's avatar
Sylvain Thery committed
73
74
	void setDiffuseBack(const Geom::Vec4f& diffuseb);

75
	void setLightPosition(const Geom::Vec3f& lp);
Pierre Kraemer's avatar
Pierre Kraemer committed
76

Sylvain Thery's avatar
Sylvain Thery committed
77
	void setParams(float explode, const Geom::Vec4f& ambiant, const Geom::Vec4f& diffuse, const Geom::Vec4f& diffuseBack, const Geom::Vec3f& lightPos);
Pierre Kraemer's avatar
Pierre Kraemer committed
78

79
	unsigned int setAttributePosition(VBO* vbo);
Sylvain Thery's avatar
Sylvain Thery committed
80
};
Pierre Kraemer's avatar
Pierre Kraemer committed
81

Pierre Kraemer's avatar
merge..  
Pierre Kraemer committed
82
83
84
85
} // namespace Utils

} // namespace CGoGN

Sylvain Thery's avatar
Sylvain Thery committed
86
#endif