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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - nitrix

Pages: [1]
1
General / SFML 2 inside out - Performances & optimisations
« on: December 05, 2011, 08:54:02 am »
Hi everyone,

my team and I just decided SFML would be the way to go for our future projects. I'm a programmer-analyst so I'm in charge to make all the strategic decisions about our work-in-progress engine.

I'd like to make sure I know SFML inside-out, along with the good practices and common pitfalls. Also any tips from the top of your head / experience is very welcomed.

I switched to SFML knowing its OpenGL core has a lot more to offer than SDL, yet with an extreme simplicity.

Note: The game we're working on is using a 2D, top-view, tile based engine. Tiles are 32x32 pixels large and the character is a playing entity of the game (meaning most likely the Camera will be centered on him and the world shall move around). Oh and the world is loaded in chunks.

Here are my starting questions:

1 - I have an SDL background where using dirty rectangles is almost necessary; from what I read on the forums, clearing the entire screen and drawing all the (only camera visible) tile sprites, then calling display() is the natural way of doing things.

  • Is this a concern for the GPU to redraw the entire screen every frames?
  • If not, it would allow me to have a camera centered on the player and easily move the world around when he moves + without any tearings?
  • Consider the fact I'm doing a multiplayer game, I might have to update a SINGLE tile once in a while, but rarely redraw the entire screen (unless there's a map change, or -like previously said- the camera is centered on the player).


2 - I also heard about RenderTexture, what's the gain?
  • If I understood it right, I think the rendering loop will display the RenderTexture easily, and my job is to draw/blit the sprite on that texture to make it efficient?


3 - When it comes to drawing the tiles (they are layered btw), it's better to group the tiles with the same textures together as there's less need to switch from one texture to another from the graphic driver.
  • True or not? When using a RenderTexture, this should get rid of this problem, right?


So yeah, sorry for bothering you guys. I think I just drank too much of the optimisation kool-aid, but honestly, I'm not a fan of wasting CPU/GPU cycles EVEN if today's computers are generally all very efficient anyway.

Big thanks in advance to anyone that can point me the best way to go from there if I'm planning to create an engine from scratch. I'm not a slacker, if there's an optimal way, it'll be mine.

I also wish Laurent can see this. If you do, thanks for your time and feel free to answer in french or english, whatever is your primary language :]

Alex.

Pages: [1]
anything