* Reduce input lag by polling after framerate syncing

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@7382 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
sha..rd 14 years ago
parent 156b1747f0
commit cfb647f743
  1. 10
      engine/src/lwjgl-ogl/com/jme3/system/lwjgl/LwjglAbstractDisplay.java
  2. 16
      engine/src/test/jme3test/gui/TestSoftwareMouse.java

@ -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();

@ -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");

Loading…
Cancel
Save