I'm trying to tile an image across an area, but instead of tiling, the image is stretching to fill the area.
The tiling function is as follows:
void tileImage(sf::RenderTarget& target, RECT area, sf::Texture& img, RECT srcRect, sf::BlendMode mode){
img.setRepeated(true);
sf::Vector2u imgSz = img.getSize();
area.left -= area.left % imgSz.x;
area.top -= area.top % imgSz.y;
sf::RectangleShape tessel(sf::Vector2f(area.width(),area.height()));
tessel.setTexture(&img);
tessel.setTextureRect(srcRect);
tessel.setPosition(area.left, area.top);
sf::RenderStates renderMode(mode);
setActiveRenderTarget(target);
glEnable(GL_SCISSOR_TEST);
glScissor(area.left, area.top, area.width(), area.height());
target.draw(tessel, renderMode);
glDisable(GL_SCISSOR_TEST);
}
The texture that's passed in contains several images of which I only want to tile one, that contained in the rectangle "srcRect". The rectangle "area" is the area in which the image should be tiled. The setActiveRenderTarget call just calls target.setActive() if target is a RenderWindow, because for some reason RenderTexture doesn't have a setActive function (which makes me wonder if this'll work on a RenderTexture, but I'll get to that later).
I'm hoping I'm just missing something obvious here. I know roughly what needs to happen (the texture should be drawn with normalized texture coordinates > 1), but I'm not sure what I've missed in trying to get SFML to do this. Will I need to copy the portion I want to repeat into a new texture?