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

Author Topic: Issue with cache of pictures  (Read 1844 times)

0 Members and 1 Guest are viewing this topic.

JasonLeon

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Issue with cache of pictures
« on: October 01, 2023, 09:26:03 pm »
I wanted to cache pictures at the beginning, using map<string, Texture>cache to store the info of the image. I wrote the code
cache[filename].loadFromFile(xxx);
but the program crashed.
I also used the ways below.
Texture temp;
temp.loadFromFile(xxx);
cache[filename]=std::move(temp);
Still did not work.
Seems like the Texture kind object cannot use '='?

kojack

  • Sr. Member
  • ****
  • Posts: 343
  • C++/C# game dev teacher.
    • View Profile
Re: Issue with cache of pictures
« Reply #1 on: October 01, 2023, 09:52:03 pm »
I just tested your first version, it works fine. (I usually use texture pointers in my resource system map, but textures work too)
Are you sure that's the part causing the crash?

JasonLeon

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Issue with cache of pictures
« Reply #2 on: October 01, 2023, 10:06:26 pm »
That's really confusing. I'm sure the file is existed.😥

JasonLeon

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Issue with cache of pictures
« Reply #3 on: October 02, 2023, 06:38:14 am »
I just tested your first version, it works fine. (I usually use texture pointers in my resource system map, but textures work too)
Are you sure that's the part causing the crash?
I wrote this and the program crashed here:
textureCache[string("animation\\") + fileinfo.name].loadFromFile(string("..\\graphics\\animation\\") + fileinfo.name);
« Last Edit: October 02, 2023, 06:41:47 am by JasonLeon »

JasonLeon

  • Newbie
  • *
  • Posts: 12
    • View Profile
    • Email
Re: Issue with cache of pictures
« Reply #4 on: October 02, 2023, 06:46:50 am »
Sorry guys. I found out that it was the loop's fault. Problem solved.