Full Screen on Mac OSX

I’m new to cocos but I’ve been looking for a while at the api and searching for this without finding something that worked for me.

I want to create a fullscreen window,

to do that I used the following code:

if(!glview) {
        glview = GLViewImpl::createWithFullScreen("ColorQueue");
        director->setOpenGLView(glview);
}

It more or less does it, at least all my screen gets filled and a nice animation is performed but stuff is not properly displayed, I can only see the first quarter of what it should:

As you can see if I use this other code instead I get the proper result:

if(!glview) {
        glview = GLViewImpl::create("ColorQueue");
        director->setOpenGLView(glview);
}

Also I found a related bug, or at least I think so because if I do the following:

if(!glview) {
        glview = GLViewImpl::create("ColorQueue");
        glview = GLViewImpl::createWithRect("ColorQueue", cocos2d::Rect(0, 0, 2560, 1600));
}

where 2560 x 1600 is my screen width and height I get a really enormous screen way bigger than my display and I really don’t know why

For the rest of the code I’m using the Hello word example code, I don’t know if the problem is that the full screen is not done like this, but it’s the way I found on previous questions about the topic, maybe it’s because I’m running Mac OS Mojave on beta 3, or maybe it’s because I have my dock on the side, in a really old post about this there was a problem with this and resizing from normal to full screen at runtime.
The code for creating a fullscreen scene, or maybe a way to resize the window with the green Mac toggle or some basic example with this wold be so helpful.

I’m new to the community so I really hope this is the right place for this post.

Thanks in advise :slight_smile:

I do it the same way you do for full screen. I also tried getting height and width from the director and that works too

Have you filed the bug on GitHub already?

1 Like

If you do it the same way and works for you but not for me I assume it’s a bug so I’m gonna reported on GitHub right now, also the other bug with createRect, maybe it’s something related with Mac OS Mojave.
Thank you :slight_smile:

@MrBlissfulGrin I think this has already been reported over 2 years ago… its the issue of your macOs settings if you change the text size.
Change it to default to fix this issue.

1 Like

let me know if it helps. thanks

@bilalmirza
Yes, that solved the problem, thank you so much.

I’m so sorry if this was answered previously, I couldn’t find that post.

Is there any explanation for this issue and also is there any intention to solve it?

1 Like

I worked on it for quite a while. Couldn’t find any good solution. I will be releasing my game with it :frowning:

Workaround fix

I hope this helps

this bug is still present in the current cocos2d-x … this is how I managed to fix it.

in Appdelegate after creating as fullscreen… those of you who don’t want to change cocos2d-x

#if( CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
     glview->setFrameSize(1440, 900);
                ((GLViewImpl *)glview)->enableRetina(true);
                ((GLViewImpl *)glview)->setFrameZoomFactor(2.0f);
#endif

this will work for all macbook pro resolutions and will produce retina output.

disadvantage is that screen adjusts resolution 2-3 times before the app is starting. so in order to fix that i went in the glviewImp::initwithRect() and where you set the framesize

    setFrameSize(rect.size.width, rect.size.height);

changed it to

#if CC_TARGET_PLATFORM == CC_PLATFORM_MAC
    _isRetinaEnabled = true;
    _frameZoomFactor = 2.0f;
    setFrameSize(1440,900);

#else
    setFrameSize(rect.size.width, rect.size.height);
#endif

This way updateFrameSize() is only called once.
I’m not sure if its the best solution but now there are no black screen and all resolutions are supported.

Tested on macbook pro 2018 && macbook pro mid 2015. and on all scaled displays.

1 Like

@bilalmirza is there a GitHub issue for this?

yes… its in the post above

@bilalmirza thanks. I totally over-scrolled.

@drelaptop We should fix this. It is a common question.

GitHub issue

work around

Plus see the post by @bilalmirza 3 spots above this post.

1 Like