crash when trying to load mesh from .x

Started by
34 comments, last by craksy 15 years, 10 months ago
Original post by Buckeye
If you use it, you'll need to include dxerr.lib in your links...quote]
how exactly do i do that? *blush*
is it in the project proberties>linker> additional libary directories?
and if, should i just type in "dxerr.lib" ? *even more blush*

Thanks :D
Advertisement
No need to blush; we're all learning here.

I'm not sure what interface you're using but try something like:

project properties->linker->input->additional dependencies.

It can't be just a directory. It must be a library.

Oh! I think you can include
#pragma comment(lib,"dxerr.lib").

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

for some reason all the lib, and include directories have been deleted from visual studio :S
anyway should i just put in "#pragma comment (lib,"dxerr.lib")" or should i put it in AND include it in the linker thingy?

[Edited by - craksy on May 30, 2008 10:51:52 AM]
I've never used the #pragma libary technique myself. However, it certainly doesn't seem necessary to do both. Just one or the other.

You do need to have the

#include "dxerr.h"

line in any file that calls DXGetErrorDescription.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

Quote:No need to blush; we're all learning here.

i dont really care right now:
for(i=0;i<1000000000;i++){
*blush*
}
just not to spam the post with *blush* -_-

anyway: "File not found"
that means that i messed up with the folders where i put the .x file, right?

Quote:"File not found"

Yeah, it looks that way.

Locating resource files can be a little painful, particularly since the path may change when you switch from Debug exe to Release exe.

Suggestion:

Declare a global variable "char appPath[MAX_PATH];" or something similar. In your initialization, call getcwd, look for the root folder of your application in that string and copy it to appPath.

Put resource files in the same location, such as "[appPath]/resources" or similar. Whenever you want to load a file, create a string from appPath and append the resource filename. That way the path will be correct whether you're in Debug or Release.

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

ok that was a hard one to understand!
could you, from the code posted in my first post, make me an example code to put in?
if so, i would be very greatful!

Thanks xD
// global variables declared probably in your main cpp filechar appPath[MAX_PATH];char texturePath[MAX_PATH];//... somewhere in your initialization in the main cpp file	int pos;        char    *appName = "YourAppFolderName"; // like "MyApp", NOT "MyApp/Debug"	// find the texture directory	GetCurrentDirectory(MAX_PATH,texturePath);	pos = (int)strlen(texturePath);	while( true ) { // work backwards until appName found		// find first '\' from end		while( texturePath[pos] != '\\' && pos > 0 ) pos--;		if( pos==0 ) break;		pos++;		if( strnicmp(&texturePath[pos],appName,strlen(appName)) == 0 ) { // found it			texturePath[pos+strlen(appName)] = 0;			strcat(strcpy(appPath,texturePath),"\\");			strcat(texturePath,"\\textures\\");			break;		} else {			pos--;			pos--;		}	}

That's for a texture directory but you can substitute a resource folder name, etc.

Then, when you go to load a resource file located in the folder MyApp\textures:
char path[MAX_PATH];strcat(strcpy(path,texturePath),"someResource.jpg");LoadSomeResource(path);

If your resource loading is not done in the same file in which you declare "texturePath," then, near the top of the file add
extern char texturePath[];

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

so i should add the file in the project folder?
as far as i understanded from the tutorial i read, it was enough to add it to the solution explorer!
so my project is named "DirectX" so i should add a folder inside that one named "textures" ?

so i would get something like

// global variables declared probably in your main cpp filechar appPath[MAX_PATH];char texturePath[MAX_PATH];//... somewhere in your initialization in the main cpp file	int pos;        char    *appName = "DirextX"; // like "MyApp", NOT "MyApp/Debug"	// find the texture directory	GetCurrentDirectory(MAX_PATH,texturePath);	pos = (int)strlen(texturePath);	while( true ) { // work backwards until appName found		// find first '\' from end		while( texturePath[pos] != '\\' && pos > 0 ) pos--;		if( pos==0 ) break;		pos++;		if( strnicmp(&texturePath[pos],appName,strlen(appName)) == 0 ) { // found it			texturePath[pos+strlen(appName)] = 0;			strcat(strcpy(appPath,texturePath),"\\");			strcat(texturePath,"\\textures\\");			break;		} else {			pos--;			pos--;		}	}

??

and the same for meshes?
If you want to keep your resource files (jpegs, fx files, etc.) in your project folder, that's okay. I just keep stuff like that in separate folders to keep the clutter down. That's up to you. It's certainly not a requirement.

If you want to keep files in your Windows project folder, then just setup the "appPath" variable and use that. Just make sure the needed files are in the correct Windows folder - like c:/projects/directx - if that's where your project files are. In that case, char *appName = "directx";

You can set a breakpoint after that code and check that appPath = "c:\projects\directx\"

Then you can use it like so:
HRESULT hr;char path[MAX_PATH];strcat(strcpy(path,appPath),"resourcefile.x");hr = D3DXLoadMeshFromX(path,...);if( FAILED(hr) ) ...

Please don't PM me with questions. Post them in the forums for everyone's benefit, and I can embarrass myself publicly.

You don't forget how to play when you grow old; you grow old when you forget how to play.

This topic is closed to new replies.

Advertisement