Sign in to follow this  
JohnDeJong

A newbie Question

Recommended Posts

JohnDeJong    122
Hi readers, I am new to programming, and have a little problem. I wonder how to implement files such as .bmp or wav files in to a program. So that the result will be only one .exe file, without any external files. I hope you all understand my poor English

Share this post


Link to post
Share on other sites
JohnDeJong    122
Oops, that information a was forgotten in my speed to search for anwsers. Sorry. I am programming in Visuall C++, so I am writting an windows program. I'm now trying to use particles. The examples I got from internet all using external data. And that is nog what I want.
I hope this infotmation is enough.

The used example:

UX_RGBImageRec *LoadBMP(char *Filename) // Loads A Bitmap Image
{
FILE *File=NULL; // File Handle

if (!Filename) // Make Sure A Filename Was Given
{
return NULL; // If Not Return NULL
}

File=fopen(Filename,"r"); // Check To See If The File Exists

if (File) // Does The File Exist?
{
fclose(File); // Close The Handle
return auxDIBImageLoad(Filename); // Load The Bitmap And Return A Pointer
}

return NULL; // If Load Failed Return NULL

Share this post


Link to post
Share on other sites
JohnDeJong    122
There was a part missing in de code above. This is the rest of it.




// Load The Bitmap, Check For Errors, If Bitmap's Not Found Quit
if (TextureImage[0]=LoadBMP("Data/some.bmp"))
{
Status=TRUE; // Set The Status To TRUE

glGenTextures(1, &texture[0]); // Create The Texture

Share this post


Link to post
Share on other sites
haegarr    7372
Binary data files (like BMPs or WAVs or whatever) are nothing more than a collection of binary data words. It is up to a correct interpretation of that data whether or not one gets actually what the data mean. So for a program it makes no difference in principal whether the data are read from an external file or an internal data array. The only thing you have to do is to convert the external file format of interest in a file format that could be bind into your executable.

To do so, the simplest way may be to convert the binary data file into a text file compatible to the programming language you are using, so that the file becomes a regular source. Typically (but really known by me only for C/C++ and Java) there is a possibility to use octet arrays as sources of files rather than a real file. Setting up such an array reader with an array of the compiled in data will do the job.

Hence the only thing remaining is to have a little utility that opens and reads the external binary data file and writes an equivalent language compatible text file, where each octet read from the file is written as a constant in the language you are using.

More details could not be given since you post which language in use, as SiCrane alreads stated.

EDIT: Hmpf. 3 posts since I've began to write. I must become faster...
However, this all will work fine only if your BMP-or-whatever-reader also allows to read from e.g. streams, not only from files specified by name!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this