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

Author Topic: Easy way to load files from zip  (Read 17680 times)

0 Members and 3 Guests are viewing this topic.

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #15 on: February 08, 2018, 10:42:57 pm »
Quote
C:\Users\*\Desktop\SFML32 - Space Wars\PhysicsFS\include

Quote
C:\Users\*\Desktop\SFML32 - Space Wars\PhysicsFS\lib

Quote
physfs.lib

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #16 on: February 08, 2018, 10:44:23 pm »
What is the actual error you are even getting?
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #17 on: February 08, 2018, 10:47:05 pm »
Quote
identifier ""PHYSFS_AddToSearchPath"" is undefined

btw, for example the following works without problems:

Quote
PHYSFS_init (0);

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #18 on: February 08, 2018, 10:50:15 pm »
It's add, not Add. Where did you take the uppercase name from?

From this maybe? https://icculus.org/physfs/physfstut.txt
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #19 on: February 08, 2018, 10:51:34 pm »
It's add, not Add. Where did you take the uppercase name from?

IT WORKS! HA! Thank you so much  ;D

I got it from the tutorial of physicsfs website.

Edit: yes

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #20 on: February 08, 2018, 10:59:50 pm »
I've sent Ryan Gordon an email about that typo too since it has such time wasting potential. The tutorial code on the SFML wiki is correct though.
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #21 on: February 09, 2018, 05:21:40 pm »
So one more question. Since i dont understand the tutorial completely, i tried to make it on my own.

Quote
PHYSFS_init (0);

   PHYSFS_addToSearchPath ("Game.zip", 1);

   PHYSFS_file* myfile = PHYSFS_openRead ("Game/Sprites/Title.tga");

        sf::Texture tex;
   tex.loadFromStream(??);

   PHYSFS_close(myfile);

   PHYSFS_deinit ();

how do i load myfile to loadfromstream?  :(

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #22 on: February 09, 2018, 05:26:17 pm »
You need a https://www.sfml-dev.org/documentation/2.4.2/classsf_1_1InputStream.php

Like the one from the wiki: https://github.com/SFML/SFML/wiki/Source:-PhysicsFS-Input-Stream

Or you can load entire file into memory and then loadFromMemory.
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #23 on: February 09, 2018, 05:43:41 pm »
Ok thanks. Ill try my best (looks difficult).

In fact, this is the only thing i dont understand:

Quote
tex.loadFromStream(wonderfullStream);

What exactly is returned there? An entire class + sub class?

FRex

  • Hero Member
  • *****
  • Posts: 1848
  • Back to C++ gamedev with SFML in May 2023
    • View Profile
    • Email
Re: Easy way to load files from zip
« Reply #24 on: February 09, 2018, 05:50:38 pm »
A stream that was created few lines before is passed by reference. It's a normal C++ thing with virtual methods, etc. All the load and open functions in SFML also return a bool to say if it worked or not.
Back to C++ gamedev with SFML in May 2023

Bizarreofnature

  • Newbie
  • *
  • Posts: 48
    • View Profile
Re: Easy way to load files from zip
« Reply #25 on: February 13, 2018, 05:01:15 pm »
Well, thank you very much. Its still a bit complicated to me and i guess i will make this at very last of my game.
I guess my c++ is not good enough yet to understand this  :(