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

Author Topic: Physics Filesystem  (Read 19953 times)

0 Members and 1 Guest are viewing this topic.

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Physics Filesystem
« on: April 09, 2013, 06:56:56 am »
I've added example code of sf::InputStream that uses PhysicsFS to load from disc or some archive(it's all transparent and abstracted away by physics).
Can someone please double check formatting and that I didn't break the main Sources page or something?

https://github.com/SFML/SFML/wiki/Sources

https://github.com/SFML/SFML/wiki/Source%3A-PhysicsFS-Input-Stream

This will be helpful next time someone molests Laurent about SFML needing a filesystem.. :P
Back to C++ gamedev with SFML in May 2023

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Physics Filesystem
« Reply #1 on: April 09, 2013, 08:08:47 am »
Looking all good.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Physics Filesystem
« Reply #2 on: April 09, 2013, 08:14:55 am »
To be extremely picky, I would add open/close functions to the stream class, rather than giving it directly a PHYSFS_FILE*. This way it is perfectly encapsulated, and has the same interface as other file streams (like std::ifstream).
Laurent Gomila - SFML developer

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Physics Filesystem
« Reply #3 on: April 09, 2013, 09:05:58 am »
Quote
To be extremely picky
>:( ;D
Done, hope I didn't introduce a mistake now..
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Physics Filesystem
« Reply #4 on: April 09, 2013, 09:19:03 am »
Looks good, but open should return a boolean ;)
Laurent Gomila - SFML developer

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10801
    • View Profile
    • development blog
    • Email
Re: Physics Filesystem
« Reply #5 on: April 09, 2013, 09:26:12 am »
Nice! :)
I always wanted to look into that, but never got around to do it.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Physics Filesystem
« Reply #6 on: April 09, 2013, 11:02:51 am »
Quote
Looks good, but open should return a boolean ;)
>:( ;D Done too. Really, it's just to show that it's possible and easy not to be best designed API ever.
Back to C++ gamedev with SFML in May 2023

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
Re: Physics Filesystem
« Reply #7 on: April 09, 2013, 11:07:39 am »
The code is so small, there's no reason to have it badly designed ;)
Laurent Gomila - SFML developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Physics Filesystem
« Reply #8 on: April 09, 2013, 03:54:06 pm »
Sorry for this useless post, but: lol

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Physics Filesystem
« Reply #9 on: April 09, 2013, 09:10:09 pm »
Quote
Sorry for this useless post, but: lol
LoL. ;D ;D
Quote
The code is so small, there's no reason to have it badly designed ;)
void main(){}

Thanks for re-edit, whoever did it. My style of coding isn't very friendly. ;D

Turns out we forgot to null out file handle when we close so it didn't really look like it closed(we held invalid pointer). ;D Fixed.
« Last Edit: April 11, 2013, 06:57:47 pm by FRex »
Back to C++ gamedev with SFML in May 2023

FRex

  • Hero Member
  • *****
  • Posts: 1845
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Physics Filesystem
« Reply #10 on: February 06, 2018, 02:07:32 pm »
I've updated it a tiny bit, added C++ to ``` to make code colored, split it into hpp and cpp, added sf::NonCopyable as a base to make it more secure, etc.
Back to C++ gamedev with SFML in May 2023

GRAHAMO

  • Newbie
  • *
  • Posts: 1
    • View Profile
Re: Physics Filesystem
« Reply #11 on: July 31, 2019, 02:51:13 pm »
Decent, need to accomplish something like this with mine.

 

anything