How do I get a Compile error from NVIDIA CG?
How do I get detailed errors from a cg compile?
At the moment my code is something like:
prog = cgCreateProgramFromFile(
开发者_运维技巧 context,
CG_SOURCE,
filename,
proifile,
null,null);
std::cout << cgGetErrorString(cgGetError());
But all I get is "The compile returned an error."
Is there any way to get a more involved error message, like glGetShaderiv with GL_COMPILE_STATUS for opengl shaders?
Can't find anything in the reference but is seems like a fairly basic requirement.
I am running cgc on the shaders first with no code generation to check for errors but that doesn't catch everything.
Thanks.
In the case of a compile error, you must use cgGetLastListing(CGcontext) instead of cgGetError(void).
From the Cg documentation for cgGetLastListing(CGcontext):
Each Cg context maintains a NULL-terminated string containing warning and error messages generated by the Cg compiler, state managers and the like. cgGetLastListing allows applications and custom state managers to query the listing text.
cgGetLastListing returns the currrent listing string for the given CGcontext. When a Cg runtime error occurs, applications can use the listing text from the appropriate context to provide the user with detailed information about the error.
精彩评论