gpu.c (1079B)
1 2 #include "gpu.h" 3 #include <stdio.h> 4 5 int try_reload_shaders(struct gpu *gpu) { 6 int ret = 0; 7 for (int i = 0; i < gpu->num_programs; ++i) { 8 struct gpu_program *program = &gpu->programs[i]; 9 ret = reload_program(program, gpu->programs); 10 11 if (ret == 2) {} 12 else if (ret == 1) 13 printf("reload %s success.\n", program->shaders[0].filename); 14 else 15 printf("reload %s failed.\n", program->shaders[0].filename); 16 17 // failure ok, clear any errors 18 glGetError(); 19 } 20 21 return ret; 22 } 23 24 struct gpu_program *get_gpu_program_by_name(struct gpu *gpu, const char *name) 25 { 26 int i; 27 struct gpu_program *program; 28 29 printf("num_programs %d\n", gpu->num_programs); 30 31 for (i = 0; i < gpu->num_programs; i++) { 32 program = &gpu->programs[i]; 33 if (!strcmp(program->name, name)) 34 return program; 35 } 36 37 return NULL; 38 } 39 40 41 struct gpu_program *new_gpu_program(struct gpu *gpu, const char *name) 42 { 43 assert(gpu->num_programs + 1 < MAX_GPU_PROGRAMS); 44 45 int id = gpu->num_programs++; 46 struct gpu_program *program = &gpu->programs[id]; 47 48 program->id = id; 49 program->name = name; 50 51 return program; 52 }