Sign in to follow this  
mlt

How to use HandleCgError?

Recommended Posts

The below function is from the Cg Toolkit 1.4 manual:
void HandleCgError(CGcontext ctx, CGerror err, void *appdata)
{
fprintf(stderr, "Cg error: %s\n", cgGetErrorString(err));
const char *listing = cgGetLastListing(ctx);

if (listing != NULL)
fprintf(stderr, " last listing: %s\n", listing);
}


How and what do I supply as the third argument to HandleCgError? From another function I have tried: void someFun() { CGcontext m_context; m_context = Cg::context(); CGerror error; void* appdata; HandleCgError(m_context, error, appdata); } But then I get a Run-time check failure, saying that appdata is not initialized. I don't quite see that point in appdata since its not even used in HandleCgError.

Share this post


Link to post
Share on other sites
Quote:
Original post by mlt
The below function is from the Cg Toolkit 1.4 manual:

*** Source Snippet Removed ***


How and what do I supply as the third argument to HandleCgError? From another function I have tried:

void someFun() {

CGcontext m_context;
m_context = Cg::context();
CGerror error;
void* appdata;

HandleCgError(m_context, error, appdata);

}

But then I get a Run-time check failure, saying that appdata is not initialized. I don't quite see that point in appdata since its not even used in HandleCgError.
You can put whatever you want there, it's supposed to be used as an "extra" parameter, so you can pass data to your own HandleCgError handler. I'm not familiar with the Cg Toolkit, but usually you'd hand a pointer over to the API which will then get passed in to the error handler in the appdata parameter.
For instance, you could modify the HandleCgError function to fprintf to a FILE* instead of stderr, and pass the file handle to the API in whatever way you do it. Then, whenever there's an error, the HandleCgError function will be called, with the FILE* passed in the appdata parameter.

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