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

Author Topic: Problem / question about complex function in main game loop  (Read 1565 times)

0 Members and 1 Guest are viewing this topic.

antytaon

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Problem / question about complex function in main game loop
« on: February 23, 2012, 04:27:31 pm »
Greetings from Poland!
I got FPS problem. Look at this code.

Function outside:
//
[/code]

In main game loop:
Code: [Select]

//


In this situation i got like 14-15 FPS.
When I comment function in main game loop i got 60 FPS.
When I comment content of DrawPlayingArea function i got like 15 FPS.
Do the function uses too many arguments or arguments too 'heavy'?
Thanks in advance for any help.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Problem / question about complex function in main game loop
« Reply #1 on: February 23, 2012, 04:31:22 pm »
Code: [Select]
sf::Image G, sf::Image T1, sf::Image MI, sf::Image SMI
Use references, otherwise you'll copy the whole images (which take probably several KB or MB of memory) every time you call the function!
Code: [Select]
const sf::Image& G, const sf::Image& T1, const sf::Image& MI, const sf::Image& SMI
And instead of copying the visible area to a new image, why don't you simply use the SubRect property of the sprite?
Laurent Gomila - SFML developer

antytaon

  • Newbie
  • *
  • Posts: 6
    • View Profile
    • Email
Problem / question about complex function in main game loop
« Reply #2 on: February 23, 2012, 04:34:33 pm »
Thanks Laurent for reply faster than light! Will write again if have any futher problems.

 

anything