SFML community forums

Help => Graphics => Topic started by: mbuckley2000 on December 15, 2013, 11:02:47 pm

Title: Extremely slow FPS drawing large sprites
Post by: mbuckley2000 on December 15, 2013, 11:02:47 pm
Hey,
I am just starting to learn C++ and SFML, so if there are any really stupid mistakes in my code, please don't hate me :)

I am trying to draw a fairly large (960x976) sprite to my screen, but when I do, it slows down to less than 1 FPS. I am also drawing 10,000 16x16 sprites to my screen, and this runs at 60 FPS no problem. I have an HD 5770 with 1gb GDDR5, so that isn't the issue I don't think.

Any help is much appriciated :)

if (sf::Keyboard::isKeyPressed(sf::Keyboard::LAlt) && EditorMode == 1) {
                                        TileSetSprite.setPosition(sf::Vector2f(GetLeftPixel(0), GetTopPixel(0)));
                                        Window.draw(TileSetSprite);
                                }
 
Title: Re: Extremely slow FPS drawing large sprites
Post by: Nexus on December 15, 2013, 11:37:38 pm
Please come up with a minimal complete example (http://en.sfml-dev.org/forums/index.php?topic=5559.msg36368#msg36368), so that we don't have to guess around.

Furthermore, don't mix input handling and drawing.
Title: Re: Extremely slow FPS drawing large sprites
Post by: mbuckley2000 on December 16, 2013, 07:52:32 pm
OK, I made a minimal complete example, and couldn't reproduce the problem.. Unfortunately, I have no idea what is causing it. Are there any known issues with using sprites with global / cross file functions and variables? So basing it's coordinates on a function which is in another file?
Title: Re: Extremely slow FPS drawing large sprites
Post by: wintertime on December 17, 2013, 08:54:07 am
The probability of a bug residing in a piece of code is inversely proportional to the number of people and the time of them using it.
If you had a problem in your new code that you cant find anymore after changing it, it was a problem with your code.
;)
Title: Re: Extremely slow FPS drawing large sprites
Post by: Nexus on December 17, 2013, 11:34:44 am
There are some known issues with global/static SFML objects. In general, it's a good idea to avoid them completely. If you design your application in a clean way, globals, statics and singletons are hardly ever necessary.