Fix bug with not showing compiler errors when custom profile is selected

This commit is contained in:
rdb 2009-04-18 14:45:52 +00:00
parent 58b1d67a92
commit 10ab4cc8b9

View File

@ -1056,11 +1056,22 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, bool fshader)
if (override != (int)CG_PROFILE_UNKNOWN) {
prog = cgCreateProgram(_cg_context, CG_SOURCE, _text.c_str(),
(CGprofile)override, entry, (const char **)compiler_args);
if (cgGetError() == CG_NO_ERROR) {
err = cgGetError();
if (err == CG_NO_ERROR) {
return prog;
}
if (prog != 0) {
cgDestroyProgram(prog);
if (err == CG_COMPILER_ERROR) {
string listing = cgGetLastListing(_cg_context);
vector_string errlines;
tokenize(listing, errlines, "\n");
for (int i=0; i<(int)errlines.size(); i++) {
string line = trim(errlines[i]);
if (line != "") {
gobj_cat.error() << get_filename() << ": " << errlines[i] << "\n";
}
}
} else {
gobj_cat.error() << get_filename() << ": " << cgGetErrorString(err) << "\n";
}
if (fshader) {
gobj_cat.error() << "Fragment shader failed to compile with profile '"
@ -1069,6 +1080,9 @@ cg_compile_entry_point(const char *entry, const ShaderCaps &caps, bool fshader)
gobj_cat.error() << "Vertex shader failed to compile with profile '"
<< cgGetProfileString((CGprofile)override) << "'!\n";
}
if (prog != 0) {
cgDestroyProgram(prog);
}
return 0;
}