Sign in to follow this  
Weedfin

CG problems

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 this post


Link to post
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

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