use of com.b3dgs.lionengine.graphic.Screen in project lionengine by b3dgs.
the class LoopHybridTest method testNoSync.
/**
* Test without sync.
*/
@Test
void testNoSync() {
ScreenMock.setScreenWait(false);
final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 0), 16, true));
final Thread thread = getTask(screen);
thread.start();
assertTimeout(1000L, thread::join);
assertEquals(maxTick.get(), tick.get());
assertTrue(rendered.get() <= tick.get(), rendered.get() + " " + tick.get());
assertTrue(extrapolation.get().doubleValue() < 1.0, String.valueOf(extrapolation.get()));
final int expectedRate = screen.getConfig().getOutput().getRate();
assertTrue(computed.get() > expectedRate, String.valueOf(computed.get()));
}
use of com.b3dgs.lionengine.graphic.Screen in project lionengine by b3dgs.
the class LoopHybridTest method testNoSyncFullscreen.
/**
* Test without sync full screen.
*/
@Test
void testNoSyncFullscreen() {
ScreenMock.setScreenWait(false);
final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 0), 16, false));
loop.notifyRateChanged(50);
final Thread thread = getTask(screen);
thread.start();
assertTimeout(1000L, thread::join);
assertEquals(maxTick.get(), tick.get());
assertTrue(rendered.get() <= tick.get(), rendered.get() + " " + tick.get());
assertTrue(extrapolation.get().doubleValue() > 0, String.valueOf(extrapolation.get()));
final int expectedRate = screen.getConfig().getOutput().getRate();
assertTrue(computed.get() > expectedRate, String.valueOf(computed.get()));
}
use of com.b3dgs.lionengine.graphic.Screen in project lionengine by b3dgs.
the class LoopUnlockedTest method testUnready.
/**
* Test with not ready screen.
*/
@Test
void testUnready() {
ScreenMock.setScreenWait(true);
try {
final Screen screen = new ScreenMock(new Config(new Resolution(320, 240, 50), 16, true));
final Thread thread = getTask(screen);
thread.start();
assertTimeout(1000L, latch::await);
loop.stop();
assertTimeout(1000L, thread::join);
assertEquals(0, rendered.get());
assertEquals(0, tick.get());
assertEquals(-1, computed.get());
} finally {
ScreenMock.setScreenWait(false);
}
}
use of com.b3dgs.lionengine.graphic.Screen in project lionengine by b3dgs.
the class Loader method handle.
/**
* Handle the sequence with its screen until no more sequence to run.
*
* @param config The configuration used.
* @param sequenceClass The the next sequence to start.
* @param arguments The sequence arguments list if needed by its constructor.
* @throws LionEngineException If an exception occurred.
*/
private static void handle(Config config, Class<? extends Sequencable> sequenceClass, Object... arguments) {
final Screen screen = Graphics.createScreen(config);
try {
screen.start();
screen.awaitReady();
Sequencable nextSequence = UtilSequence.create(sequenceClass, screen, arguments);
while (nextSequence != null) {
final Sequencable sequence = nextSequence;
final String sequenceName = sequence.getClass().getName();
Verbose.info(SEQUENCE_START, sequenceName);
sequence.start(screen);
Verbose.info(SEQUENCE_END, sequenceName);
nextSequence = sequence.getNextSequence();
sequence.onTerminated(nextSequence != null);
}
} finally {
screen.dispose();
}
}
use of com.b3dgs.lionengine.graphic.Screen in project lionengine by b3dgs.
the class FactoryGraphicAwt method createScreen.
/*
* FactoryGraphic
*/
@Override
public Screen createScreen(Config config) {
Check.notNull(config);
final Screen screen;
if (config.getApplet(AppletAwt.class).isPresent()) {
screen = new ScreenAppletAwt(config);
} else if (config.isWindowed()) {
screen = new ScreenWindowedAwt(config);
} else {
screen = new ScreenFullAwt(config);
}
return screen;
}
Aggregations