private void deleteNativeObject(Object rendererObject, NativeObject obj, NativeObjectRef ref, 
                                    boolean deleteGL, boolean deleteBufs) {
        assert rendererObject != null;
        
        // "obj" is considered the real object (with buffers and everything else)
        // if "ref" is null.
        NativeObject realObj = ref != null ? 
                                    ref.realObj.get() : 
                                    obj;
        
        assert realObj == null || obj.getId() == realObj.getId();
        
        if (deleteGL) {
            if (obj.getId() <= 0) {
                logger.log(Level.WARNING, "Object already deleted: {0}", obj.getClass().getSimpleName() + "/" + obj.getId());
            } else {
                // Unregister it from cleanup list.
                NativeObjectRef ref2 = refMap.remove(obj.getUniqueId());
                if (ref2 == null) {
                    throw new IllegalArgumentException("The " + obj + " NativeObject is not "
                            + "registered in this NativeObjectManager");
                }

                assert ref == null || ref == ref2;
                ref2.clear();

                int id = obj.getId();

                // Delete object from the GL driver
                obj.deleteObject(rendererObject);
                assert obj.getId() == NativeObject.INVALID_ID;

                if (logger.isLoggable(Level.FINEST)) {
                    logger.log(Level.FINEST, "Deleted: {0}", obj.getClass().getSimpleName() + "/" + id);
                }

                if (realObj != null){
                    // Note: make sure to reset them as well
                    // They may get used in a new renderer in the future
                    realObj.resetObject();
                }
            }
        }
        if (deleteBufs && UNSAFE && realObj != null) {
            // Only the real object has native buffers. 
            // The destructible clone has nothing and cannot be used in this case.
            realObj.deleteNativeBuffersInternal();
        }
    }
(Internal use only) Register a <code>NativeObject</code> with the manager.

@param obj the object to register (not null)
jme3-core/src/main/java/com/jme3/util/NativeObjectManager.java