Java Code Examples for org.lwjgl.opengl.Display#isCloseRequested()

The following examples show how to use org.lwjgl.opengl.Display#isCloseRequested() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestUtils.java    From slick2d-maven with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/**
 * Start the test 
 */
public void start() {
	initGL(800,600);
	init();
	
	while (true) {
		update();
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
		render();
		
		Display.update();
		Display.sync(100);

		if (Display.isCloseRequested()) {
			System.exit(0);
		}
	}
}
 
Example 2
Source File: AnimationApp.java    From OpenGL-Animation with The Unlicense 6 votes vote down vote up
/**
 * Initialises the engine and loads the scene. For every frame it updates the
 * camera, updates the animated entity (which updates the animation),
 * renders the scene to the screen, and then updates the display. When the
 * display is close the engine gets cleaned up.
 * 
 * @param args
 */
public static void main(String[] args) {

	RenderEngine engine = RenderEngine.init();

	Scene scene = SceneLoader.loadScene(GeneralSettings.RES_FOLDER);

	while (!Display.isCloseRequested()) {
		scene.getCamera().move();
		scene.getAnimatedModel().update();
		engine.renderScene(scene);
		engine.update();
	}

	engine.close();

}
 
Example 3
Source File: LevelEditor.java    From FEMultiplayer with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void loop() {
	while(!Display.isCloseRequested()) {
		time = System.nanoTime();
		glClear(GL_COLOR_BUFFER_BIT |
		        GL_DEPTH_BUFFER_BIT |
		        GL_STENCIL_BUFFER_BIT);
		glClearDepth(1.0f);
		getInput();
		glPushMatrix();
		if(!paused) {
			currentStage.beginStep();
			currentStage.onStep();
			currentStage.processAddStack();
			currentStage.processRemoveStack();
			Renderer.getCamera().lookThrough();
			currentStage.render();
			currentStage.endStep();
		}
		glPopMatrix();
		Display.update();
		timeDelta = System.nanoTime()-time;
	}
	AL.destroy();
	Display.destroy();
}
 
Example 4
Source File: LevelEditor.java    From FEMultiPlayer-V2 with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void loop() {
	while(!Display.isCloseRequested()) {
		final long time = System.nanoTime();
		glClear(GL_COLOR_BUFFER_BIT |
		        GL_DEPTH_BUFFER_BIT |
		        GL_STENCIL_BUFFER_BIT);
		glClearDepth(1.0f);
		getInput();
		glPushMatrix();
			currentStage.beginStep(emptyList());
			currentStage.onStep();
			currentStage.processAddStack();
			currentStage.processRemoveStack();
			Renderer.getCamera().lookThrough();
			currentStage.render();
			currentStage.endStep();
		glPopMatrix();
		Display.update();
		timeDelta = System.nanoTime()-time;
	}
	AL.destroy();
	Display.destroy();
}
 
Example 5
Source File: OpenGL3_TheQuadTextured.java    From ldparteditor with MIT License 6 votes vote down vote up
public TheQuadExampleTextured() {
    // Initialize OpenGL (Display)
    this.setupOpenGL();
     
    this.setupQuad();
    this.setupShaders();
    this.setupTextures();
     
    while (!Display.isCloseRequested()) {
        // Do a single loop (logic/render)
        this.loopCycle();
         
        // Force a maximum FPS of about 60
        Display.sync(60);
        // Let the CPU synchronize with the GPU if GPU is tagging behind
        Display.update();
    }
     
    // Destroy OpenGL (Display)
    this.destroyOpenGL();
}
 
Example 6
Source File: FEMultiplayer.java    From FEMultiplayer with GNU General Public License v3.0 5 votes vote down vote up
@Override
	public void loop() {
		while(!Display.isCloseRequested()) {
			time = System.nanoTime();
			glClear(GL_COLOR_BUFFER_BIT |
			        GL_DEPTH_BUFFER_BIT |
			        GL_STENCIL_BUFFER_BIT);
			glClearDepth(1.0f);
			getInput();
			messages.clear();
			if(client != null){
				messages.addAll(client.getMessages());
				for(Message m : messages)
					client.messages.remove(m);
			}
			SoundStore.get().poll(0);
			glPushMatrix();
			//Global resolution scale
//			Renderer.scale(scaleX, scaleY);
			if(!paused) {
				currentStage.beginStep();
				currentStage.onStep();
				currentStage.processAddStack();
				currentStage.processRemoveStack();
				currentStage.render();
//				FEResources.getBitmapFont("stat_numbers").render(
//						(int)(1.0f/getDeltaSeconds())+"", 440f, 0f, 0f);
				currentStage.endStep();
			}
			glPopMatrix();
			Display.update();
			timeDelta = System.nanoTime()-time;
		}
		AL.destroy();
		Display.destroy();
		if(client != null && client.isOpen()) client.quit();
	}
 
Example 7
Source File: Parser.java    From AnyaBasic with MIT License 5 votes vote down vote up
private Expression windowClosed()
{
    int res = 0;
    if( Display.isCloseRequested() )
    {
        res = 1;
    }
    return new ValueNumber( res );

}
 
Example 8
Source File: LwjglAbstractDisplay.java    From MikuMikuStudio with BSD 2-Clause "Simplified" License 5 votes vote down vote up
public void run(){
    if (listener == null)
        throw new IllegalStateException("SystemListener is not set on context!"
                                      + "Must set with JmeContext.setSystemListner().");

    logger.log(Level.INFO, "Using LWJGL {0}", Sys.getVersion());
    initInThread();
    while (true){
        if (renderable.get()){
            if (Display.isCloseRequested())
                listener.requestClose(false);

            if (wasActive != Display.isActive()) {
                if (!wasActive) {
                    listener.gainFocus();
                    timer.reset();
                    wasActive = true;
                } else {
                    listener.loseFocus();
                    wasActive = false;
                }
            }
        }

        runLoop();

        if (needClose.get())
            break;
    }
    deinitInThread();
}
 
Example 9
Source File: TwlTest.java    From tablelayout with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
public TwlTest () throws Exception {
	LWJGLRenderer renderer = new LWJGLRenderer();

	ThemeManager theme = ThemeManager.createThemeManager(TwlTest.class.getResource("/widgets.xml"), renderer);

	Widget root = new Widget() {
		protected void layout () {
			layoutChildrenFullInnerArea();
		}
	};
	root.setTheme("");

	GUI gui = new GUI(root, renderer);
	gui.setSize();
	gui.applyTheme(theme);

	final HTMLTextAreaModel htmlText = new HTMLTextAreaModel();
	TextArea textArea = new TextArea(htmlText);
	htmlText
		.setHtml("<div style='text-align:center'>TWL TextAreaTest</div>Lorem ipsum dolor sit amet, douchebagus joglus. Sed fermentum gravida turpis, sit amet gravida justo laoreet non. Donec ultrices suscipit metus a mollis. Mollis varius egestas quisque feugiat pellentesque mi, quis scelerisque velit bibendum eget. Nulla orci in enim nisl mattis varius dignissim fringilla.<br/><br/>Curabitur purus leo, ultricies ut cursus eget, adipiscing in quam. Duis non velit vel mauris vulputate fringilla et quis.<br/><br/>Suspendisse lobortis iaculis tellus id fermentum. Integer fermentum varius pretium. Nullam libero magna, mattis vel placerat ac, dignissim sed lacus. Mauris varius libero id neque auctor a auctor odio fringilla.<br/><br/><div>Mauris orci arcu, porta eget porttitor luctus, malesuada nec metus. Nunc fermentum viverra leo eu pretium. Curabitur vitae nibh massa, imperdiet egestas lectus. Nulla odio quam, lobortis eget fermentum non, faucibus ac mi. Morbi et libero nulla. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam sit amet rhoncus nulla. Morbi consectetur ante convallis ante tristique et porta ligula hendrerit. Donec rhoncus ornare augue, sit amet lacinia nulla auctor venenatis.</div><br/><div>Etiam semper egestas porta. Proin luctus porta faucibus. Curabitur sagittis, lorem nec imperdiet ullamcorper, sem risus consequat purus, non faucibus turpis lorem ut arcu. Nunc tempus lobortis enim vitae facilisis. Morbi posuere quam nec sem aliquam eleifend.</div>");
	ScrollPane scrollPane = new ScrollPane(textArea);
	scrollPane.setFixed(ScrollPane.Fixed.HORIZONTAL);
	FPSCounter fpsCounter = new FPSCounter(4, 2);
	ProgressBar progressBar = new ProgressBar();
	progressBar.setValue(0.4f);

	Table table = new Table();
	table.addCell(scrollPane).expand().fill();
	table.row();
	table.addCell(fpsCounter).right();
	table.row();
	table.addCell(progressBar).fill();
	root.add(table);

	while (!Display.isCloseRequested()) {
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
		gui.update();
		Display.update();
	}
}
 
Example 10
Source File: MainGameLoop.java    From OpenGL-Tutorial-1 with The Unlicense 5 votes vote down vote up
/**
 * Creates a display and then continuously updates the display until the user tries to close it. 
 * @param args
 */
public static void main(String[] args) {
	DisplayManager.createDisplay();

	while (!Display.isCloseRequested()) {

		// game logic
		// render geometry
		DisplayManager.updateDisplay();
	}

	DisplayManager.closeDisplay();
}
 
Example 11
Source File: LwjglAbstractDisplay.java    From jmonkeyengine with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void run(){
    if (listener == null) {
        throw new IllegalStateException("SystemListener is not set on context!"
                                      + "Must set with JmeContext.setSystemListener().");
    }

    loadNatives();
    logger.log(Level.FINE, "Using LWJGL {0}", Sys.getVersion());
    if (!initInThread()) {
        logger.log(Level.SEVERE, "Display initialization failed. Cannot continue.");
        return;
    }
    while (true){
        if (renderable.get()){
            if (Display.isCloseRequested())
                listener.requestClose(false);

            if (wasActive != Display.isActive()) {
                if (!wasActive) {
                    listener.gainFocus();
                    timer.reset();
                    wasActive = true;
                } else {
                    listener.loseFocus();
                    wasActive = false;
                }
            }
        }

        runLoop();

        if (needClose.get())
            break;
    }
    deinitInThread();
}
 
Example 12
Source File: LwJglRenderingEngine.java    From Gaalop with GNU Lesser General Public License v3.0 4 votes vote down vote up
@Override
public void run() {
    startEngine();
    //long start = System.currentTimeMillis();
    while (!Display.isCloseRequested()) {
        //System.out.println(System.currentTimeMillis()-start);
        //start = System.currentTimeMillis();
        
        if (rendering.isNewDataSetAvailable()) {
            if (list != -1) GL11.glDeleteLists(list, 1);
            list = GL11.glGenLists(1);
            GL11.glNewList(list, GL11.GL_COMPILE);
            draw(rendering.getDataSet(), rendering.getVisibleObjects(), rendering.getLoadedPointClouds());
            GL11.glEndList();
            changed = true;
        }
        
        
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT); // clear the screen
        GL11.glLoadIdentity(); // apply camPos before rotation

        GL11.glTranslatef(0.0f, 0.0f, -5.0f);
        // draw
        GLU.gluLookAt(camPos.x, camPos.y, camPos.z, // Position
                camPos.x + camDir.x, camPos.y + camDir.y, camPos.z + camDir.z, // Lookat
                camUp.x, camUp.y, camUp.z);               // Up-direction
        // apply rotation
        GL11.glRotatef(camAngleX, 0, 1, 0); // window x axis rotates around up vector
        GL11.glRotatef(camAngleY, 1, 0, 0); // window y axis rotates around x

        //Render the scene
        if (list != -1) GL11.glCallList(list);

        pollInput();
        Display.update();
        if (recorder != null) {
            if (changed || firstFrame) {
                recorder.makeScreenshot();
                changed = false;
            }
            firstFrame = false;
            Display.sync(25); // cap fps to 60fps
        }
        else 
            Display.sync(60); 
    }

    Display.destroy();
}
 
Example 13
Source File: Window.java    From 3DGameEngine with Apache License 2.0 4 votes vote down vote up
public static boolean IsCloseRequested()
{
	return Display.isCloseRequested();
}
 
Example 14
Source File: LwjglRasteriser.java    From tectonicus with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public boolean isCloseRequested()
{
	return Display.isCloseRequested();
}
 
Example 15
Source File: Test.java    From tribaltrouble with GNU General Public License v2.0 4 votes vote down vote up
public final static void main(String[] args) {
		try {
			Display.setDisplayMode(new DisplayMode(DISPLAY_WIDTH, DISPLAY_HEIGHT));
			Display.create();
			initGL();

			// Load font
			InputStream font_is = Utils.makeURL("/fonts/tahoma.ttf").openStream();
			java.awt.Font src_font = java.awt.Font.createFont(java.awt.Font.TRUETYPE_FONT, font_is);
			java.awt.Font font = src_font.deriveFont(14f);

			// Load text
			InputStreamReader text_is = new InputStreamReader(Utils.makeURL("/test_text.txt").openStream());
			StringBuffer str_buffer = new StringBuffer();
			int c = text_is.read();
			do {
				str_buffer.append((char)c);
				c = text_is.read();
			} while (c != -1);
			String str = str_buffer.toString();

			// Build texture
			int[] pixels = new int[WIDTH*HEIGHT];
//			ByteBuffer pixel_data = ByteBuffer.wrap(pixels);						// NEW
//			pixelDataFromString(WIDTH, HEIGHT, str, font, pixels);					// NEW
			IntBuffer pixel_data = BufferUtils.createIntBuffer(WIDTH*HEIGHT);	// OLD
			pixel_data.put(pixels);													// OLD
			pixel_data.rewind();

			int texture_handle = createTexture(WIDTH, HEIGHT, pixel_data);
			
		FontRenderContext frc = g2d.getFontRenderContext();
		AttributedString att_str = new AttributedString(str);
		att_str.addAttribute(TextAttribute.FONT, font);
		AttributedCharacterIterator iterator = att_str.getIterator();
		LineBreakMeasurer measurer = new LineBreakMeasurer(iterator, frc);
		
			while (!Display.isCloseRequested()) {
long start_time = System.currentTimeMillis();
for (int i = 0; i < 10; i++) {
pixelDataFromString(WIDTH, HEIGHT, str, font, pixels, measurer);
pixel_data.put(pixels); // OLD
pixel_data.rewind();

//texture_handle = createTexture(WIDTH, HEIGHT, pixel_data);
updateTexture(WIDTH, HEIGHT, pixel_data);
				GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
				GL11.glLoadIdentity();
				
				// Background
				/*
				GL11.glDisable(GL11.GL_TEXTURE_2D);
				GL11.glColor4f(.1f, .1f, .1f, 1f);
				GL11.glBegin(GL11.GL_QUADS);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f);
				GL11.glEnd();
				*/

				// Text
				GL11.glEnable(GL11.GL_TEXTURE_2D);
				GL11.glColor4f(1f, 1f, 1f, 1f);
				GL11.glBegin(GL11.GL_QUADS);
				GL11.glTexCoord2f(0f, 1f);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glTexCoord2f(1f, 1f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT-RENDER_SIZE, 1f);
				GL11.glTexCoord2f(1f, 0f);
				GL11.glVertex3f(RENDER_SIZE, DISPLAY_HEIGHT, 1f);
				GL11.glTexCoord2f(0f, 0f);
				GL11.glVertex3f(0f, DISPLAY_HEIGHT, 1f);
				GL11.glEnd();
				Display.update();
}
long total_time = System.currentTimeMillis() - start_time;
System.out.println("total_time = " + total_time);

			}
			Display.destroy();
		} catch (Exception t) {
			t.printStackTrace();
		}
	}
 
Example 16
Source File: SlytherClient.java    From Slyther with MIT License 4 votes vote down vote up
@Override
public void run() {
    double delta = 0;
    long previousTime = System.nanoTime();
    long timer = System.currentTimeMillis();
    int ups = 0;
    double nanoUpdates = 1000000000.0 / 30.0;

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDisable(GL11.GL_LIGHTING);

    GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
    GL11.glClearDepth(1);

    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    setupDisplay();

    boolean doResize = false;

    while (!Display.isCloseRequested()) {
        if (Display.wasResized() && doResize) {
            setupDisplay();
        }
        doResize = true;

        long currentTime = System.nanoTime();
        double currentTickDelta = (currentTime - previousTime) / nanoUpdates;
        delta += currentTickDelta;
        frameDelta = (frameDelta + currentTickDelta) % 1.0;
        previousTime = currentTime;

        while (delta >= 1) {
            update();
            renderHandler.update();
            delta--;
            ups++;
        }

        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT);
        GL11.glPushMatrix();

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

        renderHandler.render();

        fps++;

        if (System.currentTimeMillis() - timer > 1000) {
            int bytesPerSecond = 0;
            int packetsPerSecond = 0;
            if (networkManager != null) {
                bytesPerSecond = networkManager.bytesPerSecond;
                packetsPerSecond = networkManager.packetsPerSecond;
                networkManager.bytesPerSecond = 0;
                networkManager.packetsPerSecond = 0;
            }
            Display.setTitle("Slyther - FPS: " + fps + " - UPS: " + ups + " - BPS: " + bytesPerSecond + " - PPS: " + packetsPerSecond);
            fps = 0;

            timer += 1000;
            ups = 0;
        }

        GL11.glPopMatrix();
        Display.sync(60);
        Display.update();
    }
    if (networkManager != null && networkManager.isOpen()) {
        networkManager.closeConnection(ClientNetworkManager.SHUTDOWN_CODE, "");
    }
    try {
        ConfigHandler.INSTANCE.saveConfig(CONFIGURATION_FILE, configuration);
    } catch (IOException e) {
        Log.error("Failed to save config");
        Log.catching(e);
    }
    Display.destroy();
}
 
Example 17
Source File: ModelViewer.java    From OpenRS with GNU General Public License v3.0 4 votes vote down vote up
public static void main(String[] args) throws Exception {
	if (args.length < 1) {
		System.err.println("Usage: modelfile");
		System.exit(1);
	}

	ModelList list = new ModelList();
	try (Cache cache = new Cache(FileStore.open(Constants.CACHE_PATH))) {
		list.initialize(cache);
	}

	Model md = list.list(Integer.valueOf(args[0]));

	Display.setDisplayMode(new DisplayMode(800, 600));
	Display.setTitle("Model Viewer");
	Display.setInitialBackground((float) Color.gray.getRed() / 255f, (float) Color.gray.getGreen() / 255f,
			(float) Color.gray.getBlue() / 255f);
	Display.create();

	GL11.glMatrixMode(GL11.GL_PROJECTION);
	GL11.glLoadIdentity();
	double aspect = 1;
	double near = 1; // near should be chosen as far into the scene as
						// possible
	double far = 1000;
	double fov = 1; // 1 gives you a 90� field of view. It's
					// tan(fov_angle)/2.
	GL11.glFrustum(-aspect * near * fov, aspect * near * fov, -fov, fov, near, far);

	GL11.glCullFace(GL11.GL_BACK);

	long last = 0;

	while (!Display.isCloseRequested()) {
		// Clear the screen and depth buffer
		GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

		GL11.glBegin(GL11.GL_TRIANGLES);

		for (int i = 0; i < md.faceCount; ++i) {
			int vertexA = md.triangleX[i];
			int vertexB = md.triangleY[i];
			int vertexC = md.triangleZ[i];

			int vertexAx = md.vertexX[vertexA];
			int vertexAy = md.vertexY[vertexA];
			int vertexAz = md.vertexZ[vertexA];

			int vertexBx = md.vertexX[vertexB];
			int vertexBy = md.vertexY[vertexB];
			int vertexBz = md.vertexZ[vertexB];

			int vertexCx = md.vertexX[vertexC];
			int vertexCy = md.vertexY[vertexC];
			int vertexCz = md.vertexZ[vertexC];

			short hsb = md.faceColor[i];

			int rgb = hsbToRGB(hsb);
			Color c = new Color(rgb);

			// convert to range of 0-1
			float rf = (float) c.getRed() / 255f;
			float gf = (float) c.getGreen() / 255f;
			float bf = (float) c.getBlue() / 255f;

			GL11.glColor3f(rf, gf, bf);

			GL11.glVertex3i(vertexAx, vertexAy, vertexAz - 50);
			GL11.glVertex3i(vertexBx, vertexBy, vertexBz - 50);
			GL11.glVertex3i(vertexCx, vertexCy, vertexCz - 50);
		}

		GL11.glEnd();

		Display.update();
		Display.sync(50); // fps

		long delta = System.currentTimeMillis() - last;
		last = System.currentTimeMillis();

		Camera.create();
		Camera.acceptInput(delta);

		Camera.apply();
	}

	Display.destroy();
}
 
Example 18
Source File: LwjglGraphicsModule.java    From tprogers2048game with GNU General Public License v3.0 4 votes vote down vote up
/**
 * @return Возвращает true, если в окне нажат "крестик"
 */
@Override
public boolean isCloseRequested() {
    return Display.isCloseRequested();
}
 
Example 19
Source File: Window.java    From LowPolyWater with The Unlicense 4 votes vote down vote up
public boolean isCloseRequested() {
	return Display.isCloseRequested();
}
 
Example 20
Source File: MixinMinecraft.java    From VanillaFix with MIT License 4 votes vote down vote up
private void runGUILoop(GuiScreen screen) throws IOException {
    displayGuiScreen(screen);
    while (running && currentScreen != null && !(currentScreen instanceof GuiMainMenu) && !(Loader.isModLoaded("custommainmenu") && currentScreen instanceof GuiCustom)) {
        if (Display.isCreated() && Display.isCloseRequested()) System.exit(0);
        leftClickCounter = 10000;
        currentScreen.handleInput();
        currentScreen.updateScreen();

        GlStateManager.pushMatrix();
        GlStateManager.clear(16640);
        framebuffer.bindFramebuffer(true);
        GlStateManager.enableTexture2D();

        GlStateManager.viewport(0, 0, displayWidth, displayHeight);

        // EntityRenderer.setupOverlayRendering
        ScaledResolution scaledResolution = new ScaledResolution((Minecraft) (Object) this);
        GlStateManager.clear(256);
        GlStateManager.matrixMode(5889);
        GlStateManager.loadIdentity();
        GlStateManager.ortho(0.0D, scaledResolution.getScaledWidth_double(), scaledResolution.getScaledHeight_double(), 0, 1000, 3000);
        GlStateManager.matrixMode(5888);
        GlStateManager.loadIdentity();
        GlStateManager.translate(0, 0, -2000);
        GlStateManager.clear(256);

        int width = scaledResolution.getScaledWidth();
        int height = scaledResolution.getScaledHeight();
        int mouseX = Mouse.getX() * width / displayWidth;
        int mouseY = height - Mouse.getY() * height / displayHeight - 1;
        currentScreen.drawScreen(mouseX, mouseY, 0);

        framebuffer.unbindFramebuffer();
        GlStateManager.popMatrix();

        GlStateManager.pushMatrix();
        framebuffer.framebufferRender(displayWidth, displayHeight);
        GlStateManager.popMatrix();

        updateDisplay();
        Thread.yield();
        Display.sync(60);
        checkGLError("VanillaFix GUI Loop");
    }
}