
Wed, 05/19/2010 - 14:03
Hi everyone,
whata happen if the filename passed to SetTextureFileName in not a valid name ? Follwing my code :
aTShape->SetTextureFileName((Standard_CString)(LPCTSTR)sInitFile);
aTShape->SetTextureMapOn();
aTShape->SetTextureScale(Standard_True, toScaleU, toScaleV);
aTShape->SetTextureRepeat(Standard_True, toRepeatU, toRepeatV);
aTShape->SetTextureOrigin(Standard_True, originU, originV);
aTShape->SetDisplayMode(3); // mode 3 is "textured" mode
Standard_Boolean bNull=aTShape.IsNull();
Every thing sems to be ok but if sInitFile is not a valid filename the subsequent m_3DContext->Display( aTShape) fail and the application assert.
Is there any way to detect this situation ? Every SetTexture...method has void return.
Thank you in advance.
Ezio Endrigo
Wed, 05/19/2010 - 17:07
A primitve solution would be to try to open the sInitFile to check if it exists
FILE *test;
test := fopen(sInitFile, "r");
if(test == NULL)
{
//habdle error
}
else
{
fclose(test)
}
Wed, 05/19/2010 - 18:37
Hello Ezio,
You should make sure that you provide a valid file like Tilman Leune says.
MFC way, since you are doing that if I am correct.
BOOL IsValidFile(LPCTSTR lpszFileName)
{
CFileStatus fs;
return CFile::GetStatus(lpszFileName, fs);
}
Regards,
Arjan.
Thu, 05/20/2010 - 01:45
Thankyou Arjan,
I've already done as you suggest. I'd like to know if there were another way.
Thanks so much.
Ezio