Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add gl_cg_save_cgp().

  • Loading branch information...
commit 315b28862a771e186146684ab12faf3e662a118b 1 parent f6edb9a
Hans-Kristian Arntzen authored

Showing 2 changed files with 39 additions and 0 deletions. Show diff stats Hide diff stats

  1. +29 0 gfx/shader_cg.c
  2. +10 0 gfx/shader_cg.h
29 gfx/shader_cg.c
@@ -1199,3 +1199,32 @@ bool gl_cg_load_shader(unsigned index, const char *path)
1199 1199 }
1200 1200 }
1201 1201
  1202 +bool gl_cg_save_cgp(const char *path, const struct gl_cg_cgp_info *info)
  1203 +{
  1204 + if (!info->shader[0] || !*info->shader[0])
  1205 + return false;
  1206 +
  1207 + FILE *file = fopen(path, "w");
  1208 + if (!file)
  1209 + return false;
  1210 +
  1211 + unsigned shaders = info->shader[1] && *info->shader[1] ? 2 : 1;
  1212 + fprintf(file, "shaders = %u\n", shaders);
  1213 +
  1214 + fprintf(file, "shader0 = %s\n", info->shader[0]);
  1215 + if (shaders == 2)
  1216 + fprintf(file, "shader1 = %s\n", info->shader[1]);
  1217 +
  1218 + fprintf(file, "filter_linear0 = %s\n", info->filter_linear[0] ? "true" : "false");
  1219 +
  1220 + if (info->render_to_texture)
  1221 + {
  1222 + fprintf(file, "filter_linear1 = %s\n", info->filter_linear[1] ? "true" : "false");
  1223 + fprintf(file, "scale_type0 = source\n");
  1224 + fprintf(file, "scale0 = %.1f\n", info->fbo_scale);
  1225 + }
  1226 +
  1227 + fclose(file);
  1228 + return true;
  1229 +}
  1230 +
10 gfx/shader_cg.h
@@ -54,4 +54,14 @@ void gl_cg_set_compiler_args(const char **argv);
54 54
55 55 bool gl_cg_load_shader(unsigned index, const char *path);
56 56
  57 +struct gl_cg_cgp_info
  58 +{
  59 + const char *shader[2];
  60 + bool filter_linear[2];
  61 + bool render_to_texture;
  62 + float fbo_scale;
  63 +};
  64 +
  65 +bool gl_cg_save_cgp(const char *path, const struct gl_cg_cgp_info *info);
  66 +
57 67 #endif

0 comments on commit 315b288

Please sign in to comment.
Something went wrong with that request. Please try again.