]> de.git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix shader name in "permutation%s failed for shader %s, some features may not work...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 29 Jun 2007 07:46:15 +0000 (07:46 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Fri, 29 Jun 2007 07:46:15 +0000 (07:46 +0000)
new command r_glsl_dumpshader that dumps the engine builtin default.glsl file to glsl/default.glsl for editing and trying out stuff

git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7456 d7cf8633-e32d-0410-b094-e92efae38249

gl_rmain.c

index c0bc61c3cb517fa47df34f7948a4a6e5aac1abe2..d0f51bf00991376b9816d7427599a86d6e74a33a 100644 (file)
@@ -807,7 +807,7 @@ void R_GLSL_CompilePermutation(const char *filename, int permutation)
                qglUseProgramObjectARB(0);CHECKGLERROR
        }
        else
-               Con_Printf("permutation%s failed for shader %s, some features may not work properly!\n", permutationname, "glsl/default.glsl");
+               Con_Printf("permutation%s failed for shader %s, some features may not work properly!\n", permutationname, filename);
        if (shaderstring)
                Mem_Free(shaderstring);
 }
@@ -821,6 +821,27 @@ void R_GLSL_Restart_f(void)
        memset(r_glsl_permutations, 0, sizeof(r_glsl_permutations));
 }
 
+void R_GLSL_DumpShader_f(void)
+{
+       int i;
+
+       qfile_t *file = FS_Open("glsl/default.glsl", "w", false, false);
+       if(!file)
+       {
+               Con_Printf("failed to write to glsl/default.glsl\n");
+               return;
+       }
+
+       FS_Print(file, "// #define VERTEX_SHADER GEOMETRY_SHADER FRAGMENT_SHADER\n");
+       for (i = 0;permutationinfo[i][0];i++)
+               FS_Printf(file, "// %s", permutationinfo[i][0]);
+       FS_Print(file, "\n");
+       FS_Print(file, builtinshaderstring);
+       FS_Close(file);
+
+       Con_Printf("data/default.glsl written");
+}
+
 extern rtexture_t *r_shadow_attenuationgradienttexture;
 extern rtexture_t *r_shadow_attenuation2dtexture;
 extern rtexture_t *r_shadow_attenuation3dtexture;
@@ -1490,6 +1511,7 @@ void GL_Main_Init(void)
        r_main_mempool = Mem_AllocPool("Renderer", 0, NULL);
 
        Cmd_AddCommand("r_glsl_restart", R_GLSL_Restart_f, "unloads GLSL shaders, they will then be reloaded as needed");
+       Cmd_AddCommand("r_glsl_dumpshader", R_GLSL_DumpShader_f, "dumps the engine internal default.glsl shader into glsl/default.glsl");
        // FIXME: the client should set up r_refdef.fog stuff including the fogmasktable
        if (gamemode == GAME_NEHAHRA)
        {