Browse Source

Merge pull request #253 from ytsarko/master

Implemented drawing command memory zeroing for quick buffer compares
Micha Mettke 9 years ago
parent
commit
51a63af252
1 changed files with 11 additions and 0 deletions
  1. 11 0
      nuklear.h

+ 11 - 0
nuklear.h

@@ -214,6 +214,13 @@ OPTIONAL DEFINES:
         will be selected and compile time validated. If they are incorrect you can
         define the correct types by overloading these type defines.
 
+    NK_ZERO_COMMAND_MEMORY
+        Defining this will zero out memory for each drawing command added to a
+        drawing queue (inside nk_command_buffer_push). This can be used to
+        implement fast check (using memcmp) that command buffers are equal and
+        avoid drawing frames when nothing on screen has changed since previous
+        frame.
+
 CREDITS:
     Developed by Micha Mettke and every direct or indirect contributor to the GitHub.
 
@@ -5847,6 +5854,10 @@ nk_command_buffer_push(struct nk_command_buffer* b,
     memory = NK_ALIGN_PTR(unaligned, align);
     alignment = (nk_size)((nk_byte*)memory - (nk_byte*)unaligned);
 
+#ifdef NK_ZERO_COMMAND_MEMORY
+    NK_MEMSET(cmd, 0, size + alignment);
+#endif
+
     cmd->type = t;
     cmd->next = b->base->allocated + alignment;
 #ifdef NK_INCLUDE_COMMAND_USERDATA