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

Author Topic: Tiled Map  (Read 4052 times)

0 Members and 1 Guest are viewing this topic.

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Tiled Map
« on: February 17, 2011, 11:10:54 pm »
Hi, i wanted to render a Tiled map, each tile 12*12px.
My first way was to draw every single tile itself. But i think this may cause too many drawcalls,
any better ways?

Grimshaw

  • Hero Member
  • *****
  • Posts: 631
  • Nephilim SDK
    • View Profile
Tiled Map
« Reply #1 on: February 17, 2011, 11:25:53 pm »
Group a few tiles into a single image. Then cull the images off-screen, and you draw all the screen with very few tiles : )

Gibgezr

  • Newbie
  • *
  • Posts: 33
    • View Profile
Tiled Map
« Reply #2 on: February 18, 2011, 02:35:31 am »
Might want to follow the thread at:
http://www.sfml-dev.org/forum/viewtopic.php?t=3173

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
Tiled Map
« Reply #3 on: February 22, 2011, 02:59:37 am »
How does  sf::RenderImage work exactly?
Or to keep things simple... if i do something like

Code: [Select]

for( y = 0; y<height; y++)
{
    for(x = 0; x <width; x++)
    {
         renderImage.Draw( tile[y][x].sprite);
     }
}

... render to window ...


will this be more effective than rendering directly to screen?[/code]

Lupinius

  • Jr. Member
  • **
  • Posts: 85
    • View Profile
Tiled Map
« Reply #4 on: February 22, 2011, 03:02:14 pm »
If you render all your tiles to your RenderImage once and then use that Image every frame, yes, it will be more efficent than rendering every tile every frame. If you render all your tiles to the RenderImage every frame though, it will not be any faster.