Include vsync options
Co-authored-by: r3cp3ct <45179536+r3cp3ct@users.noreply.github.com> Co-authored-by: sigonasr2 <sigonasr2@gmail.com>
This commit is contained in:
parent
feef654498
commit
dd62b04556
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.Arrays;
|
||||
import java.util.List;
|
||||
import java.awt.image.BufferStrategy;
|
||||
import java.awt.BufferCapabilities;
|
||||
|
||||
import sig.engine.Panel;
|
||||
import sig.engine.Point;
|
||||
@ -23,7 +25,7 @@ import sig.engine.PaletteColor;
|
||||
|
||||
import java.awt.Toolkit;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.reflect.Constructor;
|
||||
|
||||
public class RabiClone {
|
||||
public static final String PROGRAM_NAME = "RabiClone";
|
||||
@ -84,7 +86,29 @@ public class RabiClone {
|
||||
(int) ((Toolkit.getDefaultToolkit().getScreenSize().getHeight() - f.getHeight()) / 2));
|
||||
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
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));
|
||||
StartGame();
|
||||
|
@ -375,6 +375,7 @@ public class Panel extends JPanel implements Runnable,KeyListener {
|
||||
}
|
||||
} while (RabiClone.f.getBufferStrategy().contentsRestored());
|
||||
RabiClone.f.getBufferStrategy().show();
|
||||
Toolkit.getDefaultToolkit().sync();
|
||||
} while (RabiClone.f.getBufferStrategy().contentsLost());
|
||||
}
|
||||
updateFPSCounter();
|
||||
|
Loading…
x
Reference in New Issue
Block a user