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


C++ RenderTexture类代码示例

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


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

示例1: spriteWithColor

Sprite* HelloWorld::spriteWithColor(Color4F bgColor, float textureWidth, float textureHeight)
{
	// 1: Create new RenderTexture
	RenderTexture *rt = RenderTexture::create(textureWidth, textureHeight);

	// 2: Call RenderTexture:begin
	rt->beginWithClear(bgColor.r, bgColor.g, bgColor.b, bgColor.a);

	// 3: Draw into the texture

	//// gradient
	_gradient_command.init(rt->getGlobalZOrder());
	_gradient_command.func = std::bind(&HelloWorld::onDrawGradient, this, textureWidth, textureHeight);
	auto renderer = Director::getInstance()->getRenderer();
	renderer->addCommand(&_gradient_command);

	//// noise cloud
	BlendFunc blendFunc;
	blendFunc.src = GL_DST_COLOR;
	blendFunc.dst = GL_ZERO;

	Sprite *noise = Sprite::create("Noise.png");
	noise->setBlendFunc(blendFunc);
	noise->setPosition(Vec2(textureWidth / 2, textureHeight / 2));
	noise->visit();

	// 4: Call CCRenderTexture:end
	rt->end();

	// 5: Create a new Sprite from the texture
	return Sprite::createWithTexture(rt->getSprite()->getTexture());
}
开发者ID:konopka,项目名称:tinywingstutorial,代码行数:32,代码来源:HelloWorldScene.cpp

示例2: maskedSpriteWithSprite

Sprite* Utils::maskedSpriteWithSprite(Sprite* textureSprite, Sprite* maskSprite)
{
    // 1
    RenderTexture * rt = RenderTexture::create( maskSprite->getContentSize().width,
                                               maskSprite->getContentSize().height );
    
    // 2
    maskSprite->setPosition(maskSprite->getContentSize().width/2,
                            maskSprite->getContentSize().height/2);
    textureSprite->setPosition(textureSprite->getContentSize().width/2,
                               textureSprite->getContentSize().height/2);
    
    // 3
    maskSprite->setBlendFunc( BlendFunc{GL_ONE, GL_ZERO} );
    textureSprite->setBlendFunc( BlendFunc{GL_DST_ALPHA, GL_ZERO} );
    
    // 4
    rt->begin();
    maskSprite->visit();
    textureSprite->visit();
    rt->end();
    
    // 5
    Sprite *retval = Sprite::createWithTexture(rt->getSprite()->getTexture());
    retval->setFlippedY(true);
    return retval;
}
开发者ID:danielzzu,项目名称:TalesRomace,代码行数:27,代码来源:Utils.cpp

示例3: if

void RenderTextureImage::sceneChangeEvent(const QSceneChangePtr &e)
{
    QScenePropertyChangePtr propertyChange = qSharedPointerCast<QScenePropertyChange>(e);

    if (e->type() == NodeUpdated) {
        if (propertyChange->propertyName() == QByteArrayLiteral("layer")) {
            m_layer = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("mipmapLevel")) {
            m_mipmapLevel = propertyChange->value().toInt();
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("cubeMapFace")) {
            m_face = static_cast<QAbstractTextureProvider::CubeMapFace>(propertyChange->value().toInt());
            m_dirty = true;
        } else if (propertyChange->propertyName() == QByteArrayLiteral("dataFunctor")) {
            m_functor = propertyChange->value().value<QTextureDataFunctorPtr>();
            m_dirty = true;
        }
    }
    if (m_dirty) {// Notify the RenderTexture that we were updated and request it to schedule an update job
        RenderTexture *txt = m_textureManager->data(m_textureProvider);
        if (txt != Q_NULLPTR)
            txt->addToPendingTextureJobs();
    }
}
开发者ID:James-intern,项目名称:Qt,代码行数:25,代码来源:rendertextureimage.cpp

示例4: SaveItemTemplateTem

RenderTexture* ShowStar::visitNode(DiySaveType type, Node *node)
{
	int index = (int)type;
	SaveItemTemplate object = SaveItemTemplateTem(WJUtils::stringAddInt("Save_", index, 3).c_str());

	//定义一个自定义大小的渲染纹理
	float scale = object.scale;
	const Size &size = node->getContentSize() * scale;
	RenderTexture *renderTexture = RenderTexture::create(size.width, size.height);
	renderTexture->setAnchorPoint(Vec2(0.5f, 0.5f));
	renderTexture->ignoreAnchorPointForPosition(false);

	Vec2 ancPoint = node->getAnchorPoint();
	float scaleOld = node->getScale();
	Vec2 point = node->getPosition();

	// 按照高度的比例缩放节点到当前的尺寸
	node->setAnchorPoint(Vec2(0.5f, 0.5f));
	node->ignoreAnchorPointForPosition(false);
	node->setScale(scale);

	renderTexture->beginWithClear(0, 0, 0, 0);
	node->setPosition(Vec2(size.width / 2, size.height / 2));
	node->visit();
	renderTexture->end();
	Director::getInstance()->getRenderer()->render();

	node->setAnchorPoint(ancPoint);
	node->setPosition(point);
	node->setScale(scaleOld);

	return renderTexture;
}
开发者ID:dalechngame,项目名称:mygame,代码行数:33,代码来源:ShowStar.cpp

示例5: RenderTexture

   RESULT Device::Create(USINT frameWidth,
                                      USINT frameHeight,
                                      USINT framebufferNum,
                                      DeviceAdapter* deviceAdapter)
    {
        if(frameWidth<=0) return RESULT::INVALIDARG;
        if(frameHeight<=0) return RESULT::INVALIDARG;
        if(framebufferNum<=0) return RESULT::INVALIDARG;
        if(deviceAdapter==nullptr) return RESULT::INVALIDARG;

        RESULT re;
        for(INT i=0; i<framebufferNum; i++)
        {
            RenderTexture* rt = new RenderTexture();
            if(nullptr == rt) return RESULT::OUTMEMORY;

            re = rt->Create(frameWidth, frameHeight);
            if(RESULT::SUCC != re)
            {
                  RemoveFrameBuffers();
                  return re;
            }

            m_framebuffers.Add_back(rt);
        }

        m_front = m_framebuffers.Begin();
        m_pDeviceAdapter = deviceAdapter;

        return RESULT::SUCC;
    }
开发者ID:343234064,项目名称:Software-Render-Engine,代码行数:31,代码来源:SRE_Device.cpp

示例6: swapTextures

void FrameBufferObject::swapTextures()
{
	for(int i=0 ; i<m_textures.size() ; i++) {
		RenderTexture* tex = m_textures[i].tex;
		tex->swap();
	}
}
开发者ID:smatcher,项目名称:S5old,代码行数:7,代码来源:framebufferobject_noglew.cpp

示例7: new

RenderTexture* RenderTexture::create(int width, int height, GLenum depthType, GLenum wrapMode, GLenum filteringMode, bool isAutoRelease)
{
	RenderTexture* ptr = new(true) RenderTexture(width, height, depthType, wrapMode, filteringMode);
	if (isAutoRelease)
	{
		ptr->autorelease();
	}
	return ptr;
}
开发者ID:SylerWang,项目名称:FunFashion,代码行数:9,代码来源:RenderTexture.cpp

示例8: Point

void ClippingToRenderTextureTest::reproduceBug()
{
    auto director = Director::getInstance();
    Size visibleSize = director->getVisibleSize();
    Point origin = director->getVisibleOrigin();


    // add "HelloWorld" splash screen"
    auto sprite = Sprite::create("Images/grossini.png");

    // position the sprite on the center of the screen
    sprite->setPosition(Point(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));

    // add the sprite as a child to this layer
    this->addChild(sprite, 0);


    // container node that will contain the clippingNode
    auto container = Node::create();
    container->retain();

    auto stencil = DrawNode::create();
    Point triangle[3];
    triangle[0] = Point(-50, -50);
    triangle[1] = Point(50, -50);
    triangle[2] = Point(0, 50);
    Color4F green(0, 1, 0, 1);
    stencil->drawPolygon(triangle, 3, green, 0, green);

    auto clipper = ClippingNode::create();
    clipper->setAnchorPoint(Point(0.5, 0.5));
    clipper->setPosition( Point(visibleSize.width/2, visibleSize.height/2) );
    clipper->setStencil(stencil);
    clipper->setInverted(true);
    container->addChild(clipper, 1);


    auto img = DrawNode::create();
    triangle[0] = Point(-200, -200);
    triangle[1] = Point(200, -200);
    triangle[2] = Point(0, 200);
    Color4F red(1, 0, 0, 1);
    img->drawPolygon(triangle, 3, red, 0, red);
    clipper->addChild(img);

    // container rendered on Texture the size of the screen and because Clipping node use stencil buffer so we need to
    // create RenderTexture with depthStencil format parameter
    RenderTexture* rt = RenderTexture::create(visibleSize.width, visibleSize.height, Texture2D::PixelFormat::RGBA8888, GL_DEPTH24_STENCIL8);
    rt->setPosition(visibleSize.width/2, visibleSize.height/2);
    this->addChild(rt);

    rt->begin();
    container->visit();
    rt->end();
}
开发者ID:anilgulgor,项目名称:myGame,代码行数:55,代码来源:ClippingNodeTest.cpp

示例9:

MapRender::~MapRender()
{
	for (size_t i = 0; i < MAX_TEX_X; i++)
	{
		for (size_t j = 0; j < MAX_TEX_Y; j++)
		{
			RenderTexture* tex = _renderTexture[i][j];
			if (tex) tex->release();
		}
	}
}
开发者ID:musenshen,项目名称:SandBox,代码行数:11,代码来源:MapRender.cpp

示例10: init

	virtual bool init() override
	{
		Size size = Director::getInstance()->getVisibleSize();
		m_renderTexture = RenderTexture::create(size.width, size.height);
		if (!m_renderTexture)
			return false;
		m_renderTexture->retain();
		m_renderTexture->setKeepMatrix(true);
		m_renderTexture->setAnchorPoint(Vec2::ZERO);
		m_renderTexture->getSprite()->setAnchorPoint(Vec2::ZERO);
		return Node::init();
	}
开发者ID:Bruke,项目名称:lwf,代码行数:12,代码来源:lwf_cocos2dx_factory.cpp

示例11: RenderTexture

RenderTexture * RenderTexture::create(int w, int h)
{
    RenderTexture *ret = new RenderTexture();

    if(ret && ret->initWithWidthAndHeight(w, h, Texture2D::PixelFormat::RGBA8888, 0))
    {
        ret->autorelease();
        return ret;
    }
    CC_SAFE_DELETE(ret);
    return nullptr;
}
开发者ID:253627764,项目名称:WagonWar,代码行数:12,代码来源:CCRenderTexture.cpp

示例12: mapRun

void GameLayer::update(float a)
{
	positon = hero->getPosition();
	if (positon.x > mapSize.width - winSize.width / 2 - 60)
	{
		hero->setState(eNormalRight);
		isRightKeyDown = false;
	}
	mapRun(positon);
	freshScore(positon);
	if (isDead)
	{
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopBackgroundMusic();
		CocosDenshion::SimpleAudioEngine::sharedEngine()->stopAllEffects();

		RenderTexture* renderTexture = RenderTexture::create(WINSIZE.width, WINSIZE.height);
		renderTexture->retain();
		Scene *s = Director::getInstance()->getRunningScene();
		renderTexture->begin();
		s->visit();
		renderTexture->end();
		Scene* scene = OverDialog::createScene(renderTexture, true);
		Director::getInstance()->pushScene(scene);
	}

	
	if (isRightKeyDown)
	{
		positon.x += hero->runSpeed;
	}

	if (isLeftKeyDown)
	{
		positon.x -= hero->runSpeed;
	}

	hero->upSpeed -= hero->gravity - hero->groundSurport;
	positon.y += hero->upSpeed;

	if (positon.y < 5)
	{
		isDead = true;
	}
	if (positon.y > 450)
		positon.y = 450;
	if (positon.y > mapSize.height - 48)
	{
		positon.y = mapSize.height - 48;
	}
	hero->setPosition(positon);
	collisionV();
	collisionH();
}
开发者ID:QingShiLuoGu,项目名称:ttpk,代码行数:53,代码来源:GameLayer.cpp

示例13: NEX_NEW

RenderTargetPtr MultiRenderTarget::CreateTexture(const TargetParam& tp) {
	if (tp.useAsTexture) {
		RenderTexture* rt = NEX_NEW(RenderTexture());
		rt->Create(TextureBase::TEXTURE_2D, tp.format, dimensions.width,
				dimensions.height, 1);
		return Assign(rt);
	} else {
		RenderBuffer* rt = NEX_NEW(RenderBuffer());
		rt->Create(tp.format, dimensions.width, dimensions.height);
		return Assign(rt);
	}
}
开发者ID:obhi-d,项目名称:nextar,代码行数:12,代码来源:MultiRenderTarget.cpp

示例14: new

RenderTexture * RenderTexture::create(int w, int h, Texture2D::PixelFormat eFormat)
{
    RenderTexture *ret = new (std::nothrow) RenderTexture();

    if(ret && ret->initWithWidthAndHeight(w, h, eFormat))
    {
        ret->autorelease();
        return ret;
    }
    CC_SAFE_DELETE(ret);
    return nullptr;
}
开发者ID:osmely,项目名称:CocosJuice,代码行数:12,代码来源:CCRenderTexture.cpp

示例15: RenderTexture

RenderTexture * RenderTexture::create(int w, int h)
{
    RenderTexture *pRet = new RenderTexture();

    if(pRet && pRet->initWithWidthAndHeight(w, h, Texture2D::PixelFormat::RGBA8888, 0))
    {
        pRet->autorelease();
        return pRet;
    }
    CC_SAFE_DELETE(pRet);
    return NULL;
}
开发者ID:0x0c,项目名称:cocos2d-x,代码行数:12,代码来源:CCRenderTexture.cpp


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