GRIM: Implement destroyMesh [OpenGLS]

This commit is contained in:
Joel Teichroeb 2014-07-09 18:17:09 -07:00
parent 77eef29e49
commit 57a3142fd8
4 changed files with 22 additions and 0 deletions

View File

@ -268,6 +268,7 @@ public:
virtual Material *getSpecialtyTexture(int n) { return &_specialty[n]; } virtual Material *getSpecialtyTexture(int n) { return &_specialty[n]; }
virtual void createMesh(Mesh *mesh) {} virtual void createMesh(Mesh *mesh) {}
virtual void destroyMesh(const Mesh *mesh) {}
virtual void createEMIModel(EMIModel *model) {} virtual void createEMIModel(EMIModel *model) {}
virtual void updateEMIModel(const EMIModel *model) {} virtual void updateEMIModel(const EMIModel *model) {}

View File

@ -1938,6 +1938,24 @@ void GfxOpenGLS::createMesh(Mesh *mesh) {
shader->disableVertexAttribute("color", Math::Vector4d(1.f, 1.f, 1.f, 1.f)); shader->disableVertexAttribute("color", Math::Vector4d(1.f, 1.f, 1.f, 1.f));
} }
void GfxOpenGLS::destroyMesh(const Mesh *mesh) {
ModelUserData *mud = static_cast<ModelUserData *>(mesh->_userData);
for (int i = 0; i < mesh->_numFaces; ++i) {
MeshFace *face = &mesh->_faces[i];
if (face->_userData) {
uint32 *data = static_cast<uint32 *>(face->_userData);
delete data;
}
}
if (!mud)
return;
delete mud->_shader;
delete mud;
}
} }

View File

@ -201,6 +201,7 @@ public:
virtual void createSpecialtyTextures() override; virtual void createSpecialtyTextures() override;
virtual void createMesh(Mesh *mesh) override; virtual void createMesh(Mesh *mesh) override;
virtual void destroyMesh(const Mesh *mesh) override;
virtual void createEMIModel(EMIModel *model) override; virtual void createEMIModel(EMIModel *model) override;
virtual void updateEMIModel(const EMIModel* model) override; virtual void updateEMIModel(const EMIModel* model) override;

View File

@ -407,6 +407,8 @@ Mesh::Mesh() :
Mesh::~Mesh() { Mesh::~Mesh() {
g_driver->destroyMesh(this);
delete[] _vertices; delete[] _vertices;
delete[] _verticesI; delete[] _verticesI;
delete[] _vertNormals; delete[] _vertNormals;