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
|
#include <Surfaces.hpp>
using namespace std;
//constructeur
Surfaces::Surfaces()
{
}
//constructeur par liste d'initialisation//////////
Surfaces::Surfaces(int ID, int nb_points)
: m_ID(ID),m_nb_vert(nb_points)
{
ajoute();
build_shape(nb_points);
string nameis = "Forme " + ID;
give_a_name(nameis);
init_VBO_VAO();
refresh_VBO_vertex_array();
create_shaders();
string default_VS=
"#version 140\n in vec3 vp; \n void main () { gl_Position = vec4 (vp, 1.0);}\n";
string default_FS=
"#version 140\n out vec4 frag_colour; \n void main () { frag_colour = vec4 (0.7, 0.7, 0.5, .7);}\n";
compile_attach_shaders(default_VS,GL_VERTEX_SHADER);
compile_attach_shaders(default_FS,GL_FRAGMENT_SHADER);
create_program();
}
//destructeur
Surfaces::~Surfaces()
{
retire();//pour descendre mon décompte d'objet créés ?
}
void Surfaces::give_a_name(std::string const &name)
{
m_name=name;
}
std::string Surfaces::return_a_name()
{
return m_name;
}
//etc etc...
void Surfaces::ajoute() {
nb_Surfaces++;
m_ID=nb_Surfaces;
}
void Surfaces::retire() {
if (nb_Surfaces > 0) nb_Surfaces--;
} |