本文整理汇总了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());
}
示例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;
}
示例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();
}
}
示例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;
}
示例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;
}
示例6: swapTextures
void FrameBufferObject::swapTextures()
{
for(int i=0 ; i<m_textures.size() ; i++) {
RenderTexture* tex = m_textures[i].tex;
tex->swap();
}
}
示例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;
}
示例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();
}
示例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();
}
}
}
示例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();
}
示例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;
}
示例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();
}
示例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);
}
}
示例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;
}
示例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;
}