SFML community forums

Help => Graphics => Topic started by: Daniel Schreiber Mendes on December 13, 2019, 11:16:12 pm

Title: How to create a VertexArray with a repeated texture
Post by: Daniel Schreiber Mendes on December 13, 2019, 11:16:12 pm
Hey,
how is the sf::Texture::m_isRepeated feature actually implemented? I looked at the source code but I don't know openGl yet and don't understand if the SFML library or openGl is doing this. Since I am using only vertexArrays for drawing and wanted to still use this feature without having to use a sf::Sprite or a sf::Drawable. I know how I would implement this feature with a vertexArray but I am wondering if there is any performance impact in case this is normally done by openGl.

Best regards,

Daniel Schreiber Mendes
Title: Re: How to create a VertexArray with a repeated texture
Post by: Hapax on December 13, 2019, 11:48:45 pm
The texture is repeated (when repeat is active) infinitely in all directions and the co-ordinates for the texture can be the original or any of those repeats. They don't all have to be in the same area either so they can cross a repeat.

Basically, to repeat an entire texture 3 times on a square, start from (0, 0) and cover the area up to (the opposite corner should be at) the texture size multiplied by 3.
For any vertex in an array, to repeat 3 times within any shape, multiply the texture co-ordinate (texCoords) by 3. Similar for any number of repeats and each dimension can be repeated differently.