Ver código fonte

Fix NK_INCLUDE_COMMAND_USERDATA usage with images.

If userdata is used with drawing images userdata was missing from
the first image command and also subsequent commands which draw the
same texture but with different user data were incorrectly merged together.
Sergey Semushin 8 anos atrás
pai
commit
988b40888b
1 arquivos alterados com 9 adições e 2 exclusões
  1. 9 2
      nuklear.h

+ 9 - 2
nuklear.h

@@ -7968,9 +7968,16 @@ nk_draw_list_push_image(struct nk_draw_list *list, nk_handle texture)
         nk_draw_list_push_command(list, nk_null_rect, texture);
     } else {
         struct nk_draw_command *prev = nk_draw_list_command_last(list);
-        if (prev->elem_count == 0)
+        if (prev->elem_count == 0) {
             prev->texture = texture;
-        else if (prev->texture.id != texture.id)
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+            prev->userdata = list->userdata;
+#endif
+    } else if (prev->texture.id != texture.id
+#ifdef NK_INCLUDE_COMMAND_USERDATA
+               || prev->userdata.id != list->userdata.id
+#endif
+              )
             nk_draw_list_push_command(list, prev->clip_rect, texture);
     }
 }