private static void initDisplay(boolean fullscreen) throws Exception {	

		Display.setTitle(TITLE); // sets aplication name
		Display.setFullscreen(fullscreen);  // create a full screen window if possible

        	DisplayMode displayMode = null;
        	DisplayMode d[] = Display.getAvailableDisplayModes();
        	for (int i = d.length - 1; i >= 0; i--) {
            		displayMode = d[i];
            	if (d[i].getWidth() == width
                	&& d[i].getHeight() == height
                	&& (d[i].getBitsPerPixel() >= 24 &&  d[i].getBitsPerPixel() <= 24 + 8 ) 
                	&& d[i].getFrequency() == FRAME_RATE) {
                	break;
            		}
        	} // Finds a suitable resolution
        	Display.setDisplayMode(displayMode); // sets display resoulation
        	if (fullscreen) Display.setVSyncEnabled(true); // enable vsync if poosible		
		Display.create();
	}