src/text.c

changeset 65
9c44c55d327a
parent 64
f18dc427f86f
child 66
8297afa1c29c
equal deleted inserted replaced
64:f18dc427f86f 65:9c44c55d327a
34 34
35 #include <GL/glew.h> 35 #include <GL/glew.h>
36 36
37 static void asc_text_draw(AscText const *node) { 37 static void asc_text_draw(AscText const *node) {
38 // Obtain shader 38 // Obtain shader
39 AscShaderSprite *shader = &asc_window_active->glctx.shader.sprite; 39 AscShaderSprite *shader = &asc_active_window->glctx.shader.sprite;
40 40
41 // Upload model matrix 41 // Upload model matrix
42 glUniformMatrix4fv(shader->base.model, 1, 42 glUniformMatrix4fv(shader->base.model, 1,
43 GL_FALSE, node->base.world_transform); 43 GL_FALSE, node->base.world_transform);
44 44
57 if (asc_texture_uninitialized(&node->tex)) { 57 if (asc_texture_uninitialized(&node->tex)) {
58 asc_texture_init_rectangle(&node->tex); 58 asc_texture_init_rectangle(&node->tex);
59 } 59 }
60 60
61 // Render text onto a surface 61 // Render text onto a surface
62 TTF_Font *font = asc_font_cache_validate(node->font)->ptr; 62 // TODO: obtain TTF_Font from font cache once it is repaired
63 TTF_Font *font = node->font.ptr;
63 static int alignments[] = { 64 static int alignments[] = {
64 TTF_WRAPPED_ALIGN_LEFT, 65 TTF_WRAPPED_ALIGN_LEFT,
65 TTF_WRAPPED_ALIGN_CENTER, 66 TTF_WRAPPED_ALIGN_CENTER,
66 TTF_WRAPPED_ALIGN_RIGHT 67 TTF_WRAPPED_ALIGN_RIGHT
67 }; 68 };
99 100
100 node->base.flags = args.alignment; 101 node->base.flags = args.alignment;
101 node->base.position.x = (float) args.x; 102 node->base.position.x = (float) args.x;
102 node->base.position.y = (float) args.y; 103 node->base.position.y = (float) args.y;
103 node->max_width = args.max_width; 104 node->max_width = args.max_width;
104 node->font = asc_context.active_font; 105 node->font = *asc_active_font;
105 node->color = asc_context.ink; 106 node->color = asc_context.ink;
106 if (args.text == NULL) { 107 if (args.text == NULL) {
107 node->text = cx_mutstr(strdup(" ")); 108 node->text = cx_mutstr(strdup(" "));
108 } else { 109 } else {
109 node->text = cx_mutstr(strdup(args.text)); 110 node->text = cx_mutstr(strdup(args.text));

mercurial