As the title, does SDL_RWops
have any advantages over std::fstream
in dealing with I/O file? Can I use std::fstream
instead because I am more familiar with it?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
SDL_RWops may be implemented for many types of data streams. Standard SDL provides
SDL_RWFromFile
andSDL_RWFromMem
, while other libraries like physfs provides implementation of RWops for many of its supported archive types.Main benefit of RWops is that all of SDL-family libraries (SDL_image, SDL_mixer, ...) supports loading from RWops so you can easily feed your own specific data source (e.g. your archive format, or maybe even network source) to them. Aside from that, it may or may not be good for your code, depending on your needs.
By reading their documentation, you can find that
std::fstream
is an:On the other side,
SDL_RWops
is something more:Quite stronger an abstraction.
So, can you use
std::fstream
in place ofSDL_RWops
for your files? Absolutely, if you feel more confident, go with it. The latter is an useful abstraction over any sort of stream in your game, so the advantage is something beyond reading a file.