mirror of
				https://github.com/Drezil/imgui.git
				synced 2025-10-30 20:51:06 +01:00 
			
		
		
		
	ImDrawList: Store initial flags for the frame in ImDrawListSharedData, reducing code duplication in setting up the flags.
This commit is contained in:
		| @@ -3502,16 +3502,15 @@ void ImGui::NewFrame() | ||||
|     IM_ASSERT(g.Font->IsLoaded()); | ||||
|     g.DrawListSharedData.ClipRectFullscreen = ImVec4(0.0f, 0.0f, g.IO.DisplaySize.x, g.IO.DisplaySize.y); | ||||
|     g.DrawListSharedData.CurveTessellationTol = g.Style.CurveTessellationTol; | ||||
|     g.DrawListSharedData.InitialFlags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0); | ||||
|  | ||||
|     g.BackgroundDrawList.Clear(); | ||||
|     g.BackgroundDrawList.PushTextureID(g.IO.Fonts->TexID); | ||||
|     g.BackgroundDrawList.PushClipRectFullScreen(); | ||||
|     g.BackgroundDrawList.Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0); | ||||
|  | ||||
|     g.ForegroundDrawList.Clear(); | ||||
|     g.ForegroundDrawList.PushTextureID(g.IO.Fonts->TexID); | ||||
|     g.ForegroundDrawList.PushClipRectFullScreen(); | ||||
|     g.ForegroundDrawList.Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0); | ||||
|  | ||||
|     // Mark rendering data as invalid to prevent user who may have a handle on it to use it. | ||||
|     g.DrawData.Clear(); | ||||
| @@ -5529,7 +5528,6 @@ bool ImGui::Begin(const char* name, bool* p_open, ImGuiWindowFlags flags) | ||||
|  | ||||
|         // Setup draw list and outer clipping rectangle | ||||
|         window->DrawList->Clear(); | ||||
|         window->DrawList->Flags = (g.Style.AntiAliasedLines ? ImDrawListFlags_AntiAliasedLines : 0) | (g.Style.AntiAliasedFill ? ImDrawListFlags_AntiAliasedFill : 0); | ||||
|         window->DrawList->PushTextureID(g.Font->ContainerAtlas->TexID); | ||||
|         PushClipRect(host_rect.Min, host_rect.Max, false); | ||||
|  | ||||
|   | ||||
							
								
								
									
										6
									
								
								imgui.h
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								imgui.h
									
									
									
									
									
								
							| @@ -218,9 +218,9 @@ namespace ImGui | ||||
|     IMGUI_API ImDrawData*   GetDrawData();                              // valid after Render() and until the next call to NewFrame(). this is what you have to render. | ||||
|  | ||||
|     // Demo, Debug, Information | ||||
|     IMGUI_API void          ShowDemoWindow(bool* p_open = NULL);        // create demo/test window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! | ||||
|     IMGUI_API void          ShowAboutWindow(bool* p_open = NULL);       // create about window. display Dear ImGui version, credits and build/system information. | ||||
|     IMGUI_API void          ShowMetricsWindow(bool* p_open = NULL);     // create metrics/debug window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. | ||||
|     IMGUI_API void          ShowDemoWindow(bool* p_open = NULL);        // create Demo window (previously called ShowTestWindow). demonstrate most ImGui features. call this to learn about the library! try to make it always available in your application! | ||||
|     IMGUI_API void          ShowAboutWindow(bool* p_open = NULL);       // create About window. display Dear ImGui version, credits and build/system information. | ||||
|     IMGUI_API void          ShowMetricsWindow(bool* p_open = NULL);     // create Metrics/Debug window. display Dear ImGui internals: draw commands (with individual draw calls and vertices), window list, basic internal state, etc. | ||||
|     IMGUI_API void          ShowStyleEditor(ImGuiStyle* ref = NULL);    // add style editor block (not a window). you can pass in a reference ImGuiStyle structure to compare to, revert to and save to (else it uses the default style) | ||||
|     IMGUI_API bool          ShowStyleSelector(const char* label);       // add style selector block (not a window), essentially a combo listing the default styles. | ||||
|     IMGUI_API void          ShowFontSelector(const char* label);        // add font selector block (not a window), essentially a combo listing the loaded fonts. | ||||
|   | ||||
| @@ -348,6 +348,7 @@ ImDrawListSharedData::ImDrawListSharedData() | ||||
|     FontSize = 0.0f; | ||||
|     CurveTessellationTol = 0.0f; | ||||
|     ClipRectFullscreen = ImVec4(-8192.0f, -8192.0f, +8192.0f, +8192.0f); | ||||
|     InitialFlags = ImDrawListFlags_None; | ||||
|  | ||||
|     // Const data | ||||
|     for (int i = 0; i < IM_ARRAYSIZE(CircleVtx12); i++) | ||||
| @@ -362,7 +363,7 @@ void ImDrawList::Clear() | ||||
|     CmdBuffer.resize(0); | ||||
|     IdxBuffer.resize(0); | ||||
|     VtxBuffer.resize(0); | ||||
|     Flags = ImDrawListFlags_AntiAliasedLines | ImDrawListFlags_AntiAliasedFill; | ||||
|     Flags = _Data->InitialFlags; | ||||
|     _VtxCurrentIdx = 0; | ||||
|     _VtxWritePtr = NULL; | ||||
|     _IdxWritePtr = NULL; | ||||
|   | ||||
| @@ -731,6 +731,7 @@ struct IMGUI_API ImDrawListSharedData | ||||
|     float           FontSize;                   // Current/default font size (optional, for simplified AddText overload) | ||||
|     float           CurveTessellationTol; | ||||
|     ImVec4          ClipRectFullscreen;         // Value for PushClipRectFullscreen() | ||||
|     ImDrawListFlags InitialFlags;               // Initial flags at the beginning of the frame (it is possible to alter flags on a per-drawlist basis afterwards) | ||||
|  | ||||
|     // Const data | ||||
|     // FIXME: Bake rounded corners fill/borders in atlas | ||||
| @@ -1034,7 +1035,7 @@ struct ImGuiContext | ||||
|     int                     WantTextInputNextFrame; | ||||
|     char                    TempBuffer[1024*3+1];               // Temporary text buffer | ||||
|  | ||||
|     ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(NULL), ForegroundDrawList(NULL) | ||||
|     ImGuiContext(ImFontAtlas* shared_font_atlas) : BackgroundDrawList(&DrawListSharedData), ForegroundDrawList(&DrawListSharedData) | ||||
|     { | ||||
|         Initialized = false; | ||||
|         FrameScopeActive = FrameScopePushedImplicitWindow = false; | ||||
| @@ -1109,9 +1110,7 @@ struct ImGuiContext | ||||
|         FocusTabPressed = false; | ||||
|  | ||||
|         DimBgRatio = 0.0f; | ||||
|         BackgroundDrawList._Data = &DrawListSharedData; | ||||
|         BackgroundDrawList._OwnerName = "##Background"; // Give it a name for debugging | ||||
|         ForegroundDrawList._Data = &DrawListSharedData; | ||||
|         ForegroundDrawList._OwnerName = "##Foreground"; // Give it a name for debugging | ||||
|         MouseCursor = ImGuiMouseCursor_Arrow; | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user