| 54 ? ASC_RENDER_GROUP_SPRITE_OPAQUE |
54 ? ASC_RENDER_GROUP_SPRITE_OPAQUE |
| 55 : ASC_RENDER_GROUP_SPRITE_BLEND; |
55 : ASC_RENDER_GROUP_SPRITE_BLEND; |
| 56 node->destroy_func = asc_sprite_destroy; |
56 node->destroy_func = asc_sprite_destroy; |
| 57 |
57 |
| 58 node->position = asc_vec3f_new(args.x, args.y, ASC_SCENE_2D_DEPTH_OFFSET); |
58 node->position = asc_vec3f_new(args.x, args.y, ASC_SCENE_2D_DEPTH_OFFSET); |
| 59 // TODO: do not use scale, add mesh params instead |
59 node->scale = asc_vec3f_one; |
| 60 node->scale = asc_vec3f_new( |
|
| 61 args.width == 0 ? args.texture->width : args.width, |
|
| 62 args.height == 0 ? args.texture->height : args.height, |
|
| 63 1 |
|
| 64 ); |
|
| 65 asc_node_update_transform(node); |
60 asc_node_update_transform(node); |
| 66 |
61 |
| 67 // initialize mesh |
62 // initialize mesh |
| 68 asc_mesh_plane_2d(&sprite->mesh); |
63 asc_mesh_plane_2d(&sprite->mesh, |
| |
64 .size = asc_vec2f_new(args.width, args.height), |
| |
65 // TODO: support different texture modes |
| |
66 ); |
| 69 |
67 |
| 70 return node; |
68 return node; |
| 71 } |
69 } |
| 72 |
70 |
| 73 void asc_sprite_draw(AscSprite const *node) { |
71 void asc_sprite_draw(AscSprite const *node) { |