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

Author Topic: Trying to create texture array  (Read 1523 times)

0 Members and 1 Guest are viewing this topic.

Miraz

  • Newbie
  • *
  • Posts: 8
    • View Profile
Trying to create texture array
« on: May 17, 2014, 03:52:35 pm »
Hello !

Im trying to store textures to array but somehow i cant figure out how. Could you guys give me a way to go ?

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Trying to create texture array
« Reply #1 on: May 17, 2014, 03:56:50 pm »
You need to ask a far more specific question, with a clear explanation of what you want to do, how you tried to achieve it (with complete and minimal code) and exactly what difficulties or error messages you encountered and why you can't overcome them on your own.

As far as I know there's no reason you can't just declare an ordinary array of sf::Textures, so I can't even guess what your problem might be.  If you simply don't know how to declare an array, go learn C++ and stop trying to use SFML until you finish.

Miraz

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Trying to create texture array
« Reply #2 on: May 17, 2014, 04:05:55 pm »
Thank you for reply, i have read 2 books of c++ and done some projects and workd whit array and classes. I also know java and others language and i have been programming 5 years.

What im asking is HOW i should construct texture array RIGHT and efficient way. Im not asking code, just logic behind all.

Sorry if i sound rude, you did too ;)

Jesper Juhl

  • Hero Member
  • *****
  • Posts: 1405
    • View Profile
    • Email
Re: Trying to create texture array
« Reply #3 on: May 17, 2014, 04:10:05 pm »
sf::Texture is a pretty heavyweight class, so you don't want to copy it more than you have to. Also, sprites store pointers to textures, so they need to stay where they were created.
So, I'd probably use a std::vector<std::unique_ptr<sf::Texture>>>

Ixrec

  • Hero Member
  • *****
  • Posts: 1241
    • View Profile
    • Email
Re: Trying to create texture array
« Reply #4 on: May 17, 2014, 04:11:37 pm »
That depends entirely on what you want to do with the textures.  For extremely simple programs, declaring an ordinary array on the stack might be all you need.  For very complicated programs you might benefit from using something like thor::ResourceCache.  For more typical programs you may just want a vector of (smart) pointers to textures, like Jesper said.

Quote
Sorry if i sound rude, you did too
People need to be scolded for asking terrible questions or they'll never learn how to ask good ones.
« Last Edit: May 17, 2014, 04:13:40 pm by Ixrec »

Miraz

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Trying to create texture array
« Reply #5 on: May 17, 2014, 04:34:55 pm »
Thank you both of you, working on my code now !

 

anything