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.


Messages - Mjonir

Pages: 1 [2] 3 4
16
Graphics / Better way to draw same sprite multiple times
« on: March 14, 2012, 08:04:04 pm »
No, you do not need to. You can have multiple sf::Sprites constructed from the same sf::Image, and draw all of them.

Sprites are very light, don't worry about performance when using them :)


However, if it's actually simpler for you to move the sprite you can draw it multiple times, but I don't think that's what you want to do in your case.

17
Quote from: "nietaki"
It isn't, at least not explicitly - I read it once again and I still wouldn't be sure if not for your answer.


I agree, I had checked the doc before answering and wasn't 100% sure about the behavior of music opening.

I also think the special status of sf::Music::openFrom* deserves a small mention in the doc of these methods.

18
Quote from: "nietaki"
But I still can free the memory (data) after I call Music::openFromMemory(const void * data, std::size_t sizeInBytes ), right?


Hmm, sorry I don't know about that, I never load from memory.

Either wait for Laurent (he's so fast that he'll probably answer before you read this line so you won't wait for long :P), or try it out yourself by loading from memory and then overwriting the data?

19
I'm pretty sure it's due to the fact that musics are opened and loaded chunk by chunk, not fully loaded when the function is used like for other resources :)

20
Graphics / Better FPS drawing 10.000 sprite
« on: March 12, 2012, 09:21:15 pm »
Just a word on SFML performance in drawing a lot of sprites:

I have a benchmark for my engines that creates 500 animated objects, each with an independent and quite complex (voluntarily unoptimized! It could easily be!) move sequence that is computed in Lua. I get about 35 FPS.  A simpler move sequence gives me around 110 FPS.

I was curious so I programmed a little profiling lib today and checked where the horsepower was going:

- 95% of the time is spent calculating the next frame.
- Which means only 5% of the frame is spent drawing.
- Out of the 95%, about 1 or 2% is checking keyboard/mouse/window events
- I'd say 2% for the engine itself (collision detection, etc.)
- 90% spent computing the move sequences (it's sequential, unoptimized, very complex and goes through a Lua interpreter, but still that's the kind of complexity you could easily get for a "whole city" above :)).

Even better, I have an option on my engine that separates the update from display, and thus on a dual core display doesn't even matter at all.

That's to say: Don't worry too much about drawing lots of sprites, that's maybe not your bottleneck thanks to SFML.

21
General discussions / New naming convention
« on: March 12, 2012, 08:43:29 pm »
Quote from: "Laurent"
And why isn't it in -Wall (which I assumed gathered all the possible warnings)?


Unfortunately that's not how it works. "-Wall" only activates an actually vey specific set of warnings: http://gcc.gnu.org/onlinedocs/gcc/Warning-Options.html

As you can see there is also "-Wextra" which activates a bunch of others, and a few "extra extra" options that are in neither :/


Lots of these warnings could be useful, but I get SO many warnings from the libraries I use that it's simply not possible to keep them on. If anyone knows a solution to only display warnings for you own project, I'd be grateful! :P

22
General discussions / Do you use C++11?
« on: March 11, 2012, 10:54:22 pm »
Thanks everyone for the useful links about C++11. I read a lot about it today, and I'm already using it. I jumped on the unordered_map/set, the ranged based for and the "auto" keyword :P

23
General discussions / New naming convention
« on: March 11, 2012, 08:54:44 pm »
Quote from: "Laurent"
It's not a class, it's a function.


Ooh, alright, I skimmed over the code and did not notice that. Well the new convention makes that fact much more clear, it's a really good thing :)

24
General discussions / New naming convention
« on: March 11, 2012, 08:42:04 pm »
I've just compiled it on Windows and changed my project accordingly, it works perfectly.

I was just surprised by the change "sf::Seconds" -> "sf::seconds", it doesn't seem to match the usual convention for all SFML classes?

25
Graphics / Better FPS drawing 10.000 sprite
« on: March 11, 2012, 03:26:16 pm »
Quote from: "TheEnigmist"
Updating the city is faster and doesn't affect game's FPS?


It depends on what you simulate. And even if your display is very fast, it might still cause problems if you can only simulate once out of ten display frames for example.

It really depends on what you're doing though but for my own project (which is roughly about displaying between 500 and 1000 objects on screen, each having its own complex logic), I'm pretty sure the bottleneck is in the simulation, not drawing.

Quote from: "Groogy"
Though thumb of rule, never trust anything until you've tested it yourself. Always benchmark and profile everything when you are optimizing.


On that subject, which tools do you use for profiling?

26
Graphics / Better FPS drawing 10.000 sprite
« on: March 11, 2012, 01:55:06 pm »
Yep. Also depending on what you want to do, you don't have to simulate de whole city either. If you can, separate it block by block and just simulate/draw the visible blocks and possibly its surroundings.

27
Graphics / How to center sf::Text (SFML2)
« on: March 10, 2012, 08:08:06 pm »
I think Zinlib gave you the solution, either GetGlobalBounds() or GetLocalBounds() depending on what you want to do :)

28
Graphics / Better FPS drawing 10.000 sprite
« on: March 10, 2012, 08:06:16 pm »
Quote from: "TheEnigmist"
I was thinking to make a city in 2d! So houses, npcs, objects, enemies, all sprite to write and update.
Maybe for enemies and npcs i can use the same texture! House maybe will be different! But this is still an idea of what i want to make. Maybe i will open a new thread when i'm ready to start this project!


But you won't draw the whole city at once on the scree, will you? :o

29
General discussions / Do you use C++11?
« on: March 10, 2012, 08:04:34 pm »
I don't use them, but it's more that I don't know enough about them. I don't think I'll use them in the near future, but I'm not uninterested either. Would anyone have a link to a nice tutorial introducing them? :)

30
General discussions / What project do i create?
« on: March 07, 2012, 02:15:53 am »
I suggest you start from scratch and follow http://www.sfml-dev.org/tutorials/1.6/start-cb.php to the letter. I also had quite a few problems setting up everything when I picked up SFML, but trust me this tutorial works perfectly for SFML1.6. It might me a bit confusing at first, but once you get the hang of it and actually understand what each option mean, it's really simple :)

As for your question, do not use "SFML project". The best choice to begin with is "console application", this is also what the tutorial recommends.

Pages: 1 [2] 3 4