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

Author Topic: Tilemap: vertex array or prerendered texture?  (Read 2850 times)

0 Members and 1 Guest are viewing this topic.

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
Tilemap: vertex array or prerendered texture?
« on: March 03, 2012, 03:12:46 pm »
With SFML 2.0 there are new possibilities drawing repeated backgrounds and tilemaps. I've already read something about using vertex arrays, but would it be faster than using prerendered textures?

E.g., a static tilemap could be prerendered on a render target and then drawn on screen as it would be a normal sprite. Of course, it uses a little bit more of memory, but wouldn't this method be faster?
Please note that my previous display name was "Shy Guy".

Chris12

  • Newbie
  • *
  • Posts: 20
    • View Profile
Tilemap: vertex array or prerendered texture?
« Reply #1 on: March 03, 2012, 05:43:55 pm »
Yes it would be faster. But you will still have to split the complete, huge, prerendered texture, into smaller textures.
Since the maximum "renderTexture" is dependant on your GPU,
i think 1024 would be ok for most gpus, but you will have to check it yourself.


Whatever, as I said you will still have to split it.
I will implement some kind of grouping into my tilemap so a 20x20 part of my levels tilemap will be rendered into one rendertexture.

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
Tilemap: vertex array or prerendered texture?
« Reply #2 on: March 03, 2012, 06:00:42 pm »
Quote from: "Chris12"
Yes it would be faster. But you will still have to split the complete, huge, prerendered texture, into smaller textures.
Since the maximum "renderTexture" is dependant on your GPU,
i think 1024 would be ok for most gpus, but you will have to check it yourself.


Whatever, as I said you will still have to split it.
I will implement some kind of grouping into my tilemap so a 20x20 part of my levels tilemap will be rendered into one rendertexture.


Yeah, thought of it, too.
But wouldn't it be waste as well when vertex arraying a such large map and drawing it?
Please note that my previous display name was "Shy Guy".

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Tilemap: vertex array or prerendered texture?
« Reply #3 on: March 03, 2012, 06:05:34 pm »
Use vertex arrays. You shouldn't get performance issues, and your code will be much cleaner.
Laurent Gomila - SFML developer

Tenry

  • Full Member
  • ***
  • Posts: 120
  • Experienced Programmer
    • View Profile
    • Simon-Burchert.com
Tilemap: vertex array or prerendered texture?
« Reply #4 on: March 03, 2012, 07:13:43 pm »
Quote from: "Laurent"
Use vertex arrays. You shouldn't get performance issues, and your code will be much cleaner.

Okay.

Quote from: "Shy Guy"
... drawing repeated backgrounds ...

I noticed a method in the texture class: SetRepeated.

That way, I don't need to define a lot of quads for each time the background is drawn, I could also use a single quad and the making tex coords like tex_width*2, tex_height*2, right?
Please note that my previous display name was "Shy Guy".

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Tilemap: vertex array or prerendered texture?
« Reply #5 on: March 03, 2012, 08:50:13 pm »
Quote
That way, I don't need to define a lot of quads for each time the background is drawn, I could also use a single quad and the making tex coords like tex_width*2, tex_height*2, right?

Yep.
Laurent Gomila - SFML developer