Search in sources :

Example 21 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class LoopFrameSkipping method getMaxFrameTimeNano.

/**
 * Get the maximum frame time in nano seconds.
 *
 * @param screen The screen reference.
 * @return The maximum frame time in nano seconds.
 */
private static double getMaxFrameTimeNano(Screen screen) {
    final Config config = screen.getConfig();
    final Resolution source = config.getSource();
    final double expectedRate = getExpectedRate(source);
    return Constant.ONE_SECOND_IN_MILLI / expectedRate * Constant.NANO_TO_MILLI;
}
Also used : Config(com.b3dgs.lionengine.Config) Resolution(com.b3dgs.lionengine.Resolution)

Example 22 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class DrawableTest method testMissingDpi.

/**
 * Test success cases with missing DPI.
 */
@Test
public void testMissingDpi() {
    Drawable.setDpi(new Resolution(320, 240, 60), new Config(new Resolution(1920, 1200, 16), 60, false));
    try {
        testImage(false);
        testSprite(false);
        testSpriteAnimated(false, 1, 1);
        testSpriteTiled(false, 1, 1);
        testSpriteFont(false, 1, 1);
        testSpriteParallaxed(false, 1, 1, 1);
    } finally {
        Drawable.setDpi(null);
    }
}
Also used : Config(com.b3dgs.lionengine.Config) Resolution(com.b3dgs.lionengine.Resolution) Test(org.junit.Test)

Example 23 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class ScreenAwtTest method testWindowed.

/**
 * Test windowed screen.
 */
@Test
void testWindowed() {
    Medias.setLoadFromJar(ScreenAwtTest.class);
    final Config config = new Config(UtilTests.RESOLUTION_320_240, 32, true, Medias.create("image.png"));
    testScreen(config);
}
Also used : Config(com.b3dgs.lionengine.Config) Test(org.junit.jupiter.api.Test)

Example 24 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class ScreenHeadlessTest method testWindowed.

/**
 * Test windowed screen.
 *
 * @throws Exception If error.
 */
@Test
void testWindowed() throws Exception {
    final Config config = new Config(com.b3dgs.lionengine.UtilTests.RESOLUTION_320_240, 32, true, Medias.create(IMAGE));
    assertTimeout(1000L, () -> testScreen(config));
}
Also used : Config(com.b3dgs.lionengine.Config) Test(org.junit.jupiter.api.Test)

Example 25 with Config

use of com.b3dgs.lionengine.Config in project lionengine by b3dgs.

the class LoopFrameSkipping method hasSync.

/**
 * Check if screen has sync locked.
 *
 * @param screen The screen reference.
 * @return <code>true</code> if sync enabled, <code>false</code> else.
 */
private static boolean hasSync(Screen screen) {
    final Config config = screen.getConfig();
    final Resolution output = config.getOutput();
    return config.isWindowed() && output.getRate() > 0;
}
Also used : Config(com.b3dgs.lionengine.Config) Resolution(com.b3dgs.lionengine.Resolution)

Aggregations

Config (com.b3dgs.lionengine.Config)89 Resolution (com.b3dgs.lionengine.Resolution)75 Screen (com.b3dgs.lionengine.graphic.Screen)47 ScreenMock (com.b3dgs.lionengine.graphic.ScreenMock)45 Test (org.junit.jupiter.api.Test)42 Test (org.junit.Test)38 FactoryGraphicMock (com.b3dgs.lionengine.graphic.FactoryGraphicMock)2 Semaphore (java.util.concurrent.Semaphore)2 AtomicReference (java.util.concurrent.atomic.AtomicReference)2 Context (com.b3dgs.lionengine.Context)1 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 ImageBuffer (com.b3dgs.lionengine.graphic.ImageBuffer)1 Rasterbar (com.b3dgs.lionengine.graphic.engine.Rasterbar)1 Sequencer (com.b3dgs.lionengine.graphic.engine.Sequencer)1 SourceResolutionProvider (com.b3dgs.lionengine.graphic.engine.SourceResolutionProvider)1 FilterBilinear (com.b3dgs.lionengine.graphic.filter.FilterBilinear)1