| 133 if (asc_has_error()) { |
133 if (asc_has_error()) { |
| 134 asc_shader_free_codes(codes); |
134 asc_shader_free_codes(codes); |
| 135 return 1; |
135 return 1; |
| 136 } |
136 } |
| 137 sprite->depth = glGetUniformLocation(sprite->program.id, "depth"); |
137 sprite->depth = glGetUniformLocation(sprite->program.id, "depth"); |
| 138 sprite->tex = glGetUniformLocation(sprite->program.id, "texture"); |
138 sprite->rect_tex = glGetUniformLocation(sprite->program.id, "rect_tex"); |
| |
139 sprite->uv_tex = glGetUniformLocation(sprite->program.id, "uv_tex"); |
| 139 asc_shader_free_codes(codes); |
140 asc_shader_free_codes(codes); |
| 140 return 0; |
141 return 0; |
| 141 } |
142 } |
| 142 |
143 |
| 143 AscShaderProgram asc_shader_program_create(AscShaderCodes codes) { |
144 AscShaderProgram asc_shader_program_create(AscShaderCodes codes) { |
| 160 if (filename == NULL) { |
161 if (filename == NULL) { |
| 161 *code = NULL; |
162 *code = NULL; |
| 162 return 0; |
163 return 0; |
| 163 } |
164 } |
| 164 cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.shader_path), cx_str(filename)); |
165 cxmutstr fpath = asc_filesystem_combine_paths(cx_strcast(asc_context.shader_path), cx_str(filename)); |
| |
166 asc_dprintf("Load shader code from %" CX_PRIstr, CX_SFMT(fpath)); |
| 165 FILE *f = fopen(fpath.ptr, "r"); |
167 FILE *f = fopen(fpath.ptr, "r"); |
| 166 cx_strfree(&fpath); |
168 cx_strfree(&fpath); |
| 167 if (f == NULL) return -1; |
169 if (f == NULL) return -1; |
| 168 CxBuffer buffer; |
170 CxBuffer buffer; |
| 169 cxBufferInit(&buffer, NULL, 1024, NULL, CX_BUFFER_AUTO_EXTEND); |
171 cxBufferInit(&buffer, NULL, 1024, NULL, CX_BUFFER_AUTO_EXTEND); |