added memory cleanup
This commit is contained in:
parent
a206be747c
commit
8da5f2d2e0
|
@ -21,7 +21,9 @@ Model::Model(std::vector<float>&& vertices, std::vector<unsigned int>&& indices)
|
|||
|
||||
Model::~Model()
|
||||
{
|
||||
|
||||
glDeleteBuffers(1, &ebo);
|
||||
glDeleteBuffers(1, &vbo);
|
||||
glDeleteVertexArrays(1, &vao);
|
||||
}
|
||||
|
||||
void Model::Draw()
|
||||
|
|
|
@ -8,7 +8,7 @@ public:
|
|||
Model();
|
||||
Model(const std::vector<float>& vertices, const std::vector<unsigned int>& indices);
|
||||
Model(std::vector<float>&& vertices, std::vector<unsigned int>&& indices);
|
||||
~Model();
|
||||
virtual ~Model();
|
||||
|
||||
void Draw();
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ unsigned int Fac(unsigned int n);
|
|||
|
||||
Orbital::Orbital(unsigned int l, unsigned int m) :
|
||||
l(l), m(m)
|
||||
{
|
||||
UpdateModel();
|
||||
CreateVAO();
|
||||
}
|
||||
|
||||
void Orbital::UpdateModel()
|
||||
{
|
||||
unsigned int verticesPerRing = 70;
|
||||
unsigned int rings = 70;
|
||||
|
@ -59,8 +65,6 @@ Orbital::Orbital(unsigned int l, unsigned int m) :
|
|||
indices.push_back(verticesPerRing * (ring + 1) + vertex);
|
||||
}
|
||||
}
|
||||
|
||||
CreateVAO();
|
||||
}
|
||||
|
||||
void Orbital::DefineVAOLayout()
|
||||
|
|
|
@ -8,6 +8,7 @@ public:
|
|||
Orbital(unsigned int l, unsigned int m);
|
||||
|
||||
private:
|
||||
void UpdateModel();
|
||||
void DefineVAOLayout() final override;
|
||||
|
||||
private:
|
||||
|
|
|
@ -36,6 +36,11 @@ Shader::Shader(const std::string& vertexShaderSourceCode, const std::string& fra
|
|||
CreateProgram(vertexShaderSourceCode, fragmentShaderSourceCode);
|
||||
}
|
||||
|
||||
Shader::~Shader()
|
||||
{
|
||||
glDeleteProgram(program);
|
||||
}
|
||||
|
||||
void Shader::SetMatrix(const std::string& name, const float* data)
|
||||
{
|
||||
unsigned int location = glGetUniformLocation(program, name.c_str());
|
||||
|
|
|
@ -7,6 +7,7 @@ class Shader
|
|||
public:
|
||||
Shader();
|
||||
Shader(const std::string& vertexShaderSourceCode, const std::string& fragmentShaderSourceCode);
|
||||
~Shader();
|
||||
|
||||
void SetMatrix(const std::string& name, const float* data);
|
||||
|
||||
|
|
Loading…
Reference in a new issue