Visibile size, window size etc

Visibile size, window size etc
0.0 0


Hi Guys,

Whats the difference between getVisibleSize and getWindowSize and when to use what. I see in some examples visible size being used and in some places window size. Thanks in advance for the help.


Sometimes they’re the same.
The API documentation says:

Size getVisibleSize() const

returns visible size of the OpenGL view in points.
the value is equal to getWinSize if don't invoke EGLView::setDesignResolutionSize()

const Size& getWinSize() const

returns the size of the OpenGL view in points. 

If you didn’t use EGLView::setDesignResolutionSize(), either of them is okay.
But as their names said, getVisibleSize() returns the visible size, and getWinSize() returns the OpenGL view size. In windows, the size of the OpenGL view is the window size.
For example, in Windows 7, we can see a border around the Cocos2d-x window. This is not in the visible size, but it’s in the window size.

So if you want to get the size which the player can see, please use getVisibleSize.
Hope this can help you!


In another word, if you called EGLView::setDesignResolutionSize(), like:

EGLView::getInstance()->setDesignResolutionSize(480, 320, ResolutionPolicy::NO_BORDER);

then getWinSize() returns Size(480, 320), and getVisibleSize() returns the size which the user can see [On my machine (Win7), that is Size(450, 320)].


@Pisces000221 Nice and clear explanation. Epic!


@Pisces000221 what if I don’t use ResolutionPolicy::NO_BORDER? Instead I have used fixed width. What would be the values for visible and win sizes? In my case I have set design resolutions of 2048 x 1536 and I get bot h sizes equal to 2048 x 1229. How can we explain this?


@naghekyan Hello again!
getFrameSize() - returns the accessible part of your screen resolution (and always when mentioned the screen resolution, it is meant available screen resolution)
getWinSize() - returns the design resolution, but as you carefully noticed (in another topic) in the case of use FIXED_HEIGHT/FIXED_WIDTH, the design resolution is recalculated so to have the same aspect ratio as the screen resolution
getVisibleSize() - returns the part of the design resolution which will be visible after the transformation the Design resolution -> to the Screen resolution.

In your case, it seems that you are using FIXED_WIDTH, 2048 x 1229 - it is accessible part of your screen resolution.
Screen resolution on your tablet/emulator on the specification is 2048 x 1536? If yes, then
Do you have something like the action bar on your screen? Something that occupies a part of your screen.
So, since it is your ‘screen resolution’, the design resolution was recalculated, and the design resolution is 2048 x 1229 now.

p.s. I did not forget about writing the guide, I think that the majority will be completed today or tomorrow. Do you have time to Review?


@TheRC thanks. Sure I will review!


@naghekyan Thank you)) I will send you PM as soon as it will be ready.