SFML community forums

Help => General => Topic started by: hipsterdufus on August 05, 2013, 04:22:46 am

Title: How can I serialize my world/level data into and out of a file?
Post by: hipsterdufus on August 05, 2013, 04:22:46 am
Hi everyone, I decided to use boost::serialize to input or output my level data into a file. My level data basically just consists of a few std::vectors that contain the tiles in the level. Each tile contains sf::sprites and sf::textures along with a position. I can serialize everything in the tile class with the exception of the sf::sprite and sf::texture data. These are sfml types that boost doesn't know how to output or read in. Does anyone have any ideas on how to do this? I feel like there should be a simple solution that I'm overlooking here.
Title: Re: How can I serialize my world/level data into and out of a file?
Post by: cpolymeris on August 05, 2013, 05:04:12 am
I am not familiar with boost::serialize, but remember Textures reside in video memory, so you can't really serialize their contents. You would have to serialize the identifiers you use to load the textures (filenames or strings or whatever). I am sure boost allows you to define your own serialization routines for a class. Or probably easier: just use the string serialization that boost provides.