Advertisement

URGENT--VC++ Compiler ?'s--URGENT

Started by June 11, 2002 04:35 PM
2 comments, last by US101 22 years, 5 months ago
I have a VC++ 6.0 application that uses sounds and graphics. I want the sound and Graphics to become part of the exe, so that You only need the .exe to play game. I know that I must use resources, but I am new to VC++ and am stuck. I have got the sounds to work, but my graphic class expects a graphic filename. I have added my Graphics to the script, but how do I tell a class a filename of a resource graphic??? I may be doing all of this wrong so please let me know. Thanks US101
Ok you said the your graphics class expects a filename, when you mean "class" I assume you mean C++ class. If so then just have antother constructor that allows the class to be created from a resource i.e.


class CImage{// creates a graphic from a fileCImage(char* Filename);// create a graphic from a resourceCImage(long ResourceID);// rest of class ignored...



then when you create an instande you could do:


CImage* my_graphic = new CImage(ID_GRAPHIC_BULLET);


or whatever the resource id is.


For more information on the actual use of resource files read the msdn help files.
Advertisement
thats kinda it. I have my app. I have another C++ class that someone else made. I call LoadGraphic(). LoadGraphic expects a Graphic objetc, also made by the same person, and a filename.

Ex.

GObject img1;

class.LoadGraphic(img1, "image1.bmp");

This basically stores image1.bmp and puts in img1. Then I can do class.DrawGraphic(img1, 0, 0); etc...

But, I want all of my images to be placed into the exe, so how do I pass a file name? If I try MAKEINTRESOURCE(image1). then the compiler does not comlain, but when I rn, it says that an access violation has occured and then VC++ asks where is STRCAT.asm file???????

US101
You can''t feed a resource to a code that expects a file, because file opening functions won''t open a resource. You have three options:

1. If you have the source code, add another constructor to the image class that loads stuff from resources.

2. Create a temporary file, copy the resource in it, and feed this file to existing image class constructor.

3. Load the image yourself and provide the class with bitmap data. This may require a hack (ie, writing private data members outside the class).

And there''s need to scream URGENT twice in the subject line. I doubt that you''ll get more/faster replies by doing so.
---visit #directxdev on afternet <- not just for directx, despite the name

This topic is closed to new replies.

Advertisement