• Advertisement

Archived

This topic is now archived and is closed to further replies.

open compresion & load screens, and va_args

This topic is 5106 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

3 questions: 1) is there any sort of ''open compresion'' software that i can use to compress resource files for my game? or is there even an easy way to load a jpeg into memory so i can acess the pixels? i have a winrar license so i ''could'' just ship with a bunch of sfx files that i copied and ran from a cache folder, but thats a pain. i don''t realy have the budget to license this sort of thing . . . . 2) how do i create a load screen with a little bar? would i set up some callbackishy function that the loading stuff would use? or would i make the load function return after every file to tell the drawing code how it was doing? 3) i know that c has a variable argument library and i have used it. does anyone with the knowledge of how this works (at the system level) know if its slower than a normal function? like would i be better served by packing a bunch of pointers into a union than using it? I just wanna get this done.

Share this post


Link to post
Share on other sites
Advertisement
quote:
Original post by Malchivus
3 questions:

1) is there any sort of ''open compresion'' software that i can use to compress resource files for my game? or is there even an easy way to load a jpeg into memory so i can acess the pixels? i have a winrar license so i ''could'' just ship with a bunch of sfx files that i copied and ran from a cache folder, but thats a pain. i don''t realy have the budget to license this sort of thing . . . .



For images, look up libPNG.

quote:
2) how do i create a load screen with a little bar? would i set up some callbackishy function that the loading stuff would use? or would i make the load function return after every file to tell the drawing code how it was doing?


Try threading. You have a "product" variable which is percent-doneness-of-loading. The loading thread is a producer for the variable, looping to load some file and then produce an "update" to the loading status. The drawing code consumes that status and draws a bar of the appropriate length.

quote:
3) i know that c has a variable argument library and i have used it. does anyone with the knowledge of how this works (at the system level) know if its slower than a normal function? like would i be better served by packing a bunch of pointers into a union than using it?


I''m not sure what kind of union you''re thinking of. I would guess that however you plan to implement it is not far different from what C does internally, though.

Share this post


Link to post
Share on other sites
1. There is a pair of Mac functions called PackBits() and UnpackBits() that do a simple RLE compression, but to use them on Windows, you have to install the QuickTime SDK, which is a bit of a pain.

2. There is a Windows progress bar control. Here''s a link to the MSDN page. You just set up the range, and then send either a PBM_SETPOS or a PBM_DELTAPOS message whenever you want to update the bar. You might also want to send periodic WM_PAINT messages to your main window if you''re doing something processor-intensive that won''t let Windows update your window by itself.

3. Just open up stdarg.h (or <cstdarg> if you''re using the more recent headers) and look at the definitions of va_list, va_start, va_arg, and va_end. The behavior varies depending on the system. It seems to me that in most cases, the arguments are simply stored in a block of contiguous memory, with spacers to align them on 4-byte boundaries, but don''t quote me on this. Someone with more knowledge of assembly should probably answer this. If I had to guess, I''d say it''s just as fast as packing a bunch of pointers into a struct or union and passing that, but again I''m not certain.

Share this post


Link to post
Share on other sites
ok the libPNG thing looks useful, and so does the zlib thing thank you.

ok . . threading, where would i find out about that? i understand the concept of running multiple programs at a atime but i don''t knowm anything about how to do it, do i include some weird library? or do i just ''brute force like'' make a few functions to do it

i''m clear on the ideas for va_arg now, i didn''t think to look up the header but it sounds like what Aprosenf says would be the simplest way and exactly like what i was going to do

so if i don''t need to do multithreading with some weird new API functions i could do something like:

typedef struct thread_packet_t {
void *byte_dest;
size_t size;
size_t fileoffset;
char *filename;
thread_packet_t *NextPacket;
} thread_packet_t;

void start_threads( thread_packet_t *packet_ll );
float chew_some_threads( void );
void end_thread( void );

the start telling what needs to be loaded, and the end cleaning up the linked list? chew would return the statu based on the total number of bytes loaded vs the total number that needed to be loaded.

Share this post


Link to post
Share on other sites
LZO seems to want a license fee? and its trying to be quick rahter than through. when a test background file came up as > 10megs i decided i needed some sort of compresion for my program that would make the images smaller reguardless of how long it took

Share this post


Link to post
Share on other sites

  • Advertisement