Skip to content

Commit 15b96fd

Browse files
committed
Merge branch 'master' into docking
# Conflicts: # imgui.cpp # imgui_internal.h
2 parents 3fb14b5 + 1aab00d commit 15b96fd

13 files changed

+176
-121
lines changed

backends/imgui_impl_dx10.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,7 @@ static void ImGui_ImplDX10_SetupRenderState(ImDrawData* draw_data, ID3D10Device*
9393
ImGui_ImplDX10_Data* bd = ImGui_ImplDX10_GetBackendData();
9494

9595
// Setup viewport
96-
D3D10_VIEWPORT vp;
97-
memset(&vp, 0, sizeof(D3D10_VIEWPORT));
96+
D3D10_VIEWPORT vp = {};
9897
vp.Width = (UINT)draw_data->DisplaySize.x;
9998
vp.Height = (UINT)draw_data->DisplaySize.y;
10099
vp.MinDepth = 0.0f;
@@ -158,8 +157,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
158157
{
159158
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
160159
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
161-
D3D10_BUFFER_DESC desc;
162-
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
160+
D3D10_BUFFER_DESC desc = {};
163161
desc.Usage = D3D10_USAGE_DYNAMIC;
164162
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
165163
desc.BindFlags = D3D10_BIND_VERTEX_BUFFER;
@@ -173,8 +171,7 @@ void ImGui_ImplDX10_RenderDrawData(ImDrawData* draw_data)
173171
{
174172
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
175173
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
176-
D3D10_BUFFER_DESC desc;
177-
memset(&desc, 0, sizeof(D3D10_BUFFER_DESC));
174+
D3D10_BUFFER_DESC desc = {};
178175
desc.Usage = D3D10_USAGE_DYNAMIC;
179176
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
180177
desc.BindFlags = D3D10_BIND_INDEX_BUFFER;
@@ -437,7 +434,7 @@ bool ImGui_ImplDX10_CreateDeviceObjects()
437434

438435
// Create the constant buffer
439436
{
440-
D3D10_BUFFER_DESC desc;
437+
D3D10_BUFFER_DESC desc = {};
441438
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER_DX10);
442439
desc.Usage = D3D10_USAGE_DYNAMIC;
443440
desc.BindFlags = D3D10_BIND_CONSTANT_BUFFER;

backends/imgui_impl_dx11.cpp

+4-7
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,7 @@ static void ImGui_ImplDX11_SetupRenderState(ImDrawData* draw_data, ID3D11DeviceC
9898
ImGui_ImplDX11_Data* bd = ImGui_ImplDX11_GetBackendData();
9999

100100
// Setup viewport
101-
D3D11_VIEWPORT vp;
102-
memset(&vp, 0, sizeof(D3D11_VIEWPORT));
101+
D3D11_VIEWPORT vp = {};
103102
vp.Width = draw_data->DisplaySize.x;
104103
vp.Height = draw_data->DisplaySize.y;
105104
vp.MinDepth = 0.0f;
@@ -166,8 +165,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
166165
{
167166
if (bd->pVB) { bd->pVB->Release(); bd->pVB = nullptr; }
168167
bd->VertexBufferSize = draw_data->TotalVtxCount + 5000;
169-
D3D11_BUFFER_DESC desc;
170-
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
168+
D3D11_BUFFER_DESC desc = {};
171169
desc.Usage = D3D11_USAGE_DYNAMIC;
172170
desc.ByteWidth = bd->VertexBufferSize * sizeof(ImDrawVert);
173171
desc.BindFlags = D3D11_BIND_VERTEX_BUFFER;
@@ -180,8 +178,7 @@ void ImGui_ImplDX11_RenderDrawData(ImDrawData* draw_data)
180178
{
181179
if (bd->pIB) { bd->pIB->Release(); bd->pIB = nullptr; }
182180
bd->IndexBufferSize = draw_data->TotalIdxCount + 10000;
183-
D3D11_BUFFER_DESC desc;
184-
memset(&desc, 0, sizeof(D3D11_BUFFER_DESC));
181+
D3D11_BUFFER_DESC desc = {};
185182
desc.Usage = D3D11_USAGE_DYNAMIC;
186183
desc.ByteWidth = bd->IndexBufferSize * sizeof(ImDrawIdx);
187184
desc.BindFlags = D3D11_BIND_INDEX_BUFFER;
@@ -455,7 +452,7 @@ bool ImGui_ImplDX11_CreateDeviceObjects()
455452

456453
// Create the constant buffer
457454
{
458-
D3D11_BUFFER_DESC desc;
455+
D3D11_BUFFER_DESC desc = {};
459456
desc.ByteWidth = sizeof(VERTEX_CONSTANT_BUFFER_DX11);
460457
desc.Usage = D3D11_USAGE_DYNAMIC;
461458
desc.BindFlags = D3D11_BIND_CONSTANT_BUFFER;

backends/imgui_impl_dx12.cpp

+9-18
Original file line numberDiff line numberDiff line change
@@ -213,8 +213,7 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
213213
}
214214

215215
// Setup viewport
216-
D3D12_VIEWPORT vp;
217-
memset(&vp, 0, sizeof(D3D12_VIEWPORT));
216+
D3D12_VIEWPORT vp = {};
218217
vp.Width = draw_data->DisplaySize.x;
219218
vp.Height = draw_data->DisplaySize.y;
220219
vp.MinDepth = 0.0f;
@@ -225,14 +224,12 @@ static void ImGui_ImplDX12_SetupRenderState(ImDrawData* draw_data, ID3D12Graphic
225224
// Bind shader and vertex buffers
226225
unsigned int stride = sizeof(ImDrawVert);
227226
unsigned int offset = 0;
228-
D3D12_VERTEX_BUFFER_VIEW vbv;
229-
memset(&vbv, 0, sizeof(D3D12_VERTEX_BUFFER_VIEW));
227+
D3D12_VERTEX_BUFFER_VIEW vbv = {};
230228
vbv.BufferLocation = fr->VertexBuffer->GetGPUVirtualAddress() + offset;
231229
vbv.SizeInBytes = fr->VertexBufferSize * stride;
232230
vbv.StrideInBytes = stride;
233231
command_list->IASetVertexBuffers(0, 1, &vbv);
234-
D3D12_INDEX_BUFFER_VIEW ibv;
235-
memset(&ibv, 0, sizeof(D3D12_INDEX_BUFFER_VIEW));
232+
D3D12_INDEX_BUFFER_VIEW ibv = {};
236233
ibv.BufferLocation = fr->IndexBuffer->GetGPUVirtualAddress();
237234
ibv.SizeInBytes = fr->IndexBufferSize * sizeof(ImDrawIdx);
238235
ibv.Format = sizeof(ImDrawIdx) == 2 ? DXGI_FORMAT_R16_UINT : DXGI_FORMAT_R32_UINT;
@@ -273,13 +270,11 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
273270
{
274271
SafeRelease(fr->VertexBuffer);
275272
fr->VertexBufferSize = draw_data->TotalVtxCount + 5000;
276-
D3D12_HEAP_PROPERTIES props;
277-
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
273+
D3D12_HEAP_PROPERTIES props = {};
278274
props.Type = D3D12_HEAP_TYPE_UPLOAD;
279275
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
280276
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
281-
D3D12_RESOURCE_DESC desc;
282-
memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC));
277+
D3D12_RESOURCE_DESC desc = {};
283278
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
284279
desc.Width = fr->VertexBufferSize * sizeof(ImDrawVert);
285280
desc.Height = 1;
@@ -296,13 +291,11 @@ void ImGui_ImplDX12_RenderDrawData(ImDrawData* draw_data, ID3D12GraphicsCommandL
296291
{
297292
SafeRelease(fr->IndexBuffer);
298293
fr->IndexBufferSize = draw_data->TotalIdxCount + 10000;
299-
D3D12_HEAP_PROPERTIES props;
300-
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
294+
D3D12_HEAP_PROPERTIES props = {};
301295
props.Type = D3D12_HEAP_TYPE_UPLOAD;
302296
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
303297
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
304-
D3D12_RESOURCE_DESC desc;
305-
memset(&desc, 0, sizeof(D3D12_RESOURCE_DESC));
298+
D3D12_RESOURCE_DESC desc = {};
306299
desc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
307300
desc.Width = fr->IndexBufferSize * sizeof(ImDrawIdx);
308301
desc.Height = 1;
@@ -410,8 +403,7 @@ static void ImGui_ImplDX12_CreateFontsTexture()
410403
// Upload texture to graphics system
411404
ImGui_ImplDX12_Texture* font_tex = &bd->FontTexture;
412405
{
413-
D3D12_HEAP_PROPERTIES props;
414-
memset(&props, 0, sizeof(D3D12_HEAP_PROPERTIES));
406+
D3D12_HEAP_PROPERTIES props = {};
415407
props.Type = D3D12_HEAP_TYPE_DEFAULT;
416408
props.CPUPageProperty = D3D12_CPU_PAGE_PROPERTY_UNKNOWN;
417409
props.MemoryPoolPreference = D3D12_MEMORY_POOL_UNKNOWN;
@@ -638,8 +630,7 @@ bool ImGui_ImplDX12_CreateDeviceObjects()
638630
// 2) use code to detect any version of the DLL and grab a pointer to D3DCompile from the DLL.
639631
// See https://github.com/ocornut/imgui/pull/638 for sources and details.
640632

641-
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc;
642-
memset(&psoDesc, 0, sizeof(D3D12_GRAPHICS_PIPELINE_STATE_DESC));
633+
D3D12_GRAPHICS_PIPELINE_STATE_DESC psoDesc = {};
643634
psoDesc.NodeMask = 1;
644635
psoDesc.PrimitiveTopologyType = D3D12_PRIMITIVE_TOPOLOGY_TYPE_TRIANGLE;
645636
psoDesc.pRootSignature = bd->pRootSignature;

backends/imgui_impl_metal.h

+1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
1515
// - Introduction, links and more at the top of imgui.cpp
1616

17+
#pragma once
1718
#include "imgui.h" // IMGUI_IMPL_API
1819
#ifndef IMGUI_DISABLE
1920

backends/imgui_impl_opengl3.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ bool ImGui_ImplOpenGL3_InitLoader()
290290
{
291291
// Initialize our loader
292292
#ifdef IMGUI_IMPL_OPENGL_LOADER_IMGL3W
293-
if (glGetIntegerv == NULL && imgl3wInit() != 0)
293+
if (glGetIntegerv == nullptr && imgl3wInit() != 0)
294294
{
295295
fprintf(stderr, "Failed to initialize OpenGL loader!\n");
296296
return false;

backends/imgui_impl_osx.h

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
// - Documentation https://dearimgui.com/docs (same as your local docs/ folder).
2525
// - Introduction, links and more at the top of imgui.cpp
2626

27+
#pragma once
2728
#include "imgui.h" // IMGUI_IMPL_API
2829
#ifndef IMGUI_DISABLE
2930

backends/imgui_impl_wgpu.cpp

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@
4343
// 2021-02-18: Change blending equation to preserve alpha in output buffer.
4444
// 2021-01-28: Initial version.
4545

46+
#include "imgui.h"
47+
4648
// When targeting native platforms (i.e. NOT emscripten), one of IMGUI_IMPL_WEBGPU_BACKEND_DAWN
4749
// or IMGUI_IMPL_WEBGPU_BACKEND_WGPU must be provided. See imgui_impl_wgpu.h for more details.
4850
#ifndef __EMSCRIPTEN__
@@ -55,7 +57,6 @@
5557
#endif
5658
#endif
5759

58-
#include "imgui.h"
5960
#ifndef IMGUI_DISABLE
6061
#include "imgui_impl_wgpu.h"
6162
#include <limits.h>
@@ -688,9 +689,15 @@ bool ImGui_ImplWGPU_CreateDeviceObjects()
688689
// Vertex input configuration
689690
WGPUVertexAttribute attribute_desc[] =
690691
{
692+
#ifdef IMGUI_IMPL_WEBGPU_BACKEND_DAWN
693+
{ nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 },
694+
{ nullptr, WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 },
695+
{ nullptr, WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 },
696+
#else
691697
{ WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, pos), 0 },
692698
{ WGPUVertexFormat_Float32x2, (uint64_t)offsetof(ImDrawVert, uv), 1 },
693699
{ WGPUVertexFormat_Unorm8x4, (uint64_t)offsetof(ImDrawVert, col), 2 },
700+
#endif
694701
};
695702

696703
WGPUVertexBufferLayout buffer_layouts[1];

docs/CHANGELOG.txt

+18
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,22 @@ HOW TO UPDATE?
4141

4242
Breaking changes:
4343

44+
- Image: removed 'tint_col' and 'border_col' parameter from Image() function. (#8131, #8238)
45+
- Old function signature:
46+
void Image (ImTextureID tex_id, ImVec2 image_size, ImVec2 uv0 = (0,0), ImVec2 uv1 = (1,1), ImVec4 tint_col = (1,1,1,1), ImVec4 border_col = (0,0,0,0));
47+
- New function signatures:
48+
void Image (ImTextureID tex_id, ImVec2 image_size, ImVec2 uv0 = (0,0), ImVec2 uv1 = (1,1));
49+
void ImageWithBg(ImTextureID tex_id, ImVec2 image_size, ImVec2 uv0 = (0,0), ImVec2 uv1 = (1,1), ImVec4 bg_col = (0,0,0,0), ImVec4 tint_col = (1,1,1,1));
50+
- TL;DR: 'border_col' had misleading side-effect on layout, 'bg_col' was missing, parameter order couldn't be consistent with ImageButton().
51+
- New behavior always use ImGuiCol_Border color + style.ImageBorderSize / ImGuiStyleVar_ImageBorderSize.
52+
- Old behavior altered border size (and therefore layout) based on border color's
53+
alpha, which caused variety of problems.
54+
- Old behavior used a fixed value of 1.0f for border size which was not tweakable.
55+
- Kept legacy signature (will obsolete), which mimics the old behavior,
56+
but uses Max(1.0f, style.ImageBorderSize) when border_col is specified.
57+
- Added ImageWithBg() function which has both 'bg_col' (which was missing) and 'tint_col'.
58+
It was impossible to add 'bg_col' to Image() with a parameter order consistent with
59+
other functions, so we decided to remove 'tint_col' and introduce ImageWithBg().
4460
- Renamed ImFontConfig::GlyphExtraSpacing.x option to GlyphExtraAdvanceX. (#242)
4561
- Renamed style.TabMinWidthForCloseButton to style.TabCloseButtonMinWidthUnselected.
4662
- Backends: Vulkan: Added 'uint32_t api_version' argument to ImGui_ImplVulkan_LoadFunctions().
@@ -70,6 +86,8 @@ Other changes:
7086
- Tables: tamed some .ini settings optimizations to more accurately allow
7187
overwriting/hot-reloading settings in more situations. (#7934)
7288
- Tables, Error Handling: Recovery from invalid index in TableSetColumnIndex(). (#1651)
89+
- Image: Added ImageWithBg() variant with bg color and tint color. (#8131, #8238)
90+
- Image, Style: Added style.ImageBorderSize, ImGuiStyleVar_ImageBorderSize. (#8131, #8238)
7391
- Selectable: Fixed horizontal label alignment with SelectableTextAlign.x > 0 and
7492
specifying a selectable size. (#8338)
7593
- Tabs, Style: made the Close Button of selected tabs always visible by default,

0 commit comments

Comments
 (0)