Properly clean GL buffers in instancing node.
This commit is contained in:
parent
c70b9ba0f8
commit
008b070aab
@ -11,6 +11,36 @@ STKInstancedSceneNode::STKInstancedSceneNode(irr::scene::IMesh* mesh, ISceneNode
|
||||
setAutomaticCulling(0);
|
||||
}
|
||||
|
||||
void STKInstancedSceneNode::cleanGL()
|
||||
{
|
||||
for (u32 i = 0; i < GLmeshes.size(); ++i)
|
||||
{
|
||||
GLMesh mesh = GLmeshes[i];
|
||||
if (!mesh.vertex_buffer)
|
||||
continue;
|
||||
if (mesh.vao_first_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_first_pass));
|
||||
if (mesh.vao_second_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_second_pass));
|
||||
if (mesh.vao_glow_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_glow_pass));
|
||||
if (mesh.vao_displace_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_displace_pass));
|
||||
if (mesh.vao_displace_mask_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_displace_mask_pass));
|
||||
if (mesh.vao_shadow_pass)
|
||||
glDeleteVertexArrays(1, &(mesh.vao_shadow_pass));
|
||||
glDeleteBuffers(1, &(mesh.vertex_buffer));
|
||||
glDeleteBuffers(1, &(mesh.index_buffer));
|
||||
}
|
||||
glDeleteBuffers(1, &instances_vbo);
|
||||
}
|
||||
|
||||
STKInstancedSceneNode::~STKInstancedSceneNode()
|
||||
{
|
||||
cleanGL();
|
||||
}
|
||||
|
||||
void STKInstancedSceneNode::createGLMeshes()
|
||||
{
|
||||
for (u32 i = 0; i<Mesh->getMeshBufferCount(); ++i)
|
||||
|
@ -16,12 +16,14 @@ protected:
|
||||
bool isMaterialInitialized;
|
||||
void setFirstTimeMaterial();
|
||||
void initinstancedvaostate(GLMesh &mesh, GeometricMaterial GeoMat, ShadedMaterial ShadedMat);
|
||||
void cleanGL();
|
||||
core::vector3df windDir;
|
||||
public:
|
||||
STKInstancedSceneNode(irr::scene::IMesh* mesh, ISceneNode* parent, irr::scene::ISceneManager* mgr, irr::s32 id,
|
||||
const irr::core::vector3df& position = irr::core::vector3df(0, 0, 0),
|
||||
const irr::core::vector3df& rotation = irr::core::vector3df(0, 0, 0),
|
||||
const irr::core::vector3df& scale = irr::core::vector3df(1.0f, 1.0f, 1.0f));
|
||||
~STKInstancedSceneNode();
|
||||
virtual void render();
|
||||
void addInstance(const core::vector3df &origin, const core::vector3df &orientation);
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user