mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-11-04 07:01:04 +01:00 
			
		
		
		
	ImDrawList: Added Clone() helper function.
This commit is contained in:
		@@ -136,6 +136,7 @@ Other Changes:
 | 
				
			|||||||
- ImFontAtlas: Added ImFontAtlasFlags_NoPowerOfTwoHeight flag to disable padding font height to nearest power of two. (#1613)
 | 
					- ImFontAtlas: Added ImFontAtlasFlags_NoPowerOfTwoHeight flag to disable padding font height to nearest power of two. (#1613)
 | 
				
			||||||
- ImFontAtlas: Added ImFontAtlasFlags_NoMouseCursors flag to disable baking software mouse cursors, mostly to save texture memory on very low end hardware. (#1613)
 | 
					- ImFontAtlas: Added ImFontAtlasFlags_NoMouseCursors flag to disable baking software mouse cursors, mostly to save texture memory on very low end hardware. (#1613)
 | 
				
			||||||
- ImDrawList: Fixed AddRect() with antialiasing disabled (lower-right corner pixel was often missing, rounding looks a little better.) (#1646)
 | 
					- ImDrawList: Fixed AddRect() with antialiasing disabled (lower-right corner pixel was often missing, rounding looks a little better.) (#1646)
 | 
				
			||||||
 | 
					- ImDrawList: Added CloneOutput() helper to facilitate the cloning of ImDrawData or ImDrawList for multi-threaded rendering.
 | 
				
			||||||
- Misc: Functions passed to libc qsort are explicitely marked cdecl to support compiling with vectorcall as the default calling convention. (#1230, #1611) [@RandyGaul]
 | 
					- Misc: Functions passed to libc qsort are explicitely marked cdecl to support compiling with vectorcall as the default calling convention. (#1230, #1611) [@RandyGaul]
 | 
				
			||||||
- Misc: ImVec2: added [] operator. This is becoming desirable for some types of code, better added sooner than later.
 | 
					- Misc: ImVec2: added [] operator. This is becoming desirable for some types of code, better added sooner than later.
 | 
				
			||||||
- Misc: Exposed IM_OFFSETOF() helper in imgui.h.
 | 
					- Misc: Exposed IM_OFFSETOF() helper in imgui.h.
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										16
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										16
									
								
								imgui.h
									
									
									
									
									
								
							@@ -1579,6 +1579,7 @@ struct ImDrawList
 | 
				
			|||||||
    // Advanced
 | 
					    // Advanced
 | 
				
			||||||
    IMGUI_API void  AddCallback(ImDrawCallback callback, void* callback_data);  // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
 | 
					    IMGUI_API void  AddCallback(ImDrawCallback callback, void* callback_data);  // Your rendering function must check for 'UserCallback' in ImDrawCmd and call the function instead of rendering triangles.
 | 
				
			||||||
    IMGUI_API void  AddDrawCmd();                                               // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
 | 
					    IMGUI_API void  AddDrawCmd();                                               // This is useful if you need to forcefully create a new draw call (to allow for dependent rendering / blending). Otherwise primitives are merged into the same draw-call as much as possible
 | 
				
			||||||
 | 
					    IMGUI_API ImDrawList* CloneOutput() const;                                  // Create a clone of the CmdBuffer/IdxBuffer/VtxBuffer.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Internal helpers
 | 
					    // Internal helpers
 | 
				
			||||||
    // NB: all primitives needs to be reserved via PrimReserve() beforehand!
 | 
					    // NB: all primitives needs to be reserved via PrimReserve() beforehand!
 | 
				
			||||||
@@ -1600,15 +1601,16 @@ struct ImDrawList
 | 
				
			|||||||
struct ImDrawData
 | 
					struct ImDrawData
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    bool            Valid;                  // Only valid after Render() is called and before the next NewFrame() is called.
 | 
					    bool            Valid;                  // Only valid after Render() is called and before the next NewFrame() is called.
 | 
				
			||||||
    ImDrawList**    CmdLists;
 | 
					    ImDrawList**    CmdLists;               // Array of ImDrawList* to render. The ImDrawList are owned by ImGuiContext and only pointed to from here.
 | 
				
			||||||
    int             CmdListsCount;
 | 
					    int             CmdListsCount;          // Number of ImDrawList* to render
 | 
				
			||||||
    int             TotalVtxCount;          // For convenience, sum of all cmd_lists vtx_buffer.Size
 | 
					    int             TotalIdxCount;          // For convenience, sum of all ImDrawList's IdxBuffer.Size
 | 
				
			||||||
    int             TotalIdxCount;          // For convenience, sum of all cmd_lists idx_buffer.Size
 | 
					    int             TotalVtxCount;          // For convenience, sum of all ImDrawList's VtxBuffer.Size
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Functions
 | 
					    // Functions
 | 
				
			||||||
    ImDrawData() { Clear(); }
 | 
					    ImDrawData()    { Valid = false; Clear(); }
 | 
				
			||||||
    void Clear() { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; } // Draw lists are owned by the ImGuiContext and only pointed to here.
 | 
					    ~ImDrawData()   { Clear(); }
 | 
				
			||||||
    IMGUI_API void DeIndexAllBuffers();               // For backward compatibility or convenience: convert all buffers from indexed to de-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
 | 
					    void Clear()    { Valid = false; CmdLists = NULL; CmdListsCount = TotalVtxCount = TotalIdxCount = 0; } // The ImDrawList are owned by ImGuiContext!
 | 
				
			||||||
 | 
					    IMGUI_API void  DeIndexAllBuffers();                // Helper to convert all buffers from indexed to non-indexed, in case you cannot render indexed. Note: this is slow and most likely a waste of resources. Always prefer indexed rendering!
 | 
				
			||||||
    IMGUI_API void  ScaleClipRects(const ImVec2& sc);   // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
 | 
					    IMGUI_API void  ScaleClipRects(const ImVec2& sc);   // Helper to scale the ClipRect field of each ImDrawCmd. Use if your final output buffer is at a different scale than ImGui expects, or if there is a difference between your window resolution and framebuffer resolution.
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -338,6 +338,16 @@ void ImDrawList::ClearFreeMemory()
 | 
				
			|||||||
    _Channels.clear();
 | 
					    _Channels.clear();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					ImDrawList* ImDrawList::CloneOutput() const
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    ImDrawList* dst = IM_NEW(ImDrawList(NULL));
 | 
				
			||||||
 | 
					    dst->CmdBuffer = CmdBuffer;
 | 
				
			||||||
 | 
					    dst->IdxBuffer = IdxBuffer;
 | 
				
			||||||
 | 
					    dst->VtxBuffer = VtxBuffer;
 | 
				
			||||||
 | 
					    dst->Flags = Flags;
 | 
				
			||||||
 | 
					    return dst;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds
 | 
					// Using macros because C++ is a terrible language, we want guaranteed inline, no code in header, and no overhead in Debug builds
 | 
				
			||||||
#define GetCurrentClipRect()    (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1]  : _Data->ClipRectFullscreen)
 | 
					#define GetCurrentClipRect()    (_ClipRectStack.Size ? _ClipRectStack.Data[_ClipRectStack.Size-1]  : _Data->ClipRectFullscreen)
 | 
				
			||||||
#define GetCurrentTextureId()   (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : NULL)
 | 
					#define GetCurrentTextureId()   (_TextureIdStack.Size ? _TextureIdStack.Data[_TextureIdStack.Size-1] : NULL)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user