refactor(renderer): introduce skipDisplayFrame logic in RendererData and update G2DRenderer rendering cycle
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package de.extio.game_engine.renderer;
|
package de.extio.game_engine.renderer;
|
||||||
|
|
||||||
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicLong;
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
@@ -31,6 +32,8 @@ public class RendererData {
|
|||||||
|
|
||||||
private final AtomicLong frame = new AtomicLong();
|
private final AtomicLong frame = new AtomicLong();
|
||||||
|
|
||||||
|
private final AtomicBoolean skipDisplayFrame = new AtomicBoolean(false);
|
||||||
|
|
||||||
private final KeycodeRegistry keycodeRegistry;
|
private final KeycodeRegistry keycodeRegistry;
|
||||||
|
|
||||||
private final EventService eventService;
|
private final EventService eventService;
|
||||||
@@ -88,6 +91,14 @@ public class RendererData {
|
|||||||
return this.frame.incrementAndGet();
|
return this.frame.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isSkipDisplayFrame() {
|
||||||
|
return this.skipDisplayFrame.get();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean setSkipDisplayFrame(final boolean skipDisplayFrame) {
|
||||||
|
return this.skipDisplayFrame.getAndSet(skipDisplayFrame);
|
||||||
|
}
|
||||||
|
|
||||||
public Renderer getRenderer() {
|
public Renderer getRenderer() {
|
||||||
return this.renderer;
|
return this.renderer;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -225,7 +225,10 @@ public class G2DRenderer implements Renderer {
|
|||||||
// Rendering cycle START
|
// Rendering cycle START
|
||||||
//
|
//
|
||||||
|
|
||||||
|
final var skipDisplay = this.rendererData.setSkipDisplayFrame(false);
|
||||||
|
if (! skipDisplay) {
|
||||||
bufferStrategy.show();
|
bufferStrategy.show();
|
||||||
|
}
|
||||||
Toolkit.getDefaultToolkit().sync();
|
Toolkit.getDefaultToolkit().sync();
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
|||||||
Reference in New Issue
Block a user