108 free(log); |
108 free(log); |
109 return (AscShaderProgram) {0}; |
109 return (AscShaderProgram) {0}; |
110 } |
110 } |
111 } |
111 } |
112 |
112 |
113 void asc_shader_program_destroy(AscShaderProgram program) { |
113 void asc_shader_program_destroy(AscShaderProgram *program) { |
114 if (program.id > 0) { |
114 if (program->id > 0) { |
115 asc_dprintf("Delete Shader Program %u", program.id); |
115 asc_dprintf("Delete Shader Program %u", program->id); |
116 glDeleteProgram(program.id); |
116 glDeleteProgram(program->id); |
117 } |
117 } |
118 program.id = 0; |
118 program->id = 0; |
|
119 } |
|
120 |
|
121 int asc_shader_sprite_init(AscShaderSprite *sprite) { |
|
122 AscShaderCodes codes; |
|
123 if (asc_shader_load_code_files((AscShaderCodeFiles){ |
|
124 .vtx = "./shader/sprite_vtx.glsl", |
|
125 .frag = "./shader/sprite_frag.glsl" |
|
126 }, &codes)) { |
|
127 asc_error("Loading sprite shader failed."); |
|
128 return 1; |
|
129 } |
|
130 sprite->program = asc_shader_program_create(codes); |
|
131 if (asc_has_error()) { |
|
132 asc_shader_free_codes(codes); |
|
133 return 1; |
|
134 } |
|
135 sprite->depth = glGetUniformLocation(sprite->program.id, "depth"); |
|
136 sprite->tex = glGetUniformLocation(sprite->program.id, "texture"); |
|
137 asc_shader_free_codes(codes); |
|
138 return 0; |
119 } |
139 } |
120 |
140 |
121 AscShaderProgram asc_shader_program_create(AscShaderCodes codes) { |
141 AscShaderProgram asc_shader_program_create(AscShaderCodes codes) { |
122 unsigned shader[4]; |
142 unsigned shader[4]; |
123 unsigned n = 0; |
143 unsigned n = 0; |