Skip to content

Commit

Permalink
Misc: tweaks + fix warnings on backends withtout -wno-memaccess (ocor…
Browse files Browse the repository at this point in the history
  • Loading branch information
ocornut committed Mar 13, 2022
1 parent 0cff5ac commit fd06ed8
Show file tree
Hide file tree
Showing 20 changed files with 23 additions and 25 deletions.
2 changes: 1 addition & 1 deletion backends/imgui_impl_allegro5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct ImGui_ImplAllegro5_Data
ALLEGRO_VERTEX_DECL* VertexDecl;
char* ClipboardTextData;

ImGui_ImplAllegro5_Data() { memset(this, 0, sizeof(*this)); }
ImGui_ImplAllegro5_Data() { memset((void*)this, 0, sizeof(*this)); }
};

// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_dx10.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ struct ImGui_ImplDX10_Data
int VertexBufferSize;
int IndexBufferSize;

ImGui_ImplDX10_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
ImGui_ImplDX10_Data() { memset((void*)this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
};

struct VERTEX_CONSTANT_BUFFER
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_dx11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ struct ImGui_ImplDX11_Data
int VertexBufferSize;
int IndexBufferSize;

ImGui_ImplDX11_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
ImGui_ImplDX11_Data() { memset((void*)this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
};

struct VERTEX_CONSTANT_BUFFER
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_dx12.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ struct ImGui_ImplDX12_Data
UINT numFramesInFlight;
UINT frameIndex;

ImGui_ImplDX12_Data() { memset(this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
ImGui_ImplDX12_Data() { memset((void*)this, 0, sizeof(*this)); frameIndex = UINT_MAX; }
};

struct VERTEX_CONSTANT_BUFFER
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_dx9.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ struct ImGui_ImplDX9_Data
int VertexBufferSize;
int IndexBufferSize;

ImGui_ImplDX9_Data() { memset(this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
ImGui_ImplDX9_Data() { memset((void*)this, 0, sizeof(*this)); VertexBufferSize = 5000; IndexBufferSize = 10000; }
};

struct CUSTOMVERTEX
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_glfw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ struct ImGui_ImplGlfw_Data
GLFWcharfun PrevUserCallbackChar;
GLFWmonitorfun PrevUserCallbackMonitor;

ImGui_ImplGlfw_Data() { memset(this, 0, sizeof(*this)); }
ImGui_ImplGlfw_Data() { memset((void*)this, 0, sizeof(*this)); }
};

// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_opengl2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ struct ImGui_ImplOpenGL2_Data
{
GLuint FontTexture;

ImGui_ImplOpenGL2_Data() { memset(this, 0, sizeof(*this)); }
ImGui_ImplOpenGL2_Data() { memset((void*)this, 0, sizeof(*this)); }
};

// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_opengl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ struct ImGui_ImplOpenGL3_Data
GLsizeiptr IndexBufferSize;
bool HasClipOrigin;

ImGui_ImplOpenGL3_Data() { memset(this, 0, sizeof(*this)); }
ImGui_ImplOpenGL3_Data() { memset((void*)this, 0, sizeof(*this)); }
};

// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_sdl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ struct ImGui_ImplSDL2_Data
char* ClipboardTextData;
bool MouseCanUseGlobalState;

ImGui_ImplSDL2_Data() { memset(this, 0, sizeof(*this)); }
ImGui_ImplSDL2_Data() { memset((void*)this, 0, sizeof(*this)); }
};

// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_sdlrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ struct ImGui_ImplSDLRenderer_Data
{
SDL_Renderer* SDLRenderer;
SDL_Texture* FontTexture;
ImGui_ImplSDLRenderer_Data() { memset(this, 0, sizeof(*this)); }
ImGui_ImplSDLRenderer_Data() { memset((void*)this, 0, sizeof(*this)); }
};

// Backend data stored in io.BackendRendererUserData to allow support for multiple Dear ImGui contexts
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_vulkan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ struct ImGui_ImplVulkan_Data

ImGui_ImplVulkan_Data()
{
memset(this, 0, sizeof(*this));
memset((void*)this, 0, sizeof(*this));
BufferMemoryAlignment = 256;
}
};
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_vulkan.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ struct ImGui_ImplVulkanH_Window

ImGui_ImplVulkanH_Window()
{
memset(this, 0, sizeof(*this));
memset((void*)this, 0, sizeof(*this));
PresentMode = VK_PRESENT_MODE_MAX_ENUM_KHR;
ClearEnable = true;
}
Expand Down
2 changes: 1 addition & 1 deletion backends/imgui_impl_win32.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ struct ImGui_ImplWin32_Data
PFN_XInputGetState XInputGetState;
#endif

ImGui_ImplWin32_Data() { memset(this, 0, sizeof(*this)); }
ImGui_ImplWin32_Data() { memset((void*)this, 0, sizeof(*this)); }
};

// Backend data stored in io.BackendPlatformUserData to allow support for multiple Dear ImGui contexts
Expand Down
1 change: 0 additions & 1 deletion imgui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8069,7 +8069,6 @@ void ImGui::ErrorCheckEndFrameRecover(ImGuiErrorLogCallback log_callback, voi
IM_ASSERT(window->IsFallbackWindow);
break;
}
IM_ASSERT(window == g.CurrentWindow);
if (window->Flags & ImGuiWindowFlags_ChildWindow)
{
if (log_callback) log_callback(user_data, "Recovered from missing EndChild() for '%s'", window->Name);
Expand Down
8 changes: 4 additions & 4 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -2342,13 +2342,13 @@ struct ImGuiListClipper
// **None of the ImGui API are using ImColor directly but you can use it as a convenience to pass colors in either ImU32 or ImVec4 formats. Explicitly cast to ImU32 or ImVec4 if needed.
struct ImColor
{
ImVec4 Value;
ImVec4 Value;

ImColor() { Value.x = Value.y = Value.z = Value.w = 0.0f; }
constexpr ImColor() { }
constexpr ImColor(float r, float g, float b, float a = 1.0f) : Value(r, g, b, a) { }
constexpr ImColor(const ImVec4& col) : Value(col) {}
ImColor(int r, int g, int b, int a = 255) { float sc = 1.0f / 255.0f; Value.x = (float)r * sc; Value.y = (float)g * sc; Value.z = (float)b * sc; Value.w = (float)a * sc; }
ImColor(ImU32 rgba) { float sc = 1.0f / 255.0f; Value.x = (float)((rgba >> IM_COL32_R_SHIFT) & 0xFF) * sc; Value.y = (float)((rgba >> IM_COL32_G_SHIFT) & 0xFF) * sc; Value.z = (float)((rgba >> IM_COL32_B_SHIFT) & 0xFF) * sc; Value.w = (float)((rgba >> IM_COL32_A_SHIFT) & 0xFF) * sc; }
ImColor(float r, float g, float b, float a = 1.0f) { Value.x = r; Value.y = g; Value.z = b; Value.w = a; }
ImColor(const ImVec4& col) { Value = col; }
inline operator ImU32() const { return ImGui::ColorConvertFloat4ToU32(Value); }
inline operator ImVec4() const { return Value; }

Expand Down
2 changes: 1 addition & 1 deletion imgui_demo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3873,7 +3873,7 @@ static void ShowDemoWindowTables()
sprintf(buf, "Hello %d,%d", column, row);
if (contents_type == CT_Text)
ImGui::TextUnformatted(buf);
else if (contents_type)
else if (contents_type == CT_FillButton)
ImGui::Button(buf, ImVec2(-FLT_MIN, 0.0f));
}
}
Expand Down
2 changes: 1 addition & 1 deletion imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3878,7 +3878,7 @@ void ImGui::RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, Im
draw_list->PathFillConvex(col);
}

void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding)
void ImGui::RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding)
{
const bool fill_L = (inner.Min.x > outer.Min.x);
const bool fill_R = (inner.Max.x < outer.Max.x);
Expand Down
4 changes: 2 additions & 2 deletions imgui_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ namespace ImStb
#define IM_NEWLINE "\n"
#endif
#define IM_TABSIZE (4)
#define IM_MEMALIGN(_OFF,_ALIGN) (((_OFF) + (_ALIGN - 1)) & ~(_ALIGN - 1)) // Memory align e.g. IM_ALIGN(0,4)=0, IM_ALIGN(1,4)=4, IM_ALIGN(4,4)=4, IM_ALIGN(5,4)=8
#define IM_MEMALIGN(_OFF,_ALIGN) (((_OFF) + ((_ALIGN) - 1)) & ~((_ALIGN) - 1)) // Memory align e.g. IM_ALIGN(0,4)=0, IM_ALIGN(1,4)=4, IM_ALIGN(4,4)=4, IM_ALIGN(5,4)=8
#define IM_F32_TO_INT8_UNBOUND(_VAL) ((int)((_VAL) * 255.0f + ((_VAL)>=0 ? 0.5f : -0.5f))) // Unsaturated, for display purpose
#define IM_F32_TO_INT8_SAT(_VAL) ((int)(ImSaturate(_VAL) * 255.0f + 0.5f)) // Saturated, always output 0..255
#define IM_FLOOR(_VAL) ((float)(int)(_VAL)) // ImFloor() is not inlined in MSVC debug builds
Expand Down Expand Up @@ -2782,7 +2782,7 @@ namespace ImGui
IMGUI_API void RenderCheckMark(ImDrawList* draw_list, ImVec2 pos, ImU32 col, float sz);
IMGUI_API void RenderArrowPointingAt(ImDrawList* draw_list, ImVec2 pos, ImVec2 half_sz, ImGuiDir direction, ImU32 col);
IMGUI_API void RenderRectFilledRangeH(ImDrawList* draw_list, const ImRect& rect, ImU32 col, float x_start_norm, float x_end_norm, float rounding);
IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, ImRect outer, ImRect inner, ImU32 col, float rounding);
IMGUI_API void RenderRectFilledWithHole(ImDrawList* draw_list, const ImRect& outer, const ImRect& inner, ImU32 col, float rounding);

#ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS
// [1.71: 2019/06/07: Updating prototypes of some of the internal functions. Leaving those for reference for a short while]
Expand Down
3 changes: 1 addition & 2 deletions imgui_widgets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,9 +843,8 @@ bool ImGui::CollapseButton(ImGuiID id, const ImVec2& pos)
// Render
ImU32 bg_col = GetColorU32((held && hovered) ? ImGuiCol_ButtonActive : hovered ? ImGuiCol_ButtonHovered : ImGuiCol_Button);
ImU32 text_col = GetColorU32(ImGuiCol_Text);
ImVec2 center = bb.GetCenter();
if (hovered || held)
window->DrawList->AddCircleFilled(center/*+ ImVec2(0.0f, -0.5f)*/, g.FontSize * 0.5f + 1.0f, bg_col, 12);
window->DrawList->AddCircleFilled(bb.GetCenter()/*+ ImVec2(0.0f, -0.5f)*/, g.FontSize * 0.5f + 1.0f, bg_col, 12);
RenderArrow(window->DrawList, bb.Min + g.Style.FramePadding, text_col, window->Collapsed ? ImGuiDir_Right : ImGuiDir_Down, 1.0f);

// Switch to moving the window after mouse is moved beyond the initial drag threshold
Expand Down
2 changes: 1 addition & 1 deletion misc/freetype/imgui_freetype.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ struct ImFontBuildSrcGlyphFT
uint32_t Codepoint;
unsigned int* BitmapData; // Point within one of the dst_tmp_bitmap_buffers[] array

ImFontBuildSrcGlyphFT() { memset(this, 0, sizeof(*this)); }
ImFontBuildSrcGlyphFT() { memset((void*)this, 0, sizeof(*this)); }
};

struct ImFontBuildSrcDataFT
Expand Down

0 comments on commit fd06ed8

Please sign in to comment.