| 41 cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.shader_path), cx_str(filename)); |
41 cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.shader_path), cx_str(filename)); |
| 42 asc_dprintf("Load shader code from %" CX_PRIstr, CX_SFMT(fpath)); |
42 asc_dprintf("Load shader code from %" CX_PRIstr, CX_SFMT(fpath)); |
| 43 FILE *f = fopen(fpath.ptr, "r"); |
43 FILE *f = fopen(fpath.ptr, "r"); |
| 44 cx_strfree(&fpath); |
44 cx_strfree(&fpath); |
| 45 CxBuffer buffer; |
45 CxBuffer buffer; |
| 46 if (f == NULL || cxBufferInit(&buffer, NULL, 1024, cxDefaultAllocator, CX_BUFFER_AUTO_EXTEND)) { |
46 if (f == NULL || cxBufferInit(&buffer, NULL, NULL, 1024, CX_BUFFER_AUTO_EXTEND)) { |
| 47 return NULL; |
47 return NULL; |
| 48 } |
48 } |
| 49 cx_stream_copy(f, &buffer, (cx_read_func) fread, cxBufferWriteFunc); |
49 cx_stream_copy(f, &buffer, (cx_read_func) fread, cxBufferWriteFunc); |
| 50 cxBufferPut(&buffer, '\0'); |
50 cxBufferPut(&buffer, '\0'); |
| 51 cxBufferShrink(&buffer, 0); |
51 cxBufferShrink(&buffer, 0); |