SetTextureFileName and invalid texture file name

Hi everyone,

whata happen if the filename passed to SetTextureFileName in not a valid name ? Follwing my code :

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

Tilman Leune's picture

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

Arjan Schouten's picture

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);



ezio.endrigo's picture

Thankyou Arjan,

I've already done as you suggest. I'd like to know if there were another way.

Thanks so much.