@748951263 wrote:
I've looked at this problem for quite some time now but still cannot seem to figure out how to do it correctly. I've looked at several tops that don't explain it correctly either. I've been trying to implement multi-resolution for my application however there seems to be a problem with how I retrieve the screen size. I can't tell if i'm fundamentally misunderstanding something or if there is a bug in the code like other threads have suggested about this topic. So here is the gist of my problem.
cocos documents tells me the following about how to get the screen resolution.
//get screen resolution Director::getInstance()->getOpenGLView()->getFrameSize()
However, this function for me does not return the screen resolution. Instead it returns the resolution of the OpenGl. I know this because of the following code in appDelegate.cpp.
if(!glview) { #if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) || (CC_TARGET_PLATFORM == CC_PLATFORM_MAC) || (CC_TARGET_PLATFORM == CC_PLATFORM_LINUX) glview = GLViewImpl::createWithRect("ShapeScape", Rect(0, 0, dsignResolutionSize.width, designResolutionSize.height)); #else glview = GLViewImpl::create("ShapeScape"); #endif director->setOpenGLView(glview); } //designResolutionSize is defined below
This code is taken directly from the HelloWordScene that builds when you create a new project. In the above code designResolutionSize is defined as follows.
static cocos2d::Size designResolutionSize = cocos2d::Size(320,480);
I am not using an emulator so when this program runs it it sets the glview resolution to the one specified by designResolutionSize. Then, when I call the getFrameSize() function on glview it always returns the resolution specified by designResolutionSize. I've checked to see if this is the case when I don't use the platform check in the if statement above by simply replacing the following under the if statement
glview = GLViewImpl::create("ShapeScape");
This time getFrameSize() returns 960x640. I've check the definition of GLViewImpl::create() and its clear that it initializes an OpenGL with the resolution 960x640. It seems that getFrameSize() is not returning the screen Resolution of my device but just the resolution of the OpenGL. Am I fundamentally misunderstanding something about how this works? How can I get the screen size of the Device that my program is running on?
Posts: 1
Participants: 1