/* \brief free texture */ GLHCKAPI unsigned int glhckTextureFree(glhckTexture *object) { unsigned int i; if (!glhckInitialized()) return 0; CALL(FREE_CALL_PRIO(object), "%p", object); assert(object); /* there is still references to this object alive */ if (--object->refCounter != 0) goto success; DEBUG(GLHCK_DBG_CRAP, "FREE(%p) %dx%dx%d", object, object->internalWidth, object->internalHeight, object->internalDepth); /* unbind from active slot */ for (i = 0; i != GLHCK_MAX_ACTIVE_TEXTURE; ++i) { if (GLHCKRD()->texture[i][object->target] == object) glhckTextureUnbind(object->target); } /* delete texture if there is one */ if (object->object) GLHCKRA()->textureDelete(1, &object->object); /* free */ IFDO(_glhckFree, object->file); /* remove from world */ _glhckWorldRemove(texture, object, glhckTexture*); /* free */ NULLDO(_glhckFree, object); success: RET(FREE_RET_PRIO(object), "%u", object?object->refCounter:0); return object?object->refCounter:0; }
/* \brief free camera */ GLHCKAPI unsigned int glhckCameraFree(glhckCamera *object) { if (!glhckInitialized()) return 0; CALL(FREE_CALL_PRIO(object), "%p", object); assert(object); /* there is still references to this object alive */ if (--object->refCounter != 0) goto success; /* remove camera from global state */ if (GLHCKRD()->camera == object) GLHCKRD()->camera = NULL; /* free camera's object */ NULLDO(glhckObjectFree, object->object); /* remove camera from world */ _glhckWorldRemove(camera, object, glhckCamera*); /* free */ NULLDO(_glhckFree, object); success: RET(FREE_RET_PRIO(object), "%u", object?object->refCounter:0); return object?object->refCounter:0; }
/* \brief free skin bone object */ GLHCKAPI unsigned int glhckSkinBoneFree(glhckSkinBone *object) { if (!glhckInitialized()) return 0; CALL(FREE_CALL_PRIO(object), "%p", object); assert(object); /* there is still references to this object alive */ if (--object->refCounter != 0) goto success; /* free the weights */ glhckSkinBoneInsertWeights(object, NULL, 0); /* remove from world */ _glhckWorldRemove(skinBone, object, glhckSkinBone*); /* free */ NULLDO(_glhckFree, object); success: RET(FREE_RET_PRIO(object), "%u", object?object->refCounter:0); return object?object->refCounter:0; }