Jump to content
  • Advertisement

Archived

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

deadlydog

How to include things as resources in your project

This topic is 5276 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 there, I''m making a game and currently you need to have the Data folder in the same directory as the .exe for it to work. The Data folder contains all of the pictures and everything else for the game. I''m pretty sure you can include these as resources into the project so they''re loaded right into the .exe, but I''m not sure how to do this. I''m using Microsoft Visual C++ 6. Can anyone help me out? - God is my favorite fictional character

Share this post


Link to post
Share on other sites
Advertisement
Okay, I figured out how to actually import images and stuff into the project, but I''m not sure how to actually use them in my program. This is basically what my Programming RPG in Windows with DirectX tells me to use, where IDB_TITLE is the name I gave to the resource, and it is in under the folder Bitmap.

cpTitle = (char*)LockResource(LoadResource(GethInst(), FindResource(GethInst(), "IDB_TITLE", "Bitmap")));

But now how do I use cpTitle? I tried simply replacing the filename (Data/Title.bmp) with cpTitle, but that did not work. Can anyone tell me how I''m supposed to use cpTitle so that I can load a Texture from it?

- God is my favorite fictional character

Share this post


Link to post
Share on other sites
cpTitle now is a pointer to the content of the bitmap..

normally you would have a function that would load a bitmap from a file like this : (pseudocode)

bool bmp.loadfile (char* filename)
{
f = fopen(filename);
char* buf = new char[filesize];
fread(f,buf);

BITMAPHEADER* bh = (BITMAPHEADER) buf;
//etc...
}

now the cpTitle is the same as buf after you read in the file.

This is just a general way of accessing resources, there is a function that returns a bitmap handle directly given a resource, but i cant remember, since i tend to avoid windows resources due to portability issues

Good luck!

Willem

Share this post


Link to post
Share on other sites
So then would it even be better to load all of my data as resources? What are the pro''s and con''s of using/not using resources then?

- God is my favorite fictional character

Share this post


Link to post
Share on other sites
The bad thing about resources is they all go in the EXE. You might think that is a great thing, but it means if you ever need to release an update, you''d have to include all the resources too (unless you find a really nice exediff tool), so your update will be the same size as the whole game. If you put the data somewhere else (in a seperate file like quake does with .pak files, in a data directory, etc) you can then make an update only updates exactly the parts that need to be updated (usually the exe and maybe a level with a bug in it or somesuch).

When data is seperated, it is much easier to make a demo version or the like (if you want to do it the ''limited content'' way) - you just ship the full exe (with a few minor code changes enclosed in #ifdef type things) and a seperate content package. With resources, you''d need to have 2 seperate projects or something like that to use the same code but include different resources.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!