当前位置: 首页>>代码示例>>C++>>正文


C++ Director::getOpenGLView方法代码示例

本文整理汇总了C++中Director::getOpenGLView方法的典型用法代码示例。如果您正苦于以下问题:C++ Director::getOpenGLView方法的具体用法?C++ Director::getOpenGLView怎么用?C++ Director::getOpenGLView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Director的用法示例。


在下文中一共展示了Director::getOpenGLView方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DoInitFixedScreenSize

void ScreenSizeManager::DoInitFixedScreenSize(float myScreenWidth,
                                              float myScreenHeight)
{
    _isInit = true;
    // cocos2d-x v3.0.0 이상만 지원.
    CCAssert(0x00030000 <= COCOS2D_VERSION, "ScreenSizeManager need to cocos2d-x 3.0.0 or higher!");
    
    Director* kDirector = CCDirector::getInstance();
    
    CCAssert(kDirector->getOpenGLView(), "ScreenSizeManager need to kDirector->getOpenGLView() is not NULL");
    
    Size kWinSize = kDirector->getWinSize();
    
    _screenSize.width = kWinSize.width;
    _screenSize.height = kWinSize.height;
    
    _imageResolutionSize.width = myScreenWidth;
    _imageResolutionSize.height = myScreenHeight;
    
    log("DoInitFixedScreenSizeManager %f %f", _imageResolutionSize.width, _imageResolutionSize.height);
    
    // Cocos2d상의 포인트영역이 _imageResolutionSize.width, _imageResolutionSize.height 으로 설정된다.
    // CCDirector::sharedDirector()->getWinSize()의 width, height 가 _imageResolutionSize.width, _imageResolutionSize.height 로 된다.
    
    ResolutionPolicy kResolutionPolicy = ResolutionPolicy::NO_BORDER;
    
    GLView* kGLView = kDirector->getOpenGLView();
    kGLView->setDesignResolutionSize(_imageResolutionSize.width, _imageResolutionSize.height, kResolutionPolicy);
    
    
}
开发者ID:OhByeongYun,项目名称:1989flanker-cpp,代码行数:31,代码来源:ScreenSizeManager.cpp

示例2: DoInitFlexibleScreenSize

void ScreenSizeManager::DoInitFlexibleScreenSize(float myImageResolutionWidth,
                                                 float myImageResolutionHeight)
{
    _isInit = true;
    // cocos2d-x v3.0.0 이상만 지원.
    CCAssert(0x00030000 <= COCOS2D_VERSION, "ScreenSizeManager need to cocos2d-x 3.0.0 or higher!");
    
    Director* kDirector = Director::getInstance();
    
    CCAssert(kDirector->getOpenGLView(), "ScreenSizeManager need to kDirector->getOpenGLView() is not NULL");
    
    Size kWinSize = kDirector->getWinSize();
    
    _screenSize.width = kWinSize.width;
    _screenSize.height = kWinSize.height;
    
    _imageResolutionSize.width = myImageResolutionWidth;
    _imageResolutionSize.height = myImageResolutionHeight;
    
    float kDefaultDesignResRatio = _imageResolutionSize.width / _imageResolutionSize.height;
    float kScreenRatio = _screenSize.width / _screenSize.height;
    
    if ( kDefaultDesignResRatio <= kScreenRatio)
    {
        float kHeightRatio = _screenSize.height  / _imageResolutionSize.height;
        // 폭이 넓은 경우
        _imageResolutionSize.width = (int)(_screenSize.width / kHeightRatio);
        _isScaleHeight = true;
    }
    else
    {
        // 높이가 긴 경우
        float kWidthRatio = _screenSize.width / _imageResolutionSize.width;
        // 폭이 넓은 경우
        _imageResolutionSize.height = (int)(_screenSize.height  / kWidthRatio);
        _isScaleHeight = false;
    }
    
    log("DoInitResourceSizeScreen %f %f", _imageResolutionSize.width, _imageResolutionSize.height);
    
    // Cocos2d상의 포인트영역이 _imageResolutionSize.width, _imageResolutionSize.height 으로 설정된다.
    // CCDirector::sharedDirector()->getWinSize()의 width, height 가 _imageResolutionSize.width, _imageResolutionSize.height 로 된다.
    ResolutionPolicy kResolutionPolicy = ResolutionPolicy::NO_BORDER;
   
    GLView* kGLView = kDirector->getOpenGLView();
    kGLView->setDesignResolutionSize(_imageResolutionSize.width, _imageResolutionSize.height, kResolutionPolicy);
  
    
}
开发者ID:OhByeongYun,项目名称:1989flanker-cpp,代码行数:49,代码来源:ScreenSizeManager.cpp

示例3: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
	Director* director = Director::getInstance();
	GLView* 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);

    register_all_packages();

    // create a scene. it's an autorelease object
    Scene* scene = WelcomeScene::scene();

    // run
    director->runWithScene(scene);

    SimpleAudioEngine::getInstance()->preloadBackgroundMusic("sounds/BgmCity.mp3");
    SimpleAudioEngine::getInstance()->playBackgroundMusic("sounds/BgmCity.mp3",true);
    return true;
}
开发者ID:dyn654466499,项目名称:MyCocosGame,代码行数:27,代码来源:AppDelegate.cpp

示例4: _startGameMenuCallback

void WelcomeMenu::_startGameMenuCallback(Ref* pSender)
{
    Director* director = Director::getInstance();
    GLView*   glView   = director->getOpenGLView();
    Size frameSize      = glView->getFrameSize();
    Size winSize       = director->getWinSize();
    log("winSize %f=%f ",winSize.width, winSize.height );
    log("frameSize %f=%f", frameSize.width, frameSize.height);
}
开发者ID:youngershen,项目名称:FingerStyle,代码行数:9,代码来源:WelcomeMenuScene.cpp

示例5: draw

            void WebViewImpl::draw(Renderer *renderer, Mat4 const &transform, uint32_t flags)
            {
                if (_createSucceeded && (flags & Node::FLAGS_TRANSFORM_DIRTY))
                {
                    Director *directorInstance = cocos2d::Director::getInstance();
                    GLView *glView = directorInstance->getOpenGLView();
                    const Size &frameSize = glView->getFrameSize();
                    const Size &winSize = directorInstance->getWinSize();
                    Vec2 leftBottom = this->_webView->convertToWorldSpace(Point::ZERO);
                    Vec2 rightTop = this->_webView->convertToWorldSpace(Point(_webView->getContentSize().width, _webView->getContentSize().height));
                    float uiLeft = frameSize.width / 2 + (leftBottom.x - winSize.width / 2) * glView->getScaleX();
                    float uiTop = frameSize.height / 2 - (rightTop.y - winSize.height / 2) * glView->getScaleY();

                    _systemWebControl->setWebViewRect(uiLeft, uiTop,
                        (rightTop.x - leftBottom.x) * glView->getScaleX(),
                        (rightTop.y - leftBottom.y) * glView->getScaleY());
                }
            }
开发者ID:253627764,项目名称:FantasyWarrior3D,代码行数:18,代码来源:UIWebViewImpl-win32.cpp

示例6: clear

void TextureManager::clear() {
    Director *director = Director::getInstance();
    auto glView = director->getOpenGLView();
    auto renderer = director->getRenderer();

    long long start = currentTimeMillis();
    CCLOG("texMgr clear texModuleCount=%d", texModuleMap.size());
    renderer->render();
    CCLOG("render before success");

    int textureCosts[TEXTURE_COUNT] = {0};

    int curLoopCounter = Director::loopCounter;

    for(auto& entry : texModuleMap) {
        auto tm = entry.second;

        for(int i = 0; i < TEXTURE_COUNT; ++i) {
            if(textures[i] == tm->tex) {
                textureCosts[i] += (tm->lastCallCounter - curLoopCounter) * tm->width * tm->height;
                break;
            }
        }
    }

    int min = INT_MAX;
    int index = -1;

    for(int i = 0; i < TEXTURE_COUNT; ++i) {
        CCLOG("textureCosts[%d]=%d", i, textureCosts[i]);

        if(min > textureCosts[i]) {
            min = textureCosts[i];
            index = i;
        }
    }

    int length = TEXTURE_SIZE * TEXTURE_SIZE << 2;
    byte *data = new byte[length];
    memset(data, 0, length);
    textures[index]->initWithData(data, length, Texture2D::PixelFormat::RGBA8888, TEXTURE_SIZE, TEXTURE_SIZE, Size(TEXTURE_SIZE, TEXTURE_SIZE));
    textureBins[index]->init(TEXTURE_SIZE, TEXTURE_SIZE);

    std::vector<int> toDeletes;

    for(auto& entry : texModuleMap) {
        auto tm = entry.second;

        if(tm->tex == textures[index]) {
            CC_SAFE_DELETE(tm);
            toDeletes.push_back(entry.first);
        }
    }

    for(auto id : toDeletes) {
        texModuleMap.erase(id);
    }

	toDeletes.clear();

	for (auto& entry : texCoordCalculatedMap) {
		auto tex = entry.second;
		if (tex == textures[index]) {
			toDeletes.push_back(entry.first);
		}
	}

	for (auto id : toDeletes) {
		texCoordCalculatedMap.erase(id);
	}

    CC_SAFE_DELETE_ARRAY(data);
    CCLOG("after texMgr clear texModuleCount=%d, clearTexId=%d, recalculate count %d, cost Time=%lld", texModuleMap.size(), index, toDeletes.size(), currentTimeMillis() - start);
}
开发者ID:289,项目名称:DouPo,代码行数:74,代码来源:TextureManager.cpp

示例7: applicationDidFinishLaunching

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    Director* pDirector = gDirector;
    
    GLView* pGLView = pDirector->getOpenGLView();
    if( NULL == pGLView )
    {
        pGLView = GLView::create("game(v1.0.0.0)---test for inner");
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
        pGLView->setFrameSize(1334, 750);
#endif
        
        pDirector->setOpenGLView(pGLView);
    }
    
    // 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);
    
    // resolution information  
    Size size;  
    size= pDirector->getWinSize();
	log("***IDONG: Director getWinSize:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getWinSizeInPixels();  
	log("***IDONG: Director getWinSizeInPixels:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getVisibleSize();  
	log("***IDONG: Director getVisibleSize:w=%f,h=%f",size.width,size.height);  

	Point point = pDirector->getVisibleOrigin();  
	log("***IDONG: Director getVisibleOrigin:x=%f,y=%f",point.x,point.y);  


	log("***IDONG: Director BS: getContentScaleFactor: scaleFactor=%f",pDirector->getContentScaleFactor());  

	auto framsize = pGLView->getFrameSize();
	auto dwinsize = pDirector->getWinSize();
	auto designsize = Size(SCREEN_WIDTH, SCREEN_HEIGHT);
	auto widthRate = framsize.width/designsize.width;
	auto heightRate = framsize.height/designsize.height;

	auto  resolutionRate = 1.f;
	if(widthRate > heightRate) 
	{
		pGLView->setDesignResolutionSize(designsize.width,
		 designsize.height*heightRate/widthRate, ResolutionPolicy::NO_BORDER);
		 resolutionRate = heightRate/widthRate;
	}
	else
	{
		pGLView->setDesignResolutionSize(designsize.width*widthRate/heightRate, designsize.height,
		 ResolutionPolicy::NO_BORDER);
		 resolutionRate = widthRate/heightRate;
	}

	//pGLView->setDesignResolutionSize(SCREEN_WIDTH, SCREEN_HEIGHT, ResolutionPolicy::FIXED_HEIGHT);

	log("***IDONG:/n");  
	log("***IDONG: Director AS: getContentScaleFactor: scaleFactor=%f",pDirector->getContentScaleFactor());  

	size= pDirector->getWinSize();  
	log("***IDONG: Director getWinSize:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getWinSizeInPixels();  
	log("***IDONG: Director getWinSizeInPixels:w=%f,h=%f",size.width,size.height);  

	size = pDirector->getVisibleSize();  
	log("***IDONG: Director getVisibleSize:w=%f,h=%f",size.width,size.height);  

	point = pDirector->getVisibleOrigin();  
	log("***IDONG: Director getVisibleOrigin:x=%f,y=%f",point.x,point.y);  

	// ‘ˆº”À—À˜¬∑æ∂
	gFileUtils->addSearchPath("assets");

	// …Ë÷√◊ ‘¥ƒø¬�?
	// ≥ı ºªØ◊ ‘¥ƒø¬�?dumpŒƒº˛…˙≥…ƒø¬�?
	string logfile = "";
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
	gGameManager->SetResourceRoot("/mnt/sdcard/com.zm.mszb/");
	gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
	gGameManager->CreateDirectory(gGameManager->GetLogPath());
	logfile = gGameManager->GetLogPath()+"/log.txt";
	gLog->Open(logfile.c_str());
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WIN32)
	gGameManager->SetResourceRoot("");
	gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
	gGameManager->CreateDirectory(gGameManager->GetLogPath());
	logfile = gGameManager->GetLogPath()+"/log.txt";
	gLog->Open(logfile.c_str());
#endif
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
	gGameManager->SetResourceRoot(gFileUtils->getWritablePath());
	gGameManager->CreateDirectory(gGameManager->GetResourceRoot());
	gGameManager->CreateDirectory(gGameManager->GetLogPath());
	logfile = gGameManager->GetLogPath()+"/log.txt";
//.........这里部分代码省略.........
开发者ID:SmallRaindrop,项目名称:LocatorApp,代码行数:101,代码来源:AppDelegate.cpp


注:本文中的Director::getOpenGLView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。