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 - Wizzard

Pages: 1 ... 13 14 [15]
211
Graphics / ImageManager
« on: March 27, 2008, 11:42:16 pm »
Thanks a ton. I was doing it with new/delete because I got fed up with googling static pointers. This way looks better though, so I will implement it.

PS: Stop making it look so easy for us beginners! :wink:

212
Graphics / ImageManager
« on: March 27, 2008, 10:46:53 am »
Sorry, I figured that only applied to when using new/delete to allocate space. I'll have to research more on the subject of static pointers. If it's not too much trouble, could you possibly give an example of this?

213
Graphics / ImageManager
« on: March 27, 2008, 09:03:02 am »
I have a similar problem. My implementation of an image manager uses a std::map to ensure resources aren't loaded twice:

Code: [Select]
std::map<std::string, sf::Image> g_Image;

void CEntity::SetImage(const std::string &filename) {
    std::map<std::string, sf::Image>::iterator it = g_Image.find(filename);

    if (it == g_Image.end()) {
        sf::Image image;

        image.LoadFromFile(filename);

        it = g_Image.insert(it, std::pair<std::string, sf::Image>(filename, image));
    }

    m_Sprite.SetImage(it->second);
}


The code works as intended when all entity objects are created before the sf::RenderWindow. However, I hope to create entity objects while in the main loop of my application (after the window has been created). The problem with that is SFML is unloading before the sf::Image destructors are executed. Can anyone tell me how to work around this? Thanks in advance!


Full source code available here.

Pages: 1 ... 13 14 [15]
anything