Potential bug in CCEGLViewProtocol::setFrameSize

Hello.

I am one of the developers at Coffee Stain Studios and we have our game Super Sanctum TD built using Cocos2dx and Marmalade. This is actually our second Cocos game. We built our first ever game I Love Strawberries in cocos2d-iphone some years ago. Appart from cocos we mainly work with Unreal Engine.

Anyway, back to topic. As Super Sanctum TD runs on PC and Mac I started investigating trying to make it possible to resize the window and have the game scale accordingly. This turned out to be a pretty nasty task. I first tried using VirtualResolution settings in IwGL. This turned out to help me “start the app” in various resolutions and then render properly in those but as soon as I resize the window it all went bananas.

I also considered using a solution that used a root CCNode in each scene that I just added all content to and then scaled it, but then from what I’ve understood DesignResolution should be able to help me out so I figured I’d aim for that. Anyway, so basically trying to set the design resolution to 1024x768 and then re-sizing the window I still never got it to scale properly.

Finally I noticed that this in CCEGLViewProtocol.cpp
void EGLViewProtocol::setFrameSize(float width, float height) { _designResolutionSize = _screenSize = Size(width, height); }
Should the designResolutionSize really get the same value here? Seems a bit strange to me.
I changed it so that it only changes the
screenSize and after that I can resize my window fine and the app renders correctly.

Saw this is still the same in cocos2dx 3 beta so I figured I’d make a post.

Love cocos and I really appreciate all the hard work you put down into it :slight_smile:

Best
Anton

Have you read this? http://www.cocos2d-x.org/wiki/Multi_resolution_support

It was helpful for me.

I read that, but it didn’t help me :slight_smile:

I don’t use contentScaleFactor. We use the same content but we want the full rendered area on the screen to scale to adapt to the current screen/surface size. I also think the fact that we run our game in Marmalade makes a difference as they have their own OpenGL implementation.

Do you resize your game during runtime successfully? Would be interesting to hear how you do it then.

Anton

I design everything on an ipad that is 1024 x 768. I then do all of my scaling based upon that resolution. So if my game is running in a Retina iPad (2048 x 1536) all of my operations check a few booleans to know what device they are running on and multiple my math times a scale factor that I set (1 for non-retina, 2 for retina, .5 for less than 1024 x 768). This gives me a lot of flexibility when wanting to be very specific to screen layout on a particular device.