i have the following code to render a texture with RenderTexture:
auto visibleSize = Director::getInstance()->getVisibleSize();
Vec2 origin = Director::getInstance()->getVisibleOrigin();
auto textureSize = Size(64, 64);
auto textureMiddle = Vec2(textureSize.width / 2, textureSize.height / 2);
auto rt = RenderTexture::create(textureSize.width, textureSize.height);
rt->beginWithClear(0, 0, 1, 1);
auto node = DrawNode::create();
node->drawDot(textureMiddle, textureSize.height / 2, Color4F::RED);
node->visit();
rt->end();
auto sprite = Sprite::createWithTexture(rt->getSprite()->getTexture());
sprite->getTexture()->setTexParameters({GL_LINEAR, GL_LINEAR, GL_REPEAT, GL_REPEAT});
sprite->setTextureRect(Rect(0, 0, visibleSize.width, textureSize.height));
this->addChild(sprite);
sprite->setPosition(Vec2(visibleSize.width/2 + origin.x, visibleSize.height/2 + origin.y));
This is the result:
Can someone explain me why the texture is not repeated like normally. The result which I expect were like the red dots positioned side by side without any gap between them. Like the background of the RenderedTexture (blue).
Can someone give me an advice how can I achieve this.
Thank you