2

My game is designed for landscape only (screen resolution 1024*768 - iPad resolution).

My game scene is rendered correctly on every platform supported by PlayN (Android, html etc). The problem with iOS only.

I have prepared all the resources for iPad screen resolution, setup info.plist file, registered platform using IOSPlatform.register(app, IOSPlatform.SupportedOrients.LANDSCAPES);

When I run my application everything regarding device orientaton is correct, but game scene isn't fully rendered. It is rendered for the resolution 768*768 (Not all of the scene objects are visible - only objects that belong to 768*768 rect are visible) and the remaining screen space is black.

I've investigated the issue in the following way:

  1. Applied scale transform to rootLayer (to make sure the entire scene is rendered). PlayN.graphics().rootLayer().setScale(0.75f, 0.75f); Result - game scene fits in 768*768 rect and I can see all game scene objects.
  2. Applied translate transform to rootLayer (to make sure PlayN doesn't render scene outside of 768*768 rect). PlayN.graphics ().rootLayer().setTranslation(1024.0f - 768.0f, 0.0f); Result - game scene is translated, but objects that are not belong to 768*768 screen rect are not visible.

My guess is that PlayN prepares its drawing context for the 768*1024 screen resolution (default iPad orientation resolution). When it renders the screen the objects located outside of 768*1024 rectangle are clipped (not rendered).

Any help or ideas what can cause such strange behavior would be very appreciated.

Thanks!

2 Answers 2

1

The problem is in the following:

  • iOS doesn't change main window frame and root view frame after device rotation (while Android does - I've checked).
  • PlayN code expects that view size after rotation should be changed from 768*1024 (default orientation) to 1024*768.

Actual result: PlayN transforms game scene using transform matrix but doesn't change OpenGL framebuffer size (framebuffer size is still 768*1024)

I've fixed this issue by adding the next piece of code to IOSGLContext:

@Override
public void setSize (int width, int height)
{
    if (UIDeviceOrientation.LandscapeLeft == orient || UIDeviceOrientation.LandscapeRight == orient)
    {
        Console.WriteLine("Swap IOSGLContext width and height for " + UIDeviceOrientation.wrap(orient));
        viewWidth = height;
        viewHeight = width;
    }
    else
    {
        viewWidth = width;
        viewHeight = height;
    }
    super.setSize(viewWidth, viewHeight);
}

Now everything work as expected!

If you have any other ideas how to fix this issue I will be glad to discuss them)

Thanks!

0

download the latest PlayN-1.5 snapshot (from -> https://github.com/threerings/playn not from google code). This issue is fixed in that version

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.