Search in sources :

Example 16 with Resolution

use of com.b3dgs.lionengine.Resolution 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)

Example 17 with Resolution

use of com.b3dgs.lionengine.Resolution 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 18 with Resolution

use of com.b3dgs.lionengine.Resolution 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 19 with Resolution

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

the class Sequence method setTime.

@Override
public void setTime(double factor) {
    final double scale = UtilMath.clamp(factor, 0.1, 5.0);
    final Resolution time = new Resolution(resolution.getWidth(), resolution.getHeight(), (int) (resolution.getRate() * scale));
    loop.notifyRateChanged(time.getRate());
    onRateChanged(time.getRate());
}
Also used : Resolution(com.b3dgs.lionengine.Resolution)

Example 20 with Resolution

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

the class SequenceRenderer method getTransform.

/**
 * Get the transform associated to the filter keeping screen scale independent.
 *
 * @return The associated transform instance.
 */
private Transform getTransform() {
    final Resolution output = config.getOutput();
    final double scaleY = output.getHeight() / (double) source.getHeight();
    if (UtilMath.equals(output.getWidth() / (double) output.getHeight(), source.getWidth() / (double) source.getHeight(), SCALE_PRECISION)) {
        return filter.getTransform(scaleY, scaleY);
    }
    final double scaleX = output.getWidth() / (double) source.getWidth();
    return filter.getTransform(scaleX, scaleY);
}
Also used : 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