Sign in to follow this  

Loading pictures in directx (beginner q)

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

[Edited so its easier to understand] I am learning directx and I have ran into a problem. It involves loading images to my project. Specifically this one project. The author of the tutorial didn't put everything in and simply putting it in the source file doesn't work. Here is the code snippet for loading the image HR(D3DXCreateTextureFromFile(gd3dDevice, "bullet.bmp", &mBulletTex)); where does the .bmp file have to be for it to load and what needs to be done? Thanks ps: Directx was installed properly. [Edited by - Argos on August 14, 2007 10:02:15 AM]

Share this post


Link to post
Share on other sites
It needs to be in the projects working directory when you are debugging from Visual Studio, if you are running the application you have built outside of VS then it's somewhere different, i forget exactly where.

Dave

Share this post


Link to post
Share on other sites
If you are running it from the IDE the current (or working) directory is set to the directory containing the project file (for visual studio). If you are running the exe directly the current directory is the directory of the exe.

In Windows you can get and change the currentdirectory if required using

char buf[MAX_PATH];
GetCurrentDirectory(MAX_PATH,buf);

and can set it using SetCurrentDirectory

BTW you can also find out where other directories are on the machine using ShGetFolderPath (or ShGetKnownFolderPath on Vista) e.g. you could get the directory where app data should be held.

Share this post


Link to post
Share on other sites
Thanks guys, I added the 3 .bmp files in the main project folder that my project linked to and it works fine.


On a side not about directX.

Is it worth learning. I got to the point where I can add basic images and use input to make them move but I see a lot of people saying XNA is the future and is easier to use (Looking at the sample code it looks much smaller). I know I cant use c++ with xna, but is directX with c++ still worth using?

thanks

[Edited by - Argos on August 14, 2007 1:31:15 PM]

Share this post


Link to post
Share on other sites

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