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

Author Topic: Load image from file  (Read 1427 times)

0 Members and 1 Guest are viewing this topic.

diego997

  • Newbie
  • *
  • Posts: 21
    • View Profile
Load image from file
« on: May 16, 2012, 08:42:24 pm »
Hello, I wanned to load 8 images from file and keep them like that sf::Image Image[8]. And when I have done it program has slowed as hell. What is the reason ?



Sory for english

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Load image from file
« Reply #1 on: May 16, 2012, 09:04:23 pm »
You are most probably loading the images every frame. Reading from the harddrive is very slow. You should only load the images once.
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

diego997

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Load image from file
« Reply #2 on: May 16, 2012, 09:19:15 pm »
I'have found where a propably can be something wrong but dont know why.
When I load this images in some class for example:

class _Player
{
sf::Texture Texture[8];
public:
void load() //Loading texture from file
};

Program goes slow but when I load it outside of class, before main loop everything works fine

Groogy

  • Hero Member
  • *****
  • Posts: 1469
    • MSN Messenger - groogy@groogy.se
    • View Profile
    • http://www.groogy.se
    • Email
Re: Load image from file
« Reply #3 on: May 16, 2012, 10:02:32 pm »
Well then you are calling the load function inside the mainloop maybe?
Developer and Maker of rbSFML and Programmer at Paradox Development Studio

diego997

  • Newbie
  • *
  • Posts: 21
    • View Profile
Re: Load image from file
« Reply #4 on: May 17, 2012, 08:18:35 am »
I know what was wrong I was sending an object of this class to some function instead of sending reference.