SFML community forums

General => Feature requests => Topic started by: Avency on November 12, 2007, 07:00:26 pm

Title: Possibility to load resources from a file buffer
Post by: Avency on November 12, 2007, 07:00:26 pm
I'd like to see the possibility of loading resources from a file buffer or filestream
(at least for the built-in ones like images and audio).
I was able to do image loading from a file buffer using DevIL, but since you are going
to replace it in the next version, I'd strongly apply for alternative loading methods as they
shouldn't be hard to implement.

It would be rather useful for use in combination with custom resource files,
filesystems such as PhysicsFS or compression libraries in general.

i.e.
Code: [Select]

bool sf::Image::LoadFromBuffer(void* data, std::size_t size)
bool sf::Image::ReadFromStream(std::fstream& stream, std::size_t size)
bool sf::Image::WriteToStream(std::fstream& stream, std::size_t size)

bool sf::SoundBuffer::LoadFromBuffer(void* data, std::size_t size)
bool sf::SoundBuffer::ReadFromStream(std::fstream& stream, std::size_t size)
bool sf::SoundBuffer::WriteToStream(std::fstream& stream, std::size_t size)

You get the idea...
Title: Possibility to load resources from a file buffer
Post by: Lord Delvin on November 12, 2007, 08:25:09 pm
A much saner way to do that would be to provide methods for a pure virtual reader Class and to do some standardimplementations.
There are still people who have to mess with FILE* as some APIs work with FILE*;)
Title: Possibility to load resources from a file buffer
Post by: Laurent on November 13, 2007, 02:15:56 am
Yep, that's quite important, I'm going to work on it for next version.
Title: Possibility to load resources from a file buffer
Post by: Avency on November 26, 2007, 04:05:58 pm
I see it has been added to svn.
Thanks a lot :D. I really appreciate your work.
I am now going to replace my own code (even if it was almost the same), as I prefer to leave third-party libraries the way they are.