Sign in to follow this  
guyaton

Custom .X files

Recommended Posts

i'm trying to create my own .X files, but I am running into a huge problem. In my header file, I have this: #ifndef CustomXTemplates_h #define CustomXTemplates_h // {69F85A3E-BA22-4dc8-90F2-038F4D0D1F60} DEFINE_GUID(NickStringTest, 0x69f85a3e, 0xba22, 0x4dc8, 0x90, 0xf2, 0x3, 0x8f, 0x4d, 0xd, 0x1f, 0x60); char NickTest[] = "xof 0303txt 0032 template test { <69F85A3E-BA22-4dc8-90F2-038F4D0D1F60> STRING name; } "; #endif I include that in my .Cpp file, but when I try to use NickStringTest, I get a linking error. LNK2001 saying that NickStringTest is an unresolved external. I looked in the Microsoft source, and couldn't find anything different they were doing (RMXFGUID.H} thanks for the help!

Share this post


Link to post
Share on other sites
Continuing this post, this is the code I use to load the .X file. when I try reading the Data of the string, no matter how long the string is, the length is always 4 bytes and the varible "array" is never filled with the string. Any ideas why?

LPDIRECTXFILE pDXFile = NULL;
LPDIRECTXFILEENUMOBJECT pDXEnum = NULL;
LPDIRECTXFILEDATA pDXData = NULL;
DirectXFileCreate( &pDXFile );

hr = pDXFile->RegisterTemplates( (LPVOID)NickTest, strlen(NickTest) );


if( FAILED( hr = pDXFile->CreateEnumObject( (LPVOID)"myX.x", DXFILELOAD_FROMFILE, &pDXEnum ) ) )
{
SAFE_RELEASE( pDXFile );
return hr;
}

//Loop through all Top level objects breaking only on errors
while( SUCCEEDED( pDXEnum->GetNextDataObject( &pDXData ) ) )
{
CXFileParser test;
const GUID *id = test.GetObjectGUID(pDXData);

if( *id == GUID_NickStringTest )
{
DWORD size = 0;
char *array = NULL;
hr = pDXData->GetData( NULL, &size, (void**)&array );



}
}

Share this post


Link to post
Share on other sites
IIRC, strings are stored as addresses, not actual string data. So you need to pass in an integer and then the value of the address with be returned:


DWORD size = 0;
DWORD* address = 0;
hr = pDXData->GetData( NULL, &size, (void**)&address );

char* str = (char*)(*address);

Share this post


Link to post
Share on other sites

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