Double buffering code fixed. Also added additional properties for Windows optimizations

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

Binary file not shown.

Binary file not shown.

@ -23,6 +23,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;
public class RabiClone { public class RabiClone {
public static final String PROGRAM_NAME = "RabiClone"; public static final String PROGRAM_NAME = "RabiClone";
@ -59,6 +60,9 @@ public class RabiClone {
public static long TIME = 0; public static long TIME = 0;
public static void main(String[] args) { public static void main(String[] args) {
System.setProperty("sun.java2d.transaccel", "True");
System.setProperty("sun.java2d.d3d", "True");
System.setProperty("sun.java2d.ddforcevram", "True");
Key.InitializeKeyConversionMap(); Key.InitializeKeyConversionMap();

@ -194,21 +194,9 @@ public class Panel extends JPanel implements Runnable,KeyListener {
@Override @Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); //super.paintComponent(g);
do { // perform draws on pixels
do { g.drawImage(this.imageBuffer,0,0,getWidth(),getHeight(),0,0,RabiClone.BASE_WIDTH,RabiClone.BASE_HEIGHT,this);
Graphics g2 = RabiClone.f.getBufferStrategy().getDrawGraphics();
// perform draws on pixels
render();
// ask ImageProducer to update image
mImageProducer.newPixels();
// draw it on panel
g2.drawImage(this.imageBuffer,0,0,getWidth(),getHeight(),0,0,RabiClone.BASE_WIDTH,RabiClone.BASE_HEIGHT,this);
g2.dispose();
} while (RabiClone.f.getBufferStrategy().contentsRestored());
RabiClone.f.getBufferStrategy().show();
} while (RabiClone.f.getBufferStrategy().contentsLost());
updateFPSCounter();
} }
/** /**
@ -369,7 +357,27 @@ public class Panel extends JPanel implements Runnable,KeyListener {
public void run() { public void run() {
while (true) { while (true) {
// request a JPanel re-drawing // request a JPanel re-drawing
repaint(); //repaint();
render();
mImageProducer.newPixels();
if (RabiClone.f!=null&&RabiClone.f.getBufferStrategy()!=null) {
do {
do {
if (RabiClone.f.getBufferStrategy()!=null) {
Graphics g2 = RabiClone.f.getBufferStrategy().getDrawGraphics();
if (g2!=null) {
try {
paintComponent(g2);
} finally {
g2.dispose();
}
}
}
} while (RabiClone.f.getBufferStrategy().contentsRestored());
RabiClone.f.getBufferStrategy().show();
} while (RabiClone.f.getBufferStrategy().contentsLost());
}
updateFPSCounter();
//System.out.println("Repaint "+frameCount++); //System.out.println("Repaint "+frameCount++);
waitForNextFrame(); waitForNextFrame();
} }

Loading…
Cancel
Save