Skip to content

Commit

Permalink
Add ability to scale anti-alias fringe. This enable users to keep geo…
Browse files Browse the repository at this point in the history
…metry sharp while scaling vertex buffer content.
  • Loading branch information
thedmd committed May 23, 2020
1 parent c8cde28 commit 39cde5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
1 change: 1 addition & 0 deletions imgui.h
Original file line number Diff line number Diff line change
Expand Up @@ -1984,6 +1984,7 @@ struct ImDrawList
ImVector<ImTextureID> _TextureIdStack; // [Internal]
ImVector<ImVec2> _Path; // [Internal] current path building
ImDrawListSplitter _Splitter; // [Internal] for channels api
float _FringeScale; // [Internal] anti-alias fringe is scaled by this value, this helps to keep things sharp while zooming at vertex buffer content

// If you want to create ImDrawList instances, pass them ImGui::GetDrawListSharedData() or create and use your own ImDrawListSharedData (so you can use ImDrawList without ImGui)
ImDrawList(const ImDrawListSharedData* shared_data) { _Data = shared_data; _OwnerName = NULL; Clear(); }
Expand Down
7 changes: 4 additions & 3 deletions imgui_draw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,7 @@ void ImDrawList::Clear()
_TextureIdStack.resize(0);
_Path.resize(0);
_Splitter.Clear();
_FringeScale = 1.0f;
}

void ImDrawList::ClearFreeMemory()
Expand Down Expand Up @@ -632,11 +633,11 @@ void ImDrawList::AddPolyline(const ImVec2* points, const int points_count, ImU32
if (!closed)
count = points_count-1;

const bool thick_line = (thickness > 1.0f);
const bool thick_line = (thickness > _FringeScale);
if (Flags & ImDrawListFlags_AntiAliasedLines)
{
// Anti-aliased stroke
const float AA_SIZE = 1.0f;
const float AA_SIZE = 1.0f * _FringeScale;
const ImU32 col_trans = col & ~IM_COL32_A_MASK;

const int idx_count = thick_line ? count*18 : count*12;
Expand Down Expand Up @@ -820,7 +821,7 @@ void ImDrawList::AddConvexPolyFilled(const ImVec2* points, const int points_coun
if (Flags & ImDrawListFlags_AntiAliasedFill)
{
// Anti-aliased Fill
const float AA_SIZE = 1.0f;
const float AA_SIZE = 1.0f * _FringeScale;
const ImU32 col_trans = col & ~IM_COL32_A_MASK;
const int idx_count = (points_count-2)*3 + points_count*6;
const int vtx_count = (points_count*2);
Expand Down

0 comments on commit 39cde5c

Please sign in to comment.