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

Author Topic: ResourceStream class for custom resource loading  (Read 15290 times)

0 Members and 2 Guests are viewing this topic.

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
ResourceStream class for custom resource loading
« Reply #15 on: June 12, 2011, 07:57:07 pm »
I'm going back and forth with Sean now about some changes to stb_image's API.  So I'll have to revise the files again in a bit.

It will be for the better, though.  Should have some performance increases when loading files, and less demanding requirements for streams.

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
ResourceStream class for custom resource loading
« Reply #16 on: June 14, 2011, 06:14:20 am »
OK this is with the official release of stb_image.  Now images can be loaded without the stream needing to be rewound.

So a few changes to stb_image.h and ImageLoader.cpp

https://legacy.sfmluploads.org/index.php?page=view_file&file_id=15

Hopefully now it's done for reals.

Haikarainen

  • Guest
ResourceStream class for custom resource loading
« Reply #17 on: June 14, 2011, 01:49:10 pm »
Quote from: "Disch"
OK this is with the official release of stb_image.  Now images can be loaded without the stream needing to be rewound.

So a few changes to stb_image.h and ImageLoader.cpp

https://legacy.sfmluploads.org/index.php?page=view_file&file_id=15

Hopefully now it's done for reals.


 Just wanted to say; Congrats on first real use of sfmluploads! :D

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
ResourceStream class for custom resource loading
« Reply #18 on: June 14, 2011, 04:58:40 pm »
Thanks.  It's great to have an upload site that doesn't suck.  =)

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
ResourceStream class for custom resource loading
« Reply #19 on: July 17, 2011, 12:22:50 pm »
This feature is now included in SFML 2 :)
Laurent Gomila - SFML developer

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
ResourceStream class for custom resource loading
« Reply #20 on: July 17, 2011, 01:54:06 pm »
hm I didn't know about this. That's great
Pluma - Plug-in Management Framework

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
ResourceStream class for custom resource loading
« Reply #21 on: July 18, 2011, 05:50:28 pm »
Awesome!

*thumbs up*

pdinklag

  • Sr. Member
  • ****
  • Posts: 330
  • JSFML Developer
    • View Profile
    • JSFML Website
ResourceStream class for custom resource loading
« Reply #22 on: July 18, 2011, 06:13:00 pm »
Yay, it will be a fun challenge to implement resource loading from Java InputStreams. :)

EDIT:
I wonder what exactly the Seek method is needed for?
JSFML - The Java binding to SFML.

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
ResourceStream class for custom resource loading
« Reply #23 on: July 18, 2011, 10:29:21 pm »
Fonts, mostly.  Font files can be huge, and the glyph data is scattered about.  When reading font data it will only want to get data from the glyphs it needs, so it will need to seek around the file to find them.

You could probably leave out seeking in an implementation and music playback and image loading would likely still work fine.  But it depends on the file.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
ResourceStream class for custom resource loading
« Reply #24 on: July 18, 2011, 10:43:02 pm »
Reading a resource file is not always sequential, even for musics or images. The loader may have to seek backward or forward to navigate in the file header for example, or to skip useless data, or whatever.

Seek is pretty common in stream classes, in all languages.
Laurent Gomila - SFML developer

Disch

  • Full Member
  • ***
  • Posts: 220
    • View Profile
ResourceStream class for custom resource loading
« Reply #25 on: July 20, 2011, 02:30:20 am »
I'm a little surprised I didn't notice this earlier... but there's an issue with name continuity.

right now we have Seek() and GetPosition().

Logically, one would expect the inverse of GetPosition to be SetPosition.  Having Seek as the inverse is kind of counter-intuitive.

That said, I find Seek/Tell to be more intuitive for Files/Streams than Get/Set Position.  But really I don't think it matters as long as one style is consistent.

Is it too late to rename one of these?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
ResourceStream class for custom resource loading
« Reply #26 on: July 20, 2011, 07:32:37 am »
Hmm you're right, this is inconsistent. And it's not too late (nothing's too late as long as SFML 2.0 is not released ;)).
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
ResourceStream class for custom resource loading
« Reply #27 on: July 20, 2011, 08:04:25 am »
Done :)
Laurent Gomila - SFML developer

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
ResourceStream class for custom resource loading
« Reply #28 on: September 05, 2011, 03:28:27 pm »
Well, there is an InputStream already. Now what about an OutputStream? It's not unusual that one wants to create/update data and send it through some output stream to add compression/encryption/send through network etc.

Also I think it would be worth adding overloads of operator >> and << to read/write data to/from streams. Those overloads can be easily implemented using the pure virtual Read/Write operations.

To be more consistent, Packet class on the network package may inherit from InputStream and OutputStream, or separate it into two classes (InputPacket, OutputPacket, or something like that). That would fit better what is said about Inputstream being able to be used to read data from the network.

What do you think?
Pluma - Plug-in Management Framework

gsaurus

  • Sr. Member
  • ****
  • Posts: 262
    • View Profile
    • Evolution Engine
ResourceStream class for custom resource loading
« Reply #29 on: September 10, 2011, 12:18:31 pm »
Any opinion/comment?  :roll:
The main purpose of InputStream is to read SFML resources from custom streams, so, a way to write them would be as good.
Finally the operators >> & << would provide a good generalization and become in conformance with the purposes of what the current Packet class is.
[/summary]
Pluma - Plug-in Management Framework

 

anything