src/text.c

changeset 135
062703d3f5cc
parent 122
1b118cd3e369
child 137
f8e6e0ae61a8
equal deleted inserted replaced
134:42dcc8134a68 135:062703d3f5cc
58 unsigned short newoffx = surface->w / 2; 58 unsigned short newoffx = surface->w / 2;
59 node->position.x = node->position.x + (float)(text->offx - newoffx); 59 node->position.x = node->position.x + (float)(text->offx - newoffx);
60 text->offx = newoffx; 60 text->offx = newoffx;
61 } 61 }
62 62
63 // Transfer Image Data
64 asc_texture_from_surface(sprite->texture, surface);
65
63 // If dimensions changed, update the mesh 66 // If dimensions changed, update the mesh
64 if (text->dimension.x != (unsigned)surface->w || text->dimension.y != (unsigned)surface->h) { 67 if (text->dimension.x != (unsigned)surface->w || text->dimension.y != (unsigned)surface->h) {
65 text->dimension.x = surface->w; 68 text->dimension.x = surface->w;
66 text->dimension.y = surface->h; 69 text->dimension.y = surface->h;
67 asc_mesh_plane_2d(&text->base.mesh, .size = asc_vec2f_new(surface->w, surface->h)); 70 const asc_vec2f uv_scale = asc_texture_calculate_uv_scale(sprite->texture, text->dimension, asc_vec2f_one);
71 asc_mesh_plane_2d(&text->base.mesh,
72 .size = asc_vec2f_new(surface->w, surface->h),
73 .uv_scale = uv_scale
74 );
68 } 75 }
69
70 // Transfer Image Data
71 asc_texture_from_surface(sprite->texture, surface);
72 76
73 // Free the surface 77 // Free the surface
74 SDL_FreeSurface(surface); 78 SDL_FreeSurface(surface);
75 79
76 // Schedule for transform update 80 // Schedule for transform update

mercurial