Search in sources :

Example 36 with Resolution

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();
}
Also used : Resolution(com.b3dgs.lionengine.Resolution) Test(org.junit.jupiter.api.Test)

Example 37 with Resolution

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();
}
Also used : Resolution(com.b3dgs.lionengine.Resolution) Test(org.junit.jupiter.api.Test)

Example 38 with Resolution

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);
    }
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Media(com.b3dgs.lionengine.Media) Resolution(com.b3dgs.lionengine.Resolution)

Example 39 with Resolution

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);
    }
}
Also used : Graphic(com.b3dgs.lionengine.graphic.Graphic) Media(com.b3dgs.lionengine.Media) Resolution(com.b3dgs.lionengine.Resolution)

Example 40 with Resolution

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;
        }
    }
}
Also used : Config(com.b3dgs.lionengine.Config) Resolution(com.b3dgs.lionengine.Resolution)

Aggregations

Resolution (com.b3dgs.lionengine.Resolution)95 Config (com.b3dgs.lionengine.Config)75 Screen (com.b3dgs.lionengine.graphic.Screen)45 ScreenMock (com.b3dgs.lionengine.graphic.ScreenMock)45 Test (org.junit.jupiter.api.Test)45 Test (org.junit.Test)33 Graphic (com.b3dgs.lionengine.graphic.Graphic)3 Media (com.b3dgs.lionengine.Media)2 LionEngineException (com.b3dgs.lionengine.LionEngineException)1 FilterBilinear (com.b3dgs.lionengine.core.filter.FilterBilinear)1 FilterBlur (com.b3dgs.lionengine.core.filter.FilterBlur)1 FilterHq2x (com.b3dgs.lionengine.core.filter.FilterHq2x)1 FilterHq3x (com.b3dgs.lionengine.core.filter.FilterHq3x)1 SourceResolutionDelegate (com.b3dgs.lionengine.graphic.engine.SourceResolutionDelegate)1 FilterBilinear (com.b3dgs.lionengine.graphic.filter.FilterBilinear)1 FilterBlur (com.b3dgs.lionengine.graphic.filter.FilterBlur)1 FilterHq2x (com.b3dgs.lionengine.graphic.filter.FilterHq2x)1 FilterHq3x (com.b3dgs.lionengine.graphic.filter.FilterHq3x)1 DisplayMode (java.awt.DisplayMode)1 GraphicsDevice (java.awt.GraphicsDevice)1