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

Author Topic: Drawing a non-homogeneous terrain  (Read 510 times)

0 Members and 1 Guest are viewing this topic.

darkonaito_

  • Newbie
  • *
  • Posts: 5
    • View Profile
Drawing a non-homogeneous terrain
« on: March 21, 2023, 10:09:59 pm »
How would you go about drawing a terrain made up of different materials, hence different texture? Have a sprite for each tile or have a single sprite and changing both it's position and it's texture multiple times?

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10817
    • View Profile
    • development blog
    • Email
Re: Drawing a non-homogeneous terrain
« Reply #1 on: March 22, 2023, 05:24:23 pm »
Depends a bit on how non-homogeneous it should be.

In simple terms, you can draw a tile map, where you have one texture with different materials on it, then you insert the map structure as vertices into a VertexArray and draw that with the different matching texture coordinates.

The tutorial has an simple example for that: https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#example-tile-map
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything