Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to create a VertexArray with a repeated texture  (Read 1348 times)

0 Members and 1 Guest are viewing this topic.

Daniel Schreiber Mendes

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
How to create a VertexArray with a repeated texture
« 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

Hapax

  • Hero Member
  • *****
  • Posts: 3379
  • My number of posts is shown in hexadecimal.
    • View Profile
    • Links
Re: How to create a VertexArray with a repeated texture
« Reply #1 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.
Selba Ward -SFML drawables
Cheese Map -Drawable Layered Tile Map
Kairos -Timing Library
Grambol
 *Hapaxia Links*