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

Author Topic: Extremely slow FPS drawing large sprites  (Read 2311 times)

0 Members and 2 Guests are viewing this topic.

mbuckley2000

  • Newbie
  • *
  • Posts: 7
    • View Profile
Extremely slow FPS drawing large sprites
« 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);
                                }
 

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Extremely slow FPS drawing large sprites
« Reply #1 on: December 15, 2013, 11:37:38 pm »
Please come up with a minimal complete example, so that we don't have to guess around.

Furthermore, don't mix input handling and drawing.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

mbuckley2000

  • Newbie
  • *
  • Posts: 7
    • View Profile
Re: Extremely slow FPS drawing large sprites
« Reply #2 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?
« Last Edit: December 16, 2013, 08:16:01 pm by mbuckley2000 »

wintertime

  • Sr. Member
  • ****
  • Posts: 255
    • View Profile
Re: Extremely slow FPS drawing large sprites
« Reply #3 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.
;)

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Re: Extremely slow FPS drawing large sprites
« Reply #4 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.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything