use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class RasterableModelIT method testRaster.
/**
* Test the raster.
*/
@Test
void testRaster() {
EngineAwt.start(getClass().getSimpleName(), Version.create(1, 0, 0), getClass());
final Resolution output = new Resolution(640, 480, 60);
Loader.start(Config.windowed(output), SceneRasterable.class).await();
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class SelectorIT method testSelector.
/**
* Test the selector.
*/
@Test
void testSelector() {
EngineAwt.start(getClass().getSimpleName(), Version.create(1, 0, 0), getClass());
final Resolution output = new Resolution(640, 400, 60);
Loader.start(Config.windowed(output), Scene.class).await();
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class ScanlineCrt method prepare.
@Override
public void prepare(Config config) {
final Resolution output = config.getOutput();
scanline = cache.get(config);
if (scanline == null) {
final Media media = Medias.create(FOLDER_SCANLINE, FOLDER_CRT, output.getWidth() + Constant.UNDERSCORE + output.getHeight() + ".png");
if (media.exists()) {
scanline = Graphics.getImageBuffer(media);
} else {
scanline = Graphics.createImageBufferAlpha(output.getWidth(), output.getHeight());
final Graphic g2 = scanline.createGraphic();
create(g2, scanline.getWidth(), scanline.getHeight());
g2.dispose();
Graphics.saveImage(scanline, media);
}
cache.put(config, scanline);
}
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class ScanlineHorizontal method prepare.
@Override
public void prepare(Config config) {
final Resolution output = config.getOutput();
scanline = cache.get(config);
if (scanline == null) {
final Media media = Medias.create(FOLDER_SCANLINE, FOLDER_HORIZONTAL, output.getWidth() + Constant.UNDERSCORE + output.getHeight() + ".png");
if (media.exists()) {
scanline = Graphics.getImageBuffer(media);
} else {
scanline = Graphics.createImageBufferAlpha(output.getWidth(), output.getHeight());
final Graphic g2 = scanline.createGraphic();
create(g2, scanline.getWidth(), scanline.getHeight());
g2.dispose();
Graphics.saveImage(scanline, media);
}
cache.put(config, scanline);
}
}
use of com.b3dgs.lionengine.Resolution in project lionengine by b3dgs.
the class LoopLocked method start.
/*
* Loop
*/
@Override
public void start(Screen screen, Frame frame) {
Check.notNull(screen);
Check.notNull(frame);
final Config config = screen.getConfig();
final Resolution output = config.getOutput();
final boolean sync = config.isWindowed() && output.getRate() > 0;
final double maxFrameTimeNano = getMaxFrameTime(output);
isRunning = true;
while (isRunning) {
if (screen.isReady()) {
final long lastTime = System.nanoTime();
frame.update(Constant.EXTRP);
screen.preUpdate();
frame.render();
screen.update();
while (sync && System.nanoTime() - lastTime < maxFrameTimeNano) {
Thread.yield();
}
frame.computeFrameRate(lastTime, Math.max(lastTime + 1L, System.nanoTime()));
} else {
frame.check();
UtilSequence.pause(Constant.DECADE);
}
if (!Engine.isStarted()) {
isRunning = false;
}
}
}
Aggregations