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

Author Topic: White rectangle  (Read 1076 times)

0 Members and 1 Guest are viewing this topic.

chadushkind

  • Newbie
  • *
  • Posts: 10
    • View Profile
White rectangle
« on: February 19, 2014, 02:43:37 pm »

when i run the application, I get a white square. Why? And how to fix it? Thnx.
« Last Edit: February 19, 2014, 03:29:38 pm by chadushkind »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6286
  • Thor Developer
    • View Profile
    • Bromeon
Re: White rectangle
« Reply #1 on: February 19, 2014, 03:03:00 pm »
Have you searched before posting? This problem has appeared dozens of times in the past. It always has to do with textures that are invalidated.

There are several mistakes in your code: You don't check for errors when loading, you return a copy (instead of reference) in GetTexture(), and you needlessly allocate a dynamic texture, where you could directly load the texture inside the map. The destructor is also unnecessary, STL containers clean up properly on their own.
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

chadushkind

  • Newbie
  • *
  • Posts: 10
    • View Profile
Re: White rectangle
« Reply #2 on: February 19, 2014, 03:29:14 pm »
Have you searched before posting? This problem has appeared dozens of times in the past. It always has to do with textures that are invalidated.

There are several mistakes in your code: You don't check for errors when loading, you return a copy (instead of reference) in GetTexture(), and you needlessly allocate a dynamic texture, where you could directly load the texture inside the map. The destructor is also unnecessary, STL containers clean up properly on their own.

Thank you very much. I used the search before, I understood the problem, but I did not understand the decision. I did not consider the option of using references. Thank you again!

 

anything