package speiger.src.coreengine.rendering.inputOld.window;

import java.util.function.LongFunction;

import org.lwjgl.system.Callback;

public class WindowCallback
{
	Callback callback;
	LongFunction<Callback> provider;
	
	public WindowCallback(LongFunction<Callback> provider) {
		this.provider = provider;
	}
	
	public void reload(long windowId) {
		destroy();
		load(windowId);
	}
	
	public void load(long windowId) {
		callback = provider.apply(windowId);
	}
	
	public void destroy() {
		if(callback == null) return;
		callback.free();
		callback = null;
	}
}
