Browse Source

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

rdb 16 years ago
parent
commit
10ab4cc8b9
1 changed files with 17 additions and 3 deletions
  1. 17 3
      panda/src/gobj/shader.cxx

+ 17 - 3
panda/src/gobj/shader.cxx

@@ -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;
   }