How do I repeat a texture without stretching it across the size of the vertex array?
I've tried this: but it seems to stretch the checkers.
Relevant Code: (rect is area I would like to repeat texture in. the texture is 64x64 px)
sf::Texture checkers;
checkers.loadFromImage(*createChecker());
checkers.setRepeated(true);
void Checkers::setTextureRect(sf::IntRect rect)
{
// size //
m_vertices[0].position = sf::Vector2f(0,0);
m_vertices[1].position = sf::Vector2f(rect.width,0);
m_vertices[2].position = sf::Vector2f(rect.width, rect.height);
m_vertices[3].position = sf::Vector2f(0,rect.height);
m_vertices[0].texCoords = sf::Vector2f(0,0);
m_vertices[1].texCoords = sf::Vector2f(64,0);
m_vertices[2].texCoords = sf::Vector2f(64, 64);
m_vertices[3].texCoords = sf::Vector2f(0,64);
}
void Checkers::draw(sf::RenderTarget& target, sf::RenderStates states) const
{
states.transform *= getTransform();
states.texture = checkers;
target.draw(m_vertices, states);
}