Loading pictures in directx (beginner q)

Started by
4 comments, last by Argos 16 years, 8 months ago
[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]
Advertisement
Edited for clarity.
Sorry I was in a rush.
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
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.

------------------------See my games programming site at: www.toymaker.info
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]
Last post edited(Decided not to make another topic because this was posted yesterday).
Thanks

This topic is closed to new replies.

Advertisement