Include vsync options

Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com>
Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
main
sigonasr2 3 years ago
parent feef654498
commit dd62b04556
  1. BIN
      RabiClone_0.0a.zip
  2. BIN
      bin/RabiClone.jar
  3. 28
      src/sig/RabiClone.java
  4. 1
      src/sig/engine/Panel.java

Binary file not shown.

Binary file not shown.

@ -8,6 +8,8 @@ import net.java.games.input.ControllerEnvironment;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.awt.image.BufferStrategy;
import java.awt.BufferCapabilities;
import sig.engine.Panel; import sig.engine.Panel;
import sig.engine.Point; import sig.engine.Point;
@ -23,7 +25,7 @@ import sig.engine.PaletteColor;
import java.awt.Toolkit; import java.awt.Toolkit;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.PrintStream; import java.lang.reflect.Constructor;
public class RabiClone { public class RabiClone {
public static final String PROGRAM_NAME = "RabiClone"; public static final String PROGRAM_NAME = "RabiClone";
@ -84,7 +86,29 @@ public class RabiClone {
(int) ((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - f.getHeight()) / 2)); (int) ((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - f.getHeight()) / 2));
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
f.setVisible(true); f.setVisible(true);
f.createBufferStrategy(2); BufferStrategy bf = f.getBufferStrategy();
if (bf != null) {
BufferCapabilities caps = bf.getCapabilities();
try {
Class ebcClass = Class.forName(
"sun.java2d.pipe.hw.ExtendedBufferCapabilities");
Class vstClass = Class.forName(
"sun.java2d.pipe.hw.ExtendedBufferCapabilities$VSyncType");
Constructor ebcConstructor = ebcClass.getConstructor(
new Class[] { BufferCapabilities.class, vstClass });
java.lang.Object vSyncType = vstClass.getField("VSYNC_ON").get(null);
BufferCapabilities newCaps = (BufferCapabilities)ebcConstructor.newInstance(
new java.lang.Object[] { caps, vSyncType });
f.createBufferStrategy(2, newCaps);
}
catch (Throwable t) {
// Ignore
t.printStackTrace();
}
}
OBJ.add(level_renderer = new LevelRenderer(p)); OBJ.add(level_renderer = new LevelRenderer(p));
StartGame(); StartGame();

@ -375,6 +375,7 @@ public class Panel extends JPanel implements Runnable,KeyListener {
} }
} while (RabiClone.f.getBufferStrategy().contentsRestored()); } while (RabiClone.f.getBufferStrategy().contentsRestored());
RabiClone.f.getBufferStrategy().show(); RabiClone.f.getBufferStrategy().show();
Toolkit.getDefaultToolkit().sync();
} while (RabiClone.f.getBufferStrategy().contentsLost()); } while (RabiClone.f.getBufferStrategy().contentsLost());
} }
updateFPSCounter(); updateFPSCounter();

Loading…
Cancel
Save