public void resize(int w, int h, boolean f) throws Exception {
        for (DisplayMode d : Display.getAvailableDisplayModes()) {
            if (d.getWidth() == w && d.getHeight() == h) {
                if (f && !d.isFullscreenCapable()) {
                    continue;
                }
                Display.setDisplayMode(d);
                full = f;
                if (isOpen()) {
                    Display.setFullscreen(f);
                }
                return;
            }
        }
        throw new Exception(String.format("No such display mode: %dx%d %s fullscreen", w, h, "with" + (f? "" : "out")));
    }