PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

embedding resources

Howdy,

I've been loading my resources such as targa's and sound files from the file system using CreateFile.

I would now like to embed them into my actual application so that only a single file is needed?

Any ideas/experiance of this?

cheers
James
yeah i'd like to know this. is it like the logo inside the quake code when checking pak1.pak?

i'm sure there must be an easier way.
There are basically three ways:

1) Add your data as a windows resource, and use the Windows API to access that resource by its identifier.

2) Convert your data into hexadecimel values in text format for direct inclusion into your source code. That is how Quake logo is embedded in the app that Paul is referring to.

3) Designate that the static var arrays that will hold your data should reside in a different section of your app (I'm talking about the PE structure), and create a tool that will write your data into those sections of your executable.

Dan East
windows resource files sounds like the best option for me.
Not sure how to get this to work with MikMod though, anyone tried it?
Sample_Load() takes either a filename or FILE*?

Any help much appreciated

Jim.
reckon I can bypass SampleLoad and create my own SAMPLE struct that points to the wav data.

If anyone knows of an easier method :)

cheers
Jim.
I would like to embed data into my application, too !

How can I convert a file into HEX in text format ?

After that, what is the instruction to include it in VC++ and eVC++ ?

Thanks !
hi, below is some code i wrote to load a TGA file stored as a windows resource. Note that the resource name has to be called using the MAKEINTRESOURCE macro and that this only works for 16bit non-compressed targa files stored using a custom resource type called "TGA".

Code:
//
// FUNCTION: moveGetRawResourcePointer()
//
// PURPOSE: Returns a pointer to a TGA file in the resource file.
//
// COMMENTS:
//
// Returns a pointer to a TGA file in the resource file. Note that the memory
// taken by the LoadResource function has to be freed by the calling function.
//
unsigned short * moveGetRawResourcePointer( LPCTSTR lpResourceName )
{
// Find the resource in this module.
HRSRC hRsrc = FindResource( GetModuleHandle(NULL), lpResourceName, TEXT("TGA") );
if( hRsrc == NULL )
return NULL;

// Load the resource into memory and get a pointer to the memory location.
HGLOBAL hGlobal = LoadResource( GetModuleHandle(NULL), hRsrc );
if( hGlobal == NULL )
return NULL;

// Now skip the header bytes.
return (unsigned short *)hGlobal+9;
}


cryo