.wav and .bmp in executable

Started by
5 comments, last by Boaty 16 years, 10 months ago
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]
------------------------------do{ WriteGames(); CompileGames(); PlayGames();}while(Me + DX9 + C++ = True♥)†Boaty Program Creed†
Advertisement
By using a resource script it is indeed possible. What IDE are you using as something like Visual Studio 2005 can be simple to include resources into your exe.
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]
------------------------------do{ WriteGames(); CompileGames(); PlayGames();}while(Me + DX9 + C++ = True♥)†Boaty Program Creed†
(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.
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.
------------------------------do{ WriteGames(); CompileGames(); PlayGames();}while(Me + DX9 + C++ = True♥)†Boaty Program Creed†
Go to:

http://www.winprog.org/tutorial/

And start with 5. Using Resources. The next ones tell you how to create resource menus etc.
Comrade, Listen! The Glorious Commonwealth's first Airship has been compromised! Who is the saboteur? Who can be saved? Uncover what the passengers are hiding and write the grisly conclusion of its final hours in an open-ended, player-driven adventure. Dziekujemy! -- Karaski: What Goes Up...
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;
------------------------------do{ WriteGames(); CompileGames(); PlayGames();}while(Me + DX9 + C++ = True♥)†Boaty Program Creed†

This topic is closed to new replies.

Advertisement