| 46 asc_dprintf("GL debug: %.*s", (int)buf.length, buf.ptr); |
46 asc_dprintf("GL debug: %.*s", (int)buf.length, buf.ptr); |
| 47 } |
47 } |
| 48 cx_strfree(&buf); |
48 cx_strfree(&buf); |
| 49 } |
49 } |
| 50 |
50 |
| 51 #include "shader_codes.h" |
|
| 52 |
|
| 53 static void asc_shader_initialize_predefined(AscGLContext *ctx) { |
51 static void asc_shader_initialize_predefined(AscGLContext *ctx) { |
| |
52 // TODO: deal with different working dirs |
| 54 AscShaderSprite *sprite = &ctx->shader.sprite; |
53 AscShaderSprite *sprite = &ctx->shader.sprite; |
| 55 sprite->program = asc_shader_program_create(asc_shader_codes_sprite); |
54 AscShaderCodes codes; |
| |
55 if (asc_shader_load_code_files((AscShaderCodeFiles){ |
| |
56 .vtx = "./shader/sprite_vtx.glsl", |
| |
57 .frag = "./shader/sprite_frag.glsl" |
| |
58 }, &codes)) { |
| |
59 asc_error("Loading sprite shader failed."); |
| |
60 return; |
| |
61 } |
| |
62 sprite->program = asc_shader_program_create(codes); |
| 56 sprite->depth = glGetUniformLocation(sprite->program.id, "depth"); |
63 sprite->depth = glGetUniformLocation(sprite->program.id, "depth"); |
| 57 sprite->tex = glGetUniformLocation(sprite->program.id, "texture"); |
64 sprite->tex = glGetUniformLocation(sprite->program.id, "texture"); |
| |
65 asc_shader_free_codes(codes); |
| 58 } |
66 } |
| 59 |
67 |
| 60 static void asc_shader_destroy_predefined(AscGLContext *ctx) { |
68 static void asc_shader_destroy_predefined(AscGLContext *ctx) { |
| 61 asc_shader_program_destroy(ctx->shader.sprite.program); |
69 asc_shader_program_destroy(ctx->shader.sprite.program); |
| 62 } |
70 } |