1
Graphics / [SOLVED]sf::Sprite::SetImage() crash
« on: October 31, 2011, 10:55:23 am »
uh... how can i be so stupid :p
Merci Laurent x)
Merci Laurent x)
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.
struct Item
{
void *ptr;
std::string name;
enum Type type;
struct Item *next;
};
ge::Menu::Menu(std::string bg_path)
{
m_bg = new sf::Sprite;
std::cout << "receive addr " << ge::ResourceManager::getInstance()->getImage(bg_path) << std::endl;
sf::Image &test = *ge::ResourceManager::getInstance()->getImage(bg_path);
m_bg->SetImage(test);
}
sf::Image* ge::ResourceManager::getImage(std::string path)
{
Item *it;
if ((it = search(IMAGE, path)))
{
return (sf::Image*)(it->ptr);
}
sf::Image img;
if (img.LoadFromFile(path))
{
sf::Image *i = (sf::Image*)insert(&img, IMAGE, path)->ptr;
std::cout << "Create image at addr " << i << std::endl;
return i;
}
return NULL;
}
Create image at addr 0x28fb40
receive addr 0x28fb40
cast addr 0x28fb40