OSDN Git Service

* Reduce input lag by polling after framerate syncing
authorshadowislord <shadowislord@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Sun, 1 May 2011 19:02:36 +0000 (19:02 +0000)
committershadowislord <shadowislord@75d07b2b-3a1a-0410-a2c5-0572b91ccdca>
Sun, 1 May 2011 19:02:36 +0000 (19:02 +0000)
git-svn-id: http://jmonkeyengine.googlecode.com/svn/trunk@7382 75d07b2b-3a1a-0410-a2c5-0572b91ccdca

engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglAbstractDisplay.java
engine/src/test/jme3test/gui/TestSoftwareMouse.java

index 74a1c51..c84f9cd 100644 (file)
@@ -151,7 +151,7 @@ public abstract class LwjglAbstractDisplay extends LwjglContext implements Runna
             // calls swap buffers, etc.
             try {
                 if (autoFlush){
-                    Display.update();
+                    Display.update(false);
                 }else{
                     Display.processMessages();
                     Thread.sleep(50);
@@ -166,6 +166,14 @@ public abstract class LwjglAbstractDisplay extends LwjglContext implements Runna
         if (frameRate > 0)
             Display.sync(frameRate);
 
+        if (renderable.get()){
+            if (autoFlush){
+                // check input after we synchronize with framerate.
+                // this reduces input lag.
+                Display.processMessages();
+            }
+        }
+
         // Subclasses just call GLObjectManager clean up objects here
         // it is safe .. for now.
         renderer.onFrame();
index 0596a60..f117435 100644 (file)
@@ -41,18 +41,9 @@ import com.jme3.input.event.MouseButtonEvent;
 import com.jme3.input.event.MouseMotionEvent;
 import com.jme3.math.FastMath;
 import com.jme3.system.AppSettings;
-import com.jme3.texture.Image;
 import com.jme3.texture.Texture;
 import com.jme3.texture.Texture2D;
 import com.jme3.ui.Picture;
-import com.jme3.util.BufferUtils;
-import java.nio.ByteBuffer;
-import java.nio.IntBuffer;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-import org.lwjgl.LWJGLException;
-import org.lwjgl.input.Cursor;
-import org.lwjgl.input.Mouse;
 
 public class TestSoftwareMouse extends SimpleApplication {
 
@@ -90,13 +81,18 @@ public class TestSoftwareMouse extends SimpleApplication {
 
     public static void main(String[] args){
         TestSoftwareMouse app = new TestSoftwareMouse();
+
+//        AppSettings settings = new AppSettings(true);
+//        settings.setFrameRate(60);
+//        app.setSettings(settings);
+
         app.start();
     }
 
     @Override
     public void simpleInitApp() {
         flyCam.setEnabled(false);
-        inputManager.setCursorVisible(false);
+//        inputManager.setCursorVisible(false);
 
         Texture tex = assetManager.loadTexture("Interface/Logo/Cursor.png");