PDA

View Full Version : Making a Package for the game? [sounds,graphics]



arthurprs
25-07-2007, 12:33 AM
Hello, im using sdl to my game it looks vry nine, fast, simple.

But i have a some resources, and its does not look nice to distribute is separated files, its there a way to make a package with all them ?

*Looks harder for me because PSDL_Surface only loadfiles from disk, and Samples and Streams of BASS too :(


PS: sorry my english

jasonf
25-07-2007, 08:42 AM
There is a way using SDL RWops (a very powerful and slightly underdocumented feature of SDL) it works for SDL, SDL_Image and SDL Mixer, the only issue you're going to have I think, is with BASS...

but that's only because I've never used BASS, perhaps it has a way of loading from a resource already built in.

But it's quite possible to load SDL Resources from a Zip file... or any other type of file for that matter.

There are examples on the net of how to do it, some people on here have done it too. I'm not sure if the current version of JEDI-SDL has examples of WRops, perhaps it should.

Robert Kosek
25-07-2007, 01:02 PM
Bass can load everything from memory. No problem there. You just need to load it to a stream and pass that stream's memory pointer. Bass has a pretty inclusive help file, you might find it helpful to read about the load functions.

WILL
25-07-2007, 02:04 PM
There are examples on the net of how to do it, some people on here have done it too. I'm not sure if the current version of JEDI-SDL has examples of WRops, perhaps it should.

Perhaps indeed. :)

I'll see what Dom has to say about it sometime after he's back from vacation. I'm likely to look into this myself as a matter of fact.

Though if I understand you correctly; you are talking about the method of compiling a large WAD-type file, loading it into memory and then instead of loading from file, you load from memory stream, yes?

I, myself, would not be so worried about the music files though. It's common practice to leave music open. I'd only bother if you really want to make extracting the music harder. ;) But if you have MOD-type music it could be a simple matter of renaming the files to throw them off, then again same with MP3 or OGG, but they'll obviously play without incident so less of a trick that way. :P

technomage
25-07-2007, 04:06 PM
In Dom's Absence, I will answer on behaf of JEDI-SDL :)

The JEDI-SDL suite contains a sdlstreams.pas unit which wraps up the TStream and SDL_RWops.

Basically you can use the functions in that unit to create the SDL_RWops from a TStream, TMemoryStream, TFileStream, TResourceStream etc and pass that to the appropriate SDL_Load function.

Personally I have written a system which will allow you to load resources from a compressed archive and load them directly into SDL. e.g use IMG_LoadRW to load the resource from the compressed archive file.

Unfortunately it's an integral part of my InfinitEngine (http://infinitengine.infinitespace-online.net) which is still in development. sorry :(

arthurprs
25-07-2007, 07:00 PM
Thanks for all the replies, i will take a look at both documentations.

If anyone have a final solution for this please share withus :)

savage
26-07-2007, 11:45 AM
Hi guys, I had a few minutes to spare, got bored sitting outside in the sun and jumping into the pool ;).

As Dean says sdlstreams.pas ( in the SDL sub dir ) is a good place to start looking. I thought there was an example somewhere of of how to use it with zip archives, but I´m obviously mistaken and can´t double check it until I get back this Sunday.

I just found this (http://www.gpwiki.org/index.php/Talk:SDL:Tutorials:Displaying_a_Bitmap_from_a_zip_ file_using_SDL_RWops_and_zlib), which might get you started.

arthurprs
17-08-2007, 11:19 PM
I have done it ;]

Thx for all!

arthurprs
18-08-2007, 02:12 PM
I have done it ;]

Thx for all!

unfortunaly i don't found a unit for unziping zip with password =(

someone have ?

Robert Kosek
18-08-2007, 02:30 PM
http://tpabbrevia.sourceforge.net/ :D

arthurprs
18-08-2007, 03:57 PM
http://tpabbrevia.sourceforge.net/ :D

:( The lib not already implemented extracttostream :(

Robert Kosek
18-08-2007, 04:05 PM
Since when? TAbUnZipper.ExtractToStream(ItemName,Stream);

arthurprs
18-08-2007, 04:43 PM
Since when? TAbUnZipper.ExtractToStream(ItemName,Stream);

The method exist, but when you use it -> it raises anerror :lol:

Robert Kosek
18-08-2007, 06:26 PM
Show me your code and the string you're looking for. I'll tell you how to get it right. Wicked Defense uses my zip handler that uses that exact line of code.

arthurprs
18-08-2007, 06:59 PM
Show me your code and the string you're looking for. I'll tell you how to get it right. Wicked Defense uses my zip handler that uses that exact line of code.

There
procedure Loadresources;
var
ZIP: TAbUnZipper;
RESZIP: TStream;
a: Cardinal;
path: string;
begin
a := SDL_GetTicks;
ZIP := TAbUnZipper.Create(nil);
path := ExtractFileDir(ParamStr(0)) + '\';
Writeln(path);
ZIP.OpenArchive(path+'res.zip');
RESZIP := TStream.Create;
ZIP.ExtractToStream('minefield.bmp',RESZIP);
g_minefield := LoadSDLBMPFromStream(RESZIP);
ZIP.Free;
RESZIP.free;
end;


ERROR:
EstreamError with message 'Tstream.seek not implemented'

JSoftware
18-08-2007, 07:09 PM
TStream is an abstract class, which means that you'll have to use a TMemoryStream instead

arthurprs
18-08-2007, 07:13 PM
TStream is an abstract class, which means that you'll have to use a TMemoryStream instead

It compiled sucefull but the
g_minefield := LoadSDLBMPFromStream(RESZIP);
does not work now ;/

JSoftware
18-08-2007, 07:18 PM
how do you know it doesn't work? Does it throw an accessviolation or another exception?

or does it just not load anything?

Robert Kosek
18-08-2007, 07:24 PM
Try this:procedure Loadresources;
var
ZIP: TAbUnZipper;
RESZIP: TMemoryStream;
a: Cardinal;
path: string;
begin
a := SDL_GetTicks;
ZIP := TAbUnZipper.Create(nil);
path := ExtractFileDir(ParamStr(0)) + '\';
Writeln(path);
ZIP.OpenArchive(path+'res.zip');
RESZIP := TMemoryStream.Create;
ZIP.ExtractToStream('minefield.bmp',RESZIP);
g_minefield := LoadSDLBMPFromStream(TStream(RESZIP));
ZIP.Free;
RESZIP.free;
end;

arthurprs
18-08-2007, 07:34 PM
JSoftware :~
Function does not return nothing

Robert Kosek :~
Same thing ;/ the function return nil

Robert Kosek
18-08-2007, 07:54 PM
Strange, it should work. I don't use SDL so I can't test everything, but I know for sure it isn't Abbrevia!

Is the archive encrypted, or is the file in a subdirectory?

arthurprs
18-08-2007, 08:06 PM
Strange, it should work. I don't use SDL so I can't test everything, but I know for sure it isn't Abbrevia!

Is the archive encrypted, or is the file in a subdirectory?
Yes i checked size of the stream and its exactly same as the file, so all right there.

The SDL funcion that don't work

In the other unit(the one that does not support protected zip) exports to Tstringstream and work all right.

technomage
18-08-2007, 09:23 PM
It's probably that after extracting the stream from the archive, you need to reset the position back to 0 before passing it to the SDL functions, otherwise it'll just read form the current position.

arthurprs
18-08-2007, 09:45 PM
It's probably that after extracting the stream from the archive, you need to reset the position back to 0 before passing it to the SDL functions, otherwise it'll just read form the current position.

Don't understand nothing, but how can i do that ?

Robert Kosek
18-08-2007, 09:56 PM
RESZIP.Position := 0; // Before "LoadFromStream"

arthurprs
18-08-2007, 10:14 PM
RESZIP.Position := 0; // Before "LoadFromStream"
YEAHHHH!!
worked ;]

Thx for all

paul_nicholls
05-11-2007, 10:14 PM
Show me your code and the string you're looking for. I'll tell you how to get it right. Wicked Defense uses my zip handler that uses that exact line of code.

There
procedure Loadresources;
var
ZIP: TAbUnZipper;
RESZIP: TStream;
a: Cardinal;
path: string;
begin
a := SDL_GetTicks;
ZIP := TAbUnZipper.Create(nil);
path := ExtractFileDir(ParamStr(0)) + '\';
Writeln(path);
ZIP.OpenArchive(path+'res.zip');
RESZIP := TStream.Create;
ZIP.ExtractToStream('minefield.bmp',RESZIP);
g_minefield := LoadSDLBMPFromStream(RESZIP);
ZIP.Free;
RESZIP.free;
end;


ERROR:
EstreamError with message 'Tstream.seek not implemented'

Hi arthurprs,
the problem here is that you are directly creating a TStream when infact you should be using one of it's descendents, like TMemoryStream for example instead.

Just try changing the TStream references to TMemoryStream and see if that helps.

cheers,
Paul

arthurprs
06-11-2007, 04:32 PM
Show me your code and the string you're looking for. I'll tell you how to get it right. Wicked Defense uses my zip handler that uses that exact line of code.

There
procedure Loadresources;
var
ZIP: TAbUnZipper;
RESZIP: TStream;
a: Cardinal;
path: string;
begin
a := SDL_GetTicks;
ZIP := TAbUnZipper.Create(nil);
path := ExtractFileDir(ParamStr(0)) + '\';
Writeln(path);
ZIP.OpenArchive(path+'res.zip');
RESZIP := TStream.Create;
ZIP.ExtractToStream('minefield.bmp',RESZIP);
g_minefield := LoadSDLBMPFromStream(RESZIP);
ZIP.Free;
RESZIP.free;
end;


ERROR:
EstreamError with message 'Tstream.seek not implemented'

Hi arthurprs,
the problem here is that you are directly creating a TStream when infact you should be using one of it's descendents, like TMemoryStream for example instead.

Just try changing the TStream references to TMemoryStream and see if that helps.

cheers,
Paul

i have followed Jsoftware tip and it worked some time ago, :)
then i needed to set .position to 0 after the extraction and it works perfectly.

paul_nicholls
06-11-2007, 09:21 PM
D'OH! sorry, I didn't read the replies properly :oops:

at least it is working now :)
cheers,
Paul

lordzero
07-11-2007, 01:07 AM
Show me your code and the string you're looking for. I'll tell you how to get it right. Wicked Defense uses my zip handler that uses that exact line of code.

There
procedure Loadresources;
var
ZIP: TAbUnZipper;
RESZIP: TStream;
a: Cardinal;
path: string;
begin
a := SDL_GetTicks;
ZIP := TAbUnZipper.Create(nil);
path := ExtractFileDir(ParamStr(0)) + '\';
Writeln(path);
ZIP.OpenArchive(path+'res.zip');
RESZIP := TStream.Create;
ZIP.ExtractToStream('minefield.bmp',RESZIP);
g_minefield := LoadSDLBMPFromStream(RESZIP);
ZIP.Free;
RESZIP.free;
end;


ERROR:
EstreamError with message 'Tstream.seek not implemented'

maybe this:

RESZIP := TStream.Create;
RESZIP.Seek(0, soFromBeginning);

seems that is the same of RESZIP.Position := 0;

arthurprs
07-11-2007, 01:09 AM
D'OH! sorry, I didn't read the replies properly :oops:

at least it is working now :)
cheers,
Paul

no problem ^^

but now im using my own packer based on Shirson one;