Glview->getFrameSize() get wrong result on win32 Project

Hi there!

I created new project and run on win32. When i get the screen size by glview->getFrameSize() the result alway is 960*640.

Here is all codes on applicationDidFinishLaunching:

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("My Game");
        director->setOpenGLView(glview);
    }
    // turn on display FPS
    director->setDisplayStats(true);

    // set FPS. the default value is 1.0/60 if you don't call this
    director->setAnimationInterval(1.0 / 60);

  	auto screenSize = glview->getFrameSize(); // return 960*640
	auto _mVisibleSize = Director::getInstance()->getVisibleSize(); // 960*640
	auto _mWinsize = Director::getInstance()->getWinSize(); // 960*640
	 
    // create a scene. it's an autorelease object
    auto scene = HelloWorld::createScene();

    // run
    director->runWithScene(scene);
    return true;
}

I know that when we run project for iOS if we want support the 4" screen ratio then we must copy “Default-568h@2x.png” image file to resource folder. But i don’t know how to do the same on win32 project.

So have anyone please help me to resolve this issue?
Thanks!

Add below line and define SCREEN_WIDTH & SCREEN_HEIGHT whatever you want.

if(!glview) {
	glview = GLViewImpl::create(GAME_NAME);
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
	glview->setFrameSize(SCREEN_WIDTH, SCREEN_HEIGHT);
#endif
	director->setOpenGLView(glview);
}
1 Like

I am getting the same problem and it’s driving me nuts. I don’t want to set an arbitrary frame size, I want to check the size of the computer’s resolution and customize my code depending on that, but getFrameSize() returns a garbage value of -107374176 for width and height, and the glview object is getting a screen size of 960 x 640 initially. How can I get the size of the user’s resolution for win32?

If you want to check the size of the computer’s resolution then set your screen full resolution and then get it with getVisibleSize

That was just what I needed, thanks! Does anyone know if Cocos2D-x supports fullscreen/windowed toggling now? I knew they didn’t a while back.