src/text.c

changeset 41
df81d493716e
parent 40
6c438be1a1fd
child 44
b3da4096c607
equal deleted inserted replaced
40:6c438be1a1fd 41:df81d493716e
44 // Upload surface 44 // Upload surface
45 glActiveTexture(GL_TEXTURE0); 45 glActiveTexture(GL_TEXTURE0);
46 glBindTexture(GL_TEXTURE_RECTANGLE, node->tex_id); 46 glBindTexture(GL_TEXTURE_RECTANGLE, node->tex_id);
47 glUniform1i(ASC_SHADER_SPRITE.surface, 0); 47 glUniform1i(ASC_SHADER_SPRITE.surface, 0);
48 48
49 // Apply depth
50 glUniform1f(ASC_SHADER_SPRITE.depth, (float)(node->base.depth));
51
49 // Draw mesh 52 // Draw mesh
50 asc_primitives_draw_plane(); 53 asc_primitives_draw_plane();
51 } 54 }
52 55
53 static void asc_text_update_transform(AscText *node) { 56 static void asc_text_update_transform(AscText *node) {
81 asc_error(SDL_GetError()); 84 asc_error(SDL_GetError());
82 return; 85 return;
83 } 86 }
84 node->dimension.width = surface->w; 87 node->dimension.width = surface->w;
85 node->dimension.height = surface->h; 88 node->dimension.height = surface->h;
86 asc_node_update_transform(node); 89 asc_node_update_transform((AscSceneNode *) node);
87 90
88 // Transfer Image Data 91 // Transfer Image Data
89 // TODO: move the image data transfer to a separate function - we will need it more often 92 // TODO: move the image data transfer to a separate function - we will need it more often
90 glBindTexture(GL_TEXTURE_RECTANGLE, node->tex_id); 93 glBindTexture(GL_TEXTURE_RECTANGLE, node->tex_id);
91 glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->pitch / surface->format->BytesPerPixel); 94 glPixelStorei(GL_UNPACK_ROW_LENGTH, surface->pitch / surface->format->BytesPerPixel);
102 if (node == NULL) { 105 if (node == NULL) {
103 asc_error("Out of memory."); 106 asc_error("Out of memory.");
104 return NULL; 107 return NULL;
105 } 108 }
106 109
107 node->base.render_group = ASC_RENDER_GROUP_FONTS; 110 node->base.render_group = ASC_RENDER_GROUP_SPRITE_BLEND;
108 node->base.free_func = (asc_scene_free_func) asc_text_free; 111 node->base.free_func = (asc_scene_free_func) asc_text_free;
109 node->base.update_func = (asc_scene_update_func) asc_text_update; 112 node->base.update_func = (asc_scene_update_func) asc_text_update;
110 node->base.transform_update_func = (asc_scene_update_func) asc_text_update_transform; 113 node->base.transform_update_func = (asc_scene_update_func) asc_text_update_transform;
111 node->base.draw_func = (asc_scene_draw_func) asc_text_draw; 114 node->base.draw_func = (asc_scene_draw_func) asc_text_draw;
112 115

mercurial