Mercurial > repos > blastem
comparison render_sdl.c @ 1693:ba3fb7a3be6b
Added some Makefile options to build a packaging friendly executable
author | Michael Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 22 Jan 2019 21:15:38 -0800 |
parents | 475e84bfccbb |
children | 52a47611a273 |
comparison
equal
deleted
inserted
replaced
1691:e96d0d3bec7f | 1693:ba3fb7a3be6b |
---|---|
11 #include "render_sdl.h" | 11 #include "render_sdl.h" |
12 #include "blastem.h" | 12 #include "blastem.h" |
13 #include "genesis.h" | 13 #include "genesis.h" |
14 #include "bindings.h" | 14 #include "bindings.h" |
15 #include "util.h" | 15 #include "util.h" |
16 #include "paths.h" | |
16 #include "ppm.h" | 17 #include "ppm.h" |
17 #include "png.h" | 18 #include "png.h" |
18 #include "config.h" | 19 #include "config.h" |
19 #include "controller_info.h" | 20 #include "controller_info.h" |
20 | 21 |
487 { | 488 { |
488 char const * parts[] = {get_home_dir(), "/.config/blastem/shaders/", fname}; | 489 char const * parts[] = {get_home_dir(), "/.config/blastem/shaders/", fname}; |
489 char * shader_path = alloc_concat_m(3, parts); | 490 char * shader_path = alloc_concat_m(3, parts); |
490 FILE * f = fopen(shader_path, "rb"); | 491 FILE * f = fopen(shader_path, "rb"); |
491 free(shader_path); | 492 free(shader_path); |
492 if (!f) { | 493 GLchar * text; |
493 parts[0] = get_exe_dir(); | 494 long fsize; |
494 parts[1] = "/shaders/"; | 495 if (f) { |
495 shader_path = alloc_concat_m(3, parts); | 496 fsize = file_size(f); |
496 f = fopen(shader_path, "rb"); | 497 text = malloc(fsize); |
498 if (fread(text, 1, fsize, f) != fsize) { | |
499 warning("Error reading from shader file %s\n", fname); | |
500 free(text); | |
501 return 0; | |
502 } | |
503 } else { | |
504 shader_path = path_append("shaders", fname); | |
505 uint32_t fsize32; | |
506 text = read_bundled_file(shader_path, &fsize32); | |
497 free(shader_path); | 507 free(shader_path); |
498 if (!f) { | 508 if (!text) { |
499 warning("Failed to open shader file %s for reading\n", fname); | 509 warning("Failed to open shader file %s for reading\n", fname); |
500 return 0; | 510 return 0; |
501 } | 511 } |
502 } | 512 fsize = fsize32; |
503 long fsize = file_size(f); | 513 } |
504 GLchar * text = malloc(fsize); | 514 |
505 if (fread(text, 1, fsize, f) != fsize) { | |
506 warning("Error reading from shader file %s\n", fname); | |
507 free(text); | |
508 return 0; | |
509 } | |
510 if (strncmp(text, "#version", strlen("#version"))) { | 515 if (strncmp(text, "#version", strlen("#version"))) { |
511 GLchar *tmp = text; | 516 GLchar *tmp = text; |
512 text = alloc_concat(shader_prefix, tmp); | 517 text = alloc_concat(shader_prefix, tmp); |
513 free(tmp); | 518 free(tmp); |
514 fsize += strlen(shader_prefix); | 519 fsize += strlen(shader_prefix); |