Permalink
Browse files

Add gl_cg_save_cgp().

  • Loading branch information...
1 parent f6edb9a commit 315b28862a771e186146684ab12faf3e662a118b @Themaister committed Feb 8, 2012
Showing with 39 additions and 0 deletions.
  1. +29 −0 gfx/shader_cg.c
  2. +10 −0 gfx/shader_cg.h
View
@@ -1199,3 +1199,32 @@ bool gl_cg_load_shader(unsigned index, const char *path)
}
}
+bool gl_cg_save_cgp(const char *path, const struct gl_cg_cgp_info *info)
+{
+ if (!info->shader[0] || !*info->shader[0])
+ return false;
+
+ FILE *file = fopen(path, "w");
+ if (!file)
+ return false;
+
+ unsigned shaders = info->shader[1] && *info->shader[1] ? 2 : 1;
+ fprintf(file, "shaders = %u\n", shaders);
+
+ fprintf(file, "shader0 = %s\n", info->shader[0]);
+ if (shaders == 2)
+ fprintf(file, "shader1 = %s\n", info->shader[1]);
+
+ fprintf(file, "filter_linear0 = %s\n", info->filter_linear[0] ? "true" : "false");
+
+ if (info->render_to_texture)
+ {
+ fprintf(file, "filter_linear1 = %s\n", info->filter_linear[1] ? "true" : "false");
+ fprintf(file, "scale_type0 = source\n");
+ fprintf(file, "scale0 = %.1f\n", info->fbo_scale);
+ }
+
+ fclose(file);
+ return true;
+}
+
View
@@ -54,4 +54,14 @@ void gl_cg_set_compiler_args(const char **argv);
bool gl_cg_load_shader(unsigned index, const char *path);
+struct gl_cg_cgp_info
+{
+ const char *shader[2];
+ bool filter_linear[2];
+ bool render_to_texture;
+ float fbo_scale;
+};
+
+bool gl_cg_save_cgp(const char *path, const struct gl_cg_cgp_info *info);
+
#endif

0 comments on commit 315b288

Please sign in to comment.