From 684ee486415d8aa318c70bba3d4462f801f4a1c2 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Wed, 3 May 2006 20:53:16 +0000 Subject: [PATCH] Added Display.swapBuffers(). Combined with Display.processMessages() and Mouse/Keyboard/Controllers.poll() this method allows an application to create a custom policy for the rendering/polling loop in addition to the static Display.update() policy. --- src/java/org/lwjgl/opengl/Display.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/java/org/lwjgl/opengl/Display.java b/src/java/org/lwjgl/opengl/Display.java index b4cd8931..730ba45c 100644 --- a/src/java/org/lwjgl/opengl/Display.java +++ b/src/java/org/lwjgl/opengl/Display.java @@ -549,25 +549,37 @@ public final class Display { */ public static void processMessages() { if (!isCreated()) - throw new IllegalStateException("Cannot update uncreated window"); + throw new IllegalStateException("Display not created"); display_impl.update(); } + /** + * Swap the display buffers. This method is called from update(), and should normally not be called by + * the application. + * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() + */ + public static void swapBuffers() throws LWJGLException { + if (!isCreated()) + throw new IllegalStateException("Display not created"); + + Util.checkGLError(); + Context.swapBuffers(); + } + /** * Update the window. This calls processMessages(), and if the window is visible - * clears the dirty flag and swaps the buffers and polls the input devices. + * clears the dirty flag and calls swapBuffers() and finally polls the input devices. * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() */ public static void update() { if (!isCreated()) - throw new IllegalStateException("Cannot update uncreated window"); + throw new IllegalStateException("Display not created"); // We paint only when the window is visible or dirty if (isVisible() || isDirty()) { - Util.checkGLError(); try { - Context.swapBuffers(); + swapBuffers(); } catch (LWJGLException e) { throw new RuntimeException(e); }