Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix mac project on MacBook Pro with Retina display #2359

Closed
wants to merge 2 commits into from
Closed

Fix mac project on MacBook Pro with Retina display #2359

wants to merge 2 commits into from

Conversation

linguofeng
Copy link
Contributor

Snip20130412_1
Fix mac project on MacBook Pro with Retina display

@billy1380
Copy link
Contributor

Nice!

@minggo
Copy link
Contributor

minggo commented Apr 12, 2013

What's the problem? I can run HelloCpp correctly on mac book pro retina.

@linguofeng
Copy link
Contributor Author

@linguofeng
Copy link
Contributor Author

Before:
Snip20130412_2
After:
Snip20130412_3

@dumganhar
Copy link

Your second image seems incorrect.
B3929424-8958-4FAA-B515-AC0CE915EA30

@linguofeng
Copy link
Contributor Author

Because HelloCpp proj.mac

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

    // Set the design resolution
    pEGLView->setDesignResolutionSize(designResolutionSize.width, designResolutionSize.height, kResolutionNoBorder);

    CCSize frameSize = pEGLView->getFrameSize();

    vector<string> searchPath;

    // In this demo, we select resource according to the frame's height.
    // If the resource size is different from design resolution size, you need to set contentScaleFactor.
    // We use the ratio of resource's height to the height of design resolution,
    // this can make sure that the resource's height could fit for the height of design resolution.

    // if the frame's height is larger than the height of medium resource size, select large resource.
    if (frameSize.height > mediumResource.size.height)
    {
        searchPath.push_back(largeResource.directory);

        pDirector->setContentScaleFactor(MIN(largeResource.size.height/designResolutionSize.height, largeResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is larger than the height of small resource size, select medium resource.
    else if (frameSize.height > smallResource.size.height)
    {
        searchPath.push_back(mediumResource.directory);

        pDirector->setContentScaleFactor(MIN(mediumResource.size.height/designResolutionSize.height, mediumResource.size.width/designResolutionSize.width));
    }
    // if the frame's height is smaller than the height of medium resource size, select small resource.
    else
    {
        searchPath.push_back(smallResource.directory);

        pDirector->setContentScaleFactor(MIN(smallResource.size.height/designResolutionSize.height, smallResource.size.width/designResolutionSize.width));
    }

    // set searching path
    CCFileUtils::sharedFileUtils()->setSearchPaths(searchPath);

    // turn on display FPS
    pDirector->setDisplayStats(true);

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

    // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}

mac is iphone?ipad???? why setDesignResolutionSize???

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    CCDirector* pDirector = CCDirector::sharedDirector();
    CCEGLView* pEGLView = CCEGLView::sharedOpenGLView();

    pDirector->setOpenGLView(pEGLView);

    // turn on display FPS
    pDirector->setDisplayStats(true);

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

    // create a scene. it's an autorelease object
    CCScene *pScene = HelloWorld::scene();

    // run
    pDirector->runWithScene(pScene);

    return true;
}

is ok,retina image*2

@dumganhar
Copy link

Sorry, I don't understand what you meant.
Maybe you should refer to http://www.cocos2d-x.org/projects/cocos2d-x/wiki/Multi_resolution_support.

@linguofeng linguofeng closed this Apr 13, 2013
dumganhar pushed a commit to dumganhar/cocos2d-x that referenced this pull request Jul 3, 2013
…rolSwitch.

setShaderProgram should not be in Sprite::setTexture since setTexture is not related to shader.
dumganhar pushed a commit to dumganhar/cocos2d-x that referenced this pull request Jul 3, 2013
…n Sprite.

TODO: PostionTextureColor shader should support empty texture.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 28, 2014
…rolSwitch.

setShaderProgram should not be in Sprite::setTexture since setTexture is not related to shader.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 28, 2014
…n Sprite.

TODO: PostionTextureColor shader should support empty texture.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 29, 2014
…rolSwitch.

setShaderProgram should not be in Sprite::setTexture since setTexture is not related to shader.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 29, 2014
…n Sprite.

TODO: PostionTextureColor shader should support empty texture.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 30, 2014
…rolSwitch.

setShaderProgram should not be in Sprite::setTexture since setTexture is not related to shader.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 30, 2014
…n Sprite.

TODO: PostionTextureColor shader should support empty texture.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 30, 2014
…rolSwitch.

setShaderProgram should not be in Sprite::setTexture since setTexture is not related to shader.
angeltown pushed a commit to angeltown/cocos2d-x that referenced this pull request Apr 30, 2014
…n Sprite.

TODO: PostionTextureColor shader should support empty texture.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants