# CG problems

This topic is 3253 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi, I am getting CG errors "The file could not be read." when I'm loading my vertex program from file (cgCreateProgramFromFile). It typically loads OK when I first start debugging the program from the IDE (VC6), however if I try to reload it during that same debug session, it generates the error. To get it to work again, I need to stop the program, open the .cg file in another editor and save it, then start the program again. Sometimes even this doesn't work, and I need to log out and back in. It's not a current directory problem, I've even specified the full path when loading. It seems like the cgCreateProgramFromFile function doesn't close the file properly? I make sure to call cgDestroyProgram(myCgVertexProgram) before I try to reload, but that doesn't work either. Any ideas? Thanks, Weedfin

##### Share on other sites
Never mind, it was a current directory problem! There was a complex sequence of events to reproduce the problem, but suffice it to say, calls to MS common dialogs change the current directory.

To atone for my sins, some handy code to get the current executable folder, where my .cg files are stored:

    char szPath[256 ], szAppDirectory[256];    GetModuleFileName( NULL, szPath, 256 );    int size = strrchr(szPath, '\\') - szPath + 1;    strncpy(szAppDirectory, szPath, size );    szAppDirectory[size ] = '\0';    sprintf(szPath, "%s%s", szAppDirectory, myVertexProgramFileName);

Thanks,
Weedfin

• 10
• 10
• 9
• 48
• 12
• ### Forum Statistics

• Total Topics
631388
• Total Posts
2999715
×