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

Author Topic: Possibility to load resources from a file buffer  (Read 24322 times)

0 Members and 1 Guest are viewing this topic.

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Possibility to load resources from a file buffer
« 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...

Lord Delvin

  • Jr. Member
  • **
  • Posts: 68
    • ICQ Messenger - 166781460
    • View Profile
Possibility to load resources from a file buffer
« Reply #1 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*;)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Possibility to load resources from a file buffer
« Reply #2 on: November 13, 2007, 02:15:56 am »
Yep, that's quite important, I'm going to work on it for next version.
Laurent Gomila - SFML developer

Avency

  • Full Member
  • ***
  • Posts: 113
    • View Profile
Possibility to load resources from a file buffer
« Reply #3 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.