Sign in to follow this  

.wav and .bmp in executable

This topic is 3855 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

Hi all, Is there a way to build/compile an .exe file that will not need to reside in the same directory as the .bmp and .wav files it needs/uses, but rather have them compiled into the .exe file itself instead? [Edited by - Boaty on May 28, 2007 1:18:13 PM]

Share this post


Link to post
Share on other sites
Really?

Well, I'm using Visual Studio C++ Express 2005 (or something like that).

I've definently heard of these Resource files, though. How would I go about using them?

[Edited by - Boaty on May 28, 2007 1:47:12 PM]

Share this post


Link to post
Share on other sites
(Warning this explanation is done using the full version of visual studio so it might be slightly different in the express version)

1. Start off by in the solution explorer right clicking Resource Files highlighting Add then clicking Resource

2. You should be presented with a popup which is named Add Resource

3. Click import followed by selecting what file you are going to add as a resource to your project (note after you select this item it is best not to move the file to another folder, so make sure you are happy where your resource files are located)

4. You should be presented with the file you added to the resource in Resource View, here you will want to right click the resource in the left (it will be named IDB_BITMAP1 or something similar it varies upon resource type) and click properties, change the ID to something easy to remember and keep the prefix as that is the only thing that distinguishes between resource types in the final code.

5. Go back to the solution explorer and load the new file resource.h

6. Ensure that there are no duplicate entries for example you may have an:
#define IDB_BITMAP1 101
#define IDB_CAR1 101

In this case the IDB_CAR1 would be the renamed resource from step 4, so you would delete the line IDB_BITMAP1 is on to prevent confusion.

7. To include the resource in your game code varies on how you load the files. For example a bitmap class i wrote takes files and resources differently, the resource requires an instance handle, while the file doesnt, so you may need to take that into account when implementing resource files.

If you have any problems ill do my best to help out in the morning as its late and i should sleep.

Share this post


Link to post
Share on other sites
Yea...That kind of is a problem because Express doesn't have resource templates to add. What file extension do they have? I've seen .rc, .res, .resx, and others. Do you know the syntax for one? If you do, I might be able to just type it in notepad and save it. I already have a .rc file, but it doesn't seem to be working.

Share this post


Link to post
Share on other sites
Ok. This is what I have so far. Should this work?


This is my resource.rc file:

#include "resource.h"

//icon resources
IDI_ICON ICON "heron.ico"
IDI_ICONSM ICON "small.ico"

//bitmap resources
IDB_FONTBLACK BITMAP "fontblck.bmp"
IDB_FONTWHITE BITMAP "fontwhite.bmp"
IDB_BACKGROUND BITMAP "background.bmp"
IDB_BALL BITMAP "ball.bmp"
IDB_PADDLE BITMAP "paddle.bmp"
IDB_BRICK BITMAP "brick.bmp"

//wave resources
IDW_BOUNCE WAVE "bounce.wav"
IDW_HIT WAVE "hit.wav"
IDW_MISSED WAVE "missed.wav"
IDW_LAUNCH WAVE "launch.wav"


This is my resource.h file:

//icon resources
#define IDI_ICON
#define IDI_ICONSM

//bitmap resources
#define IDB_FONTBLACK
#define IDB_FONTWHITE
#define IDB_BACKGROUND
#define IDB_BALL
#define IDB_PADDLE
#define IDB_BRICK

//wave resources
#define IDW_BOUNCE
#define IDW_HIT
#define IDW_MISSED
#define IDW_LAUNCH

And this is a part of my main file trying to load a bitmap:

//load the font
fontwhite = LoadTexture(IDB_FONTWHITE, D3DCOLOR_XRGB(0,0,0));
if (fontwhite == NULL)
return 0;

Share this post


Link to post
Share on other sites

This topic is 3855 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.

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