37 typedef struct asc_text_shader_s { |
37 typedef struct asc_text_shader_s { |
38 AscShaderProgram program; |
38 AscShaderProgram program; |
39 asc_uniform_loc tex; |
39 asc_uniform_loc tex; |
40 } AscTextShader; |
40 } AscTextShader; |
41 |
41 |
42 AscShaderProgram *asc_text_shader_create(cx_attr_unused int unused) { |
42 static void asc_text_shader_init(AscShaderProgram *p, cx_attr_unused int flags) { |
43 AscShaderCodes codes; |
43 asc_shader_init_uniform_loc_nice(p, AscTextShader, tex); |
44 if (asc_shader_load_code_files((AscShaderCodeInfo){ |
44 } |
|
45 |
|
46 static AscShaderProgram *asc_text_shader_create(int flags) { |
|
47 return asc_shader_create((AscShaderCodeInfo){ |
45 .files.vtx = "sprite_vtx.glsl", |
48 .files.vtx = "sprite_vtx.glsl", |
46 .files.frag = "sprite_frag.glsl", |
49 .files.frag = "sprite_frag.glsl", |
47 .defines.frag = "#define USE_RECT", |
50 .defines.frag = "#define USE_RECT", |
48 }, &codes)) { |
51 }, sizeof(AscTextShader), asc_text_shader_init, flags); |
49 asc_error("Loading text shader failed."); |
|
50 return NULL; |
|
51 } |
|
52 AscShaderProgram *shader = asc_shader_create(codes, sizeof(AscTextShader)); |
|
53 if (asc_shader_invalid(shader)) { |
|
54 asc_shader_free_codes(codes); |
|
55 return shader; |
|
56 } |
|
57 asc_ptr_cast(AscTextShader, text_shader, shader); |
|
58 text_shader->tex = asc_shader_get_uniform_loc(shader, "tex"); |
|
59 asc_shader_free_codes(codes); |
|
60 |
|
61 if (asc_error_catch_gl("Creating text shader")) { |
|
62 // TODO: error handling |
|
63 } |
|
64 |
|
65 return shader; |
|
66 } |
52 } |
67 |
53 |
68 static void asc_text_update(AscSceneNode *node) { |
54 static void asc_text_update(AscSceneNode *node) { |
69 asc_ptr_cast(AscText, text, node); |
55 asc_ptr_cast(AscText, text, node); |
70 |
56 |