i'm just starting trying to learn Cg. i put the following code to check for runtime compile errors:
if (!cgIsProgram(vertProgram))
MessageBox(NULL, cgGetErrorString(cgGetError()), "Cg runtime compilation failure", MB_OK|MB_ICONWARNING);
it there a way to get more detailed error information? it just says there was an error but it never gives any clue whats wrong.
thanks
Types of Cg error
Started by MrIdiot, Sep 24 2005 04:27 PM
5 replies to this topic
#1
Posted 24 September 2005 - 04:27 PM
#2
Posted 27 September 2005 - 10:40 AM
am i asking this in the wrong forum or something? surely someone knows the answer?
#3
Posted 27 September 2005 - 12:10 PM
I've never used Cg, but instead use GLSL, however I can tell you that with languages like these, the error reporting is almost always very minimal.
Looking at that code though, It would look like GetErrorString should return a string that is specific to that error no? A quick google search tells me that is what you are supposed to do in order to get the error. I would suggest common debugging techniques for normal code, like reducing the complexity to the smallest program that still wont compile so you can narrow down the search for what you've done wrong.
Looking at that code though, It would look like GetErrorString should return a string that is specific to that error no? A quick google search tells me that is what you are supposed to do in order to get the error. I would suggest common debugging techniques for normal code, like reducing the complexity to the smallest program that still wont compile so you can narrow down the search for what you've done wrong.
Jesse Coyle
#4
Posted 27 September 2005 - 03:19 PM
If you run the Cg compiler from the command prompt and compile your shader, it should output the errors if there are any.
#5
Posted 28 September 2005 - 01:12 PM
ok thanks for your help. NomadRock the GetErrorString function is not very helpful, it just says "the compile returned an error" but doesnt say what the error is. i will try compiling from the command prompt.
#6
Posted 28 September 2005 - 04:40 PM
The error you are getting means that there are syntax errors in your shader. I use this code to get more detailed info on the runtime errors/warnings:
...And then stick this call in your initialization:
// Error callback function for Cg
void __cdecl cgErrorCallback()
{
CGerror err = cgGetError();
if(err == CG_COMPILER_ERROR)
{
printf("*** Cg compiler error:\n%s\n", cgGetLastListing(g_cgContext));
}
else
{
const char* str = cgGetErrorString(err);///cgD3D9TranslateCGerror(err);
printf("%s", str);
HRESULT hres = cgD3D9GetLastError();
if(hres != S_OK)
{
const char* errStr = cgD3D9TranslateHRESULT(hres);
print(" - HRESULT: %s", errStr);
}
printf("\n");
}
}
...And then stick this call in your initialization:
cgSetErrorCallback(&cgErrorCallback);
"Stupid bug! You go squish now!!" - Homer Simpson
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users












