Jump to content
  • Advertisement
Sign in to follow this  
DeepPurple

Hi everybody!

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

Hey whats up guys?! new guy in the community. I really need help with a DirectX program I am trying to run. It's actually an example out of J. Harbour's Beginnign Game Programming book that I've typed out myself and edited a bit for debugging purpouses. I have this peace of code in the program: result = D3DXGetImageInfoFromFile(filename, &info); if (result != D3D_OK) { MessageBox(hwnd, "Return NULL - Function 'D3DXGetImageInfoFromFile ()' ", "Error", MB_OK); return NULL; } and what happens is that I DO get this Message Box and the whole window then closes. What I suspect is that it may not be reading the "filename" correctly from this loop: for (n=0; n<6; n++) { sprintf(s,"cat%d.bmp",n+1); kitty_image[n] = LoadSurface(s, D3DCOLOR_XRGB(255,0,255), hwnd); if (kitty_image[n] == NULL) return 0; } although, I dont see why not. By the way, I have all the bmp files stored in the debug directory, and have them added to the "Resource Files" folder. Any help will be really appreciated, and thanks.

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by DeepPurple
By the way, I have all the bmp files stored in the debug directory, and have them added to the "Resource Files" folder.


This happens to me all the time. I usually solve it by moving the bmp files into the root directory of the project, where the solution file is. In Visual Studio I then go to debugging options and set the working directory to $(SolutionDir). But first, make sure that the files you are opening actually exist. Change the

MessageBox(hwnd, "Return NULL - Function 'D3DXGetImageInfoFromFile ()' ", "Error", MB_OK);

to

MessageBox(hwnd, filename, "Return NULL - Function 'D3DXGetImageInfoFromFile ()' ", MB_OK);

Share this post


Link to post
Share on other sites
By default, if you run the program in VS, you should put your resource files same as project folder, and if you run it in "My Computer", then put those files into application folder where your .exe file is.

BTW: You can change that path sets in Project Options.

Share this post


Link to post
Share on other sites
Well I changed the MessageBox() line, and it does print out the name of the file. How do I access the dubugging options? cant find it. And Im not too sure about changing the path; all the bmp files are in the same folder as the *.exe file.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!