Skip to main content
gamedev.net
🔒 Locked

Problem loading .x files

Started by Brobanx 1 reply 200+ views
Original Post
Brobanx
Brobanx
I''m loading a .x file into my program, and the following code gives me an access violation during the dxFData->GetType(&guidDataType) call. I''ve tried changing it around a lot and I''m not sure why guidDataType is corrupt and unusable in the function. Anyone who knows about this sorta stuff, I''d appreciate any help I can get.
  
	IDirectXFile *dxF;
	if ( DXFILE_OK != DirectXFileCreate(&dxF) )
		return ERR_BADFILE;

	IDirectXFileEnumObject *dxFEnumObject;

	if ( DXFILE_OK != dxF->CreateEnumObject(strFilename, DXFILELOAD_FROMFILE, 
			&dxFEnumObject) )
		return ERR_BADFILE;

	HRESULT hr;
	IDirectXFileData *dxFData;
	while(1) {
		hr = dxFEnumObject->GetNextDataObject(&dxFData);
		if ( hr == DXFILEERR_NOMOREOBJECTS )
			break;

		else if ( hr == DXFILEERR_BADVALUE ) {
			break; return ERR_BADFILE;

		} else {
			const GUID *guidDataType;
			if ( DXFILE_OK  != dxFData->GetType(&guidDataType) ) {
				break; return ERR_BADFILE;
			}
		}
	}
  
Brobanx
Brobanx
Ok, it turns out that the call to GetNextDataObject is not succeeding, so I changed the code a bit to handle that, but now I have to figure out WHY that function is not working, it''s VERY strange, because the DX docs say it can only return DXFILE_OK, DXFILEERR_NOMOREOBJECTS, and DXFILEERR_BADVALUE, but the call to GetNextDataObject is returning NEITHER of these values!!!

  
//////////////////////////////////////////////////////////

// load the data from the X file, return with any errors.

if ( DXFILE_OK != DirectXFileCreate(&dxF) )
return ERR_BADFILE;

if ( DXFILE_OK != dxF->CreateEnumObject(strFilename, DXFILELOAD_FROMFILE,
&dxFEnumObject) )
return ERR_BADFILE;

while(1) {
hr = dxFEnumObject->GetNextDataObject(&dxFData);
if ( SUCCEEDED(hr) ) {
if ( DXFILE_OK != dxFData->GetType(&guidDataType) )
return ERR_BADFILE;
} else {
if ( hr == DXFILEERR_NOMOREOBJECTS )
break;
else return ERR_BADFILE;
}
}

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.