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


C++ retain函数代码示例

本文整理汇总了C++中retain函数的典型用法代码示例。如果您正苦于以下问题:C++ retain函数的具体用法?C++ retain怎么用?C++ retain使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: retain

	// Adds child at <code>index<code/>, or does nothing if <code>index<code/> greater than <code>numChildren</code>.
	void DisplayObject::addChildAt(DisplayObject * displayObject, unsigned int index)
	{
		if (index <= numChildren()) {
			std::vector<DisplayObject*>::iterator it;
			
			// Get iterator for index.
			it = _children.begin();
			it += index;
			
			// Insert child
			_children.insert(it, displayObject);
			displayObject->setParent(this);
			
			// hold on to it so it doesn't get freed.
			retain(displayObject);
		}
	}
开发者ID:masiw,项目名称:masicore,代码行数:18,代码来源:DisplayObject.cpp

示例2: retain

void NetworkSprite::loadTexture() {
	if (_asset && _asset->isReadAvailable()) {
		auto cache = TextureCache::getInstance();

		Asset * asset = _asset;

		retain();
		cache->addTexture(_asset, [this, asset] (cocos2d::Texture2D *tex) {
			if (asset == _asset && tex) {
				setTexture(tex, Rect(0, 0, tex->getContentSize().width, tex->getContentSize().height));
			}
			release();
		}, _texture != nullptr);
	} else {
		setTexture(nullptr, Rect::ZERO);
	}
}
开发者ID:SBKarr,项目名称:stappler,代码行数:17,代码来源:SPNetworkSprite.cpp

示例3: ofGetGLProgrammableRenderer

//--------------------------------------------------------------
void ofVbo::setVertexData(const float * vert0x, int numCoords, int total, int usage, int stride) {

#ifdef TARGET_OPENGLES
	if(!vaoChecked){
		if(ofGetGLProgrammableRenderer()){
			glGenVertexArrays = (glGenVertexArraysType)dlsym(RTLD_DEFAULT, "glGenVertexArrays");
			glDeleteVertexArrays =  (glDeleteVertexArraysType)dlsym(RTLD_DEFAULT, "glDeleteVertexArrays");
			glBindVertexArray =  (glBindVertexArrayType)dlsym(RTLD_DEFAULT, "glBindVertexArrayArrays");
		}else{
			glGenVertexArrays = (glGenVertexArraysType)dlsym(RTLD_DEFAULT, "glGenVertexArraysOES");
			glDeleteVertexArrays =  (glDeleteVertexArraysType)dlsym(RTLD_DEFAULT, "glDeleteVertexArraysOES");
			glBindVertexArray =  (glBindVertexArrayType)dlsym(RTLD_DEFAULT, "glBindVertexArrayArraysOES");
		}
		vaoChecked = true;
		supportVAOs = glGenVertexArrays && glDeleteVertexArrays && glBindVertexArray;
	}
#else
	if(!vaoChecked){
		supportVAOs = ofGetGLProgrammableRenderer() || glewIsSupported("GL_ARB_vertex_array_object");
		vaoChecked = true;
	}
#endif


	if(vertId==0) {
		bAllocated  = true;
		bUsingVerts = true;
		vaoChanged=true;
		glGenBuffers(1, &(vertId));
		retain(vertId);
		#if defined(TARGET_ANDROID) || defined(TARGET_OF_IOS)
			registerVbo(this);
		#endif
	}

	vertUsage = usage;
	vertSize = numCoords;
	vertStride = stride==0?3*sizeof(float):stride;
	totalVerts = total;
	
	glBindBuffer(GL_ARRAY_BUFFER, vertId);
	glBufferData(GL_ARRAY_BUFFER, total * stride, vert0x, usage);
	glBindBuffer(GL_ARRAY_BUFFER, 0);

}
开发者ID:TheAtomicBen,项目名称:openFrameworks,代码行数:46,代码来源:ofVbo.cpp

示例4: initGLContextAttrs

int Application::run()
{
    initGLContextAttrs();
    // Initialize instance and cocos2d.
    if (! applicationDidFinishLaunching())
    {
        return 0;
    }

    long lastTime = 0L;
    long curTime = 0L;

    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();

    // Retain glview to avoid glview being released in the while loop
    glview->retain();

    while (!glview->windowShouldClose())
    {
        lastTime = getCurrentMillSecond();

        director->mainLoop();
        glview->pollEvents();

        curTime = getCurrentMillSecond();
        if (curTime - lastTime < _animationInterval)
        {
            usleep((_animationInterval - curTime + lastTime)*1000);
        }
    }
    /* Only work on Desktop
    *  Director::mainLoop is really one frame logic
    *  when we want to close the window, we should call Director::end();
    *  then call Director::mainLoop to do release of internal resources
    */
    if (glview->isOpenGLReady())
    {
        director->end();
        director->mainLoop();
        director = nullptr;
    }
    glview->release();
    return -1;
}
开发者ID:BeemoLin,项目名称:daca,代码行数:45,代码来源:CCApplication-linux.cpp

示例5: register_all_packages

bool AppDelegate::applicationDidFinishLaunching() {
    // initialize director
    auto director = Director::getInstance();
    auto glview = director->getOpenGLView();
    if(!glview) {
        glview = GLViewImpl::create("Starcraft");
        director->setOpenGLView(glview);
    }
    
    glview->setDesignResolutionSize(DISPLAY_WIDTH, DISPLAY_HEIGHT, ResolutionPolicy::SHOW_ALL);

    // 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();
    
    ///////////////////////////로그인 서버로 접속

    if(PLAY_ALONE) {
        glview->setDesignResolutionSize(1280, 720, ResolutionPolicy::SHOW_ALL);
        auto scene = GameWorld::createScene();
        
        // run
        director->runWithScene(scene);
    }else{
        GameClient::GetInstance().Initialize();
        
        auto networkBGLayer = NetworkLayer::create();
        networkBGLayer->retain();
        
        GameClient::GetInstance().currentScene = NO_SCENE_NOW;
        
        Scene* scene = HelloWorld::createScene();
        
        scene->addChild(networkBGLayer, 0, TAG_NETWORK_LAYER);
        Director::getInstance()->runWithScene(scene);
        
        networkBGLayer->handler->frontSendFirstConnectReq();
    }

    return true;
}
开发者ID:kimeyongchan,项目名称:MobileStar,代码行数:45,代码来源:AppDelegate.cpp

示例6: clear

ofVbo & ofVbo::operator=(const ofVbo& mom){
	if(&mom==this) return *this;
	clear();
	bUsingVerts = mom.bUsingVerts;
	bUsingTexCoords = mom.bUsingTexCoords;
	bUsingColors = mom.bUsingColors;
	bUsingNormals = mom.bUsingNormals;
	bUsingIndices = mom.bUsingIndices;

	vertSize		= mom.vertSize;
	vertStride      = mom.vertStride;
	colorStride		= mom.colorStride;
	normalStride    = mom.normalStride;
	texCoordStride  = mom.texCoordStride;

	vertUsage		= mom.vertUsage;
	colorUsage		= mom.colorUsage;
	normUsage		= mom.normUsage;
	texUsage		= mom.texUsage;

	vertId     = mom.vertId;
	retain(vertId);
	normalId   = mom.normalId;
	retain(normalId);
	colorId    = mom.colorId;
	retain(colorId);
	texCoordId = mom.texCoordId;
	retain(texCoordId);
	indexId    = mom.indexId;
	retain(indexId);
	if(supportVAOs){
		vaoID	   = mom.vaoID;
		retainVAO(vaoID);
		vaoChanged = mom.vaoChanged;
	}

	attributeIds = mom.attributeIds;
	for (map<int, GLuint>::iterator it = attributeIds.begin(); it != attributeIds.end(); it++){
		retain(it->second);
	}
	
	attributeNumCoords = mom.attributeNumCoords;
	attributeStrides = mom.attributeStrides;
	attributeSize = mom.attributeSize;
	
	totalVerts = mom.totalVerts;
	totalIndices = mom.totalIndices;

	bAllocated		= mom.bAllocated;
	bBound   = mom.bBound;
	return *this;
}
开发者ID:YeongJoo-Kim,项目名称:openFrameworks,代码行数:52,代码来源:ofVbo.cpp

示例7: l

unsigned long Channel::push(Variant *var)
{
	if (!var)
		return 0;

	Lock l(mutex);
	var->retain();

	// Keep a reference to ourselves
	// if we're non-empty and named.
	if (named && queue.empty())
		retain();

	queue.push(var);
	cond->broadcast();

	return ++sent;
}
开发者ID:Ghor,项目名称:LoveEngineCore,代码行数:18,代码来源:Channel.cpp

示例8: addChild

void HelloWorld::initScene()
{
    Size visibleSize = Director::getInstance()->getVisibleSize();
    auto vp = Camera::getDefaultViewport();
    auto node = CSLoader::createNode("res/Scene3DNoParticle.csb");
    node->setCameraMask((unsigned short)CameraFlag::USER1, true);
    addChild(node);
    _headNode = node->getChildByTag(57);
    {
        _camera = Camera::createPerspective(60,visibleSize.width/visibleSize.height * 0.5,0.1f,800);
        _camera->setCameraFlag(CameraFlag::USER1);
        //
        //        _camera->setPosition3D(Vec3(-0.01,0,0));
        _camera->setFrameBufferObject(Director::getInstance()->getDefaultFBO());
        _camera->setViewport(experimental::Viewport(vp._left,vp._bottom, vp._width/2, vp._height));
        _headNode->addChild(_camera);
        
        _camera2 = Camera::createPerspective(60,visibleSize.width/visibleSize.height * 0.5,0.1f,800);
        _camera2->setCameraFlag(CameraFlag::USER1);
        //
        //        _camera->setPosition3D(Vec3(-0.01,0,0));
        _camera2->setFrameBufferObject(Director::getInstance()->getDefaultFBO());
        _camera2->setViewport(experimental::Viewport(vp._left + vp._width/2,vp._bottom, vp._width/2, vp._height));
        _headNode->addChild(_camera2);
    }
    
    //add skybox
    {
        auto textureCube = TextureCube::create("skybox/left.jpg", "skybox/right.jpg",
                                           "skybox/top.jpg", "skybox/bottom.jpg",
                                           "skybox/front.jpg", "skybox/back.jpg");
        auto skyBox = Skybox::create();
        skyBox->retain();
        
        skyBox->setTexture(textureCube);
        addChild(skyBox);
        skyBox->setCameraMask((unsigned short)CameraFlag::USER1);
    }
    auto listener = EventListenerTouchOneByOne::create();
    listener->onTouchBegan = CC_CALLBACK_2(HelloWorld::onTouchBegan, this);
    listener->onTouchEnded = CC_CALLBACK_2(HelloWorld::onTouchEnded, this);
    _eventDispatcher->addEventListenerWithSceneGraphPriority(listener, this);
    CCASSERT(_headNode, "");
}
开发者ID:dabingnn,项目名称:cocosVR,代码行数:44,代码来源:HelloWorldScene.cpp

示例9: switch

/**
 * @brief Reads a Boole from `reader`.
 * @param reader The JSONReader.
 * @return The Boole.
 */
static _Bool *readBoole(JSONReader *reader) {

	Boole *boolean = NULL;

	switch (*reader->b) {
		case 't':
			consumeBytes(reader, "true");
			boolean = $$(Boole, True);
			break;
		case 'f':
			consumeBytes(reader, "false");
			boolean = $$(Boole, False);
			break;
		default:
			assert(false);
	}

	return retain(boolean);
}
开发者ID:jdolan,项目名称:Objectively,代码行数:24,代码来源:JSONSerialization.c

示例10: super

/**
 * @fn Array *Array::initWithArray(Array *self, const Array *array)
 *
 * @memberof Array
 */
static Array *initWithArray(Array *self, const Array *array) {

	self = (Array *) super(Object, self, init);
	if (self) {

		self->count = array->count;
		if (self->count) {

			self->elements = calloc(self->count, sizeof(ident));
			assert(self->elements);

			for (size_t i = 0; i < self->count; i++) {
				self->elements[i] = retain(array->elements[i]);
			}
		}
	}

	return self;
}
开发者ID:ab5tract,项目名称:Objectively,代码行数:24,代码来源:Array.c

示例11: setTitleImage

void CAAlertView::showMessage(std::string title, std::string alertMsg, std::vector<std::string>& vBtnText)
{
	setTitleImage(CAImage::create("source_material/alert_title.png"));
	setContentBackGroundImage(CAImage::create("source_material/alert_content.png"));
	setTitle(title.c_str(), CAColor_white);
	setAlertMessage(alertMsg.c_str());
	
	initAllButton(vBtnText);
	setAllBtnBackGroundImage(CAControlStateNormal, CAImage::create("source_material/alert_btn.png"));
	setAllBtnBackGroundImage(CAControlStateHighlighted, CAImage::create("source_material/alert_btn_sel.png"));
	setAllBtnTextColor();

	calcuCtrlsSize();

	CAApplication* pApplication = CAApplication::getApplication();
	CCAssert(pApplication != NULL, "");
	pApplication->getRootWindow()->insertSubview(this, CAWindowZoderCenter);
	retain();
}
开发者ID:13609594236,项目名称:CrossApp,代码行数:19,代码来源:CAAlertView.cpp

示例12: retain

//----------------------------------------
void ofLight::enable() {
	if(glIndex==-1){
		// search for the first free block
		for(int i=0; i<OF_MAX_LIGHTS; i++) {
			if(getActiveLights()[i] == false) {
				glIndex = i;
				retain(glIndex);
				enable();
				return;
			}
		}
	}
	if(glIndex!=-1) {
		ofEnableLighting();
		glEnable(GL_LIGHT0 + glIndex);
	}else{
		ofLog(OF_LOG_ERROR, "Trying to create too many lights: " + ofToString(glIndex));
	}
}
开发者ID:henryzhang,项目名称:openFrameworks,代码行数:20,代码来源:ofLight.cpp

示例13: setPhysicsBody

Goal::Goal():clampPos(nullptr){
	Sprite::init();
	_isDead = false;

	PhysicsBody* pb = PhysicsBody::createCircle(25);
	pb->setMass(1000.0f);
	pb->setDynamic(true);
	pb->setContactTestBitmask(true);
	setPhysicsBody(pb);
	setName("Goal");
	
	/*-------
	 当たり判定
	 --------*/
	auto c = CollisionDelegate<Goal>::create(this, &Goal::onContact);
	CollisionFuncManager::getInstance()->addFunc(this->getName(), c);

	retain();
}
开发者ID:setu15,项目名称:FishLight,代码行数:19,代码来源:Goal.cpp

示例14: IOSimpleLockInit

bool IOFWSyncer::init(bool twoRetains)
{
    if (!OSObject::init())
        return false;

    if (!(guardLock = IOSimpleLockAlloc()) )
        return false;
	
    IOSimpleLockInit(guardLock);

    if(twoRetains)
	retain();

    fResult = kIOReturnSuccess;

    reinit();

    return true;
}
开发者ID:alfintatorkace,项目名称:osx-10.9-opensource,代码行数:19,代码来源:IOFWSyncer.cpp

示例15: IMG_LoadTexture

ARC<TextureProtocol>
SDLRenderer::textureFromImage(const std::string& image) {
    
    if(_textureCache.find(image) != _textureCache.end()) {
        return alloc<SDLTexture>(_textureCache[image]);
    }
    
    // TODO: Replace with cache call for SDL_Texture
    SDL_Texture* _sdl = IMG_LoadTexture(_renderer, image.c_str());
    if(_sdl == nullptr) {
        throw std::runtime_error(std::string("Error creating texture: ")+IMG_GetError());
    }
    SDL_SetTextureBlendMode(_sdl, SDL_BLENDMODE_BLEND);
    
    auto texture = alloc<SDLTextureRef>(_sdl);
    _textureCache[image] = texture;
    texture->retain();
    
    return alloc<SDLTexture>(texture);
}
开发者ID:cesarparent,项目名称:Meteor,代码行数:20,代码来源:SDLRenderer.cpp


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