Created
February 24, 2016 05:57
-
-
Save czlc/fe4a4694bb885c73b06b to your computer and use it in GitHub Desktop.
Revisions
-
czlc created this gist
Feb 24, 2016 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ union { struct sprite * children[1]; struct rich_text * rich_text; int scissor; struct anchor_data *anchor; struct pack_polygon *polygon; } data; int sprite_size(struct sprite_pack *pack, int id) { else if (type == TYPE_POLYGON) { offset_t *data = OFFSET_TO_POINTER(offset_t, pack, pack->data); struct pack_polygon_data * poly = OFFSET_TO_POINTER(struct pack_polygon_data, pack, data[id]); return sizeof(struct sprite) + sizeof (pack_polygon) + (poly->n - 1) * sizeof(struct pack_poly *) ; } } void sprite_init(struct sprite * s, struct sprite_pack * pack, int id, int sz) { else if (s->type == TYPE_POLYGON) { struct pack_polygon_data * polygon = (struct pack_polygon_data *)s->s.poly; s->data.polygon = (struct pack_polygon *)(s + 1); s->data.polygon->n = polygon->n; int i; for (i=0; i<polygon->n; i++) { s->data.polygon->poly[i].texture_coord = OFFSET_TO_POINTER(uv_t, pack, polygon->poly[i].texture_coord); s->data.polygon->poly[i].screen_coord = OFFSET_TO_POINTER(int32_t, pack, polygon->poly[i].screen_coord); s->data.polygon->poly[i].texid = polygon->poly[i].texid; s->data.polygon->poly[i].n = polygon->poly[i].n; } s->s.poly = s->data.polygon; }