Browse Source

Texture-based round corners: Fix building for stroke width 1,2,4 instead of 1,3,4.

features/tex_round_corners
ocornut 4 years ago
parent
commit
4ff00a9032
  1. 10
      imgui.h
  2. 7
      imgui_internal.h

10
imgui.h

@ -3256,11 +3256,11 @@ struct ImFontGlyphRangesBuilder
// Data for texture-based rounded corners for a given radius
struct ImFontRoundedCornerData
{
ImVec4 TexUvFilled; // UV of filled round corner quad in the atlas (only valid when stroke width is 1)
ImVec4 TexUvStroked; // UV of stroked round corner quad in the atlas
float ParametricStrokeWidth; // Pre-calculated value for stroke width divided by the radius
int RectId; // Rect ID in the atlas, or -1 if there is no data
bool StrokedUsesAlternateUVs; // True if stroked drawing should use the alternate (i.e. other corner) UVs
ImVec4 TexUvFilled; // UV of filled round corner quad in the atlas (only valid when stroke width is 1)
ImVec4 TexUvStroked; // UV of stroked round corner quad in the atlas
float ParametricStrokeWidth; // Pre-calculated value for stroke width divided by the radius
int RectId; // Rect ID in the atlas, or -1 if there is no data
bool StrokedUsesAlternateUVs; // True if stroked drawing should use the alternate (i.e. other corner) UVs
};
// See ImFontAtlas::AddCustomRectXXX functions.

7
imgui_internal.h

@ -778,7 +778,6 @@ struct IMGUI_API ImDrawListSharedData
ImU8 CircleSegmentCounts[64]; // Precomputed segment count for given radius before we calculate it dynamically (to avoid calculation overhead)
const ImVec4* TexUvLines; // UV of anti-aliased lines in the atlas
// FIXME-ROUNDCORNERS: WIP + need to remove CircleVtx12 before PR
ImVector<ImFontRoundedCornerData>* TexRoundCornerData; // Data for texture-based rounded corners, indexed by radius
ImDrawListSharedData();
@ -3492,11 +3491,11 @@ IMGUI_API void ImFontAtlasBuildMultiplyRectAlpha8(const unsigned char table
// Note that stroke width increases effective radius, so (e.g.) a max radius circle will have to use the fallback path if stroke width is > 1
const int ImFontAtlasRoundCornersMaxSize = 32; // Maximum size of rounded corner texture to generate in fonts
const int ImFontAtlasRoundCornersMaxStrokeWidth = 5; // Maximum stroke width of rounded corner texture to generate in fonts
// Bit mask for which stroke widths should have textures generated for them (the default of 0xD means widths 1, 2 and 4)
const int ImFontAtlasRoundCornersMaxStrokeWidth = 4; // Maximum stroke width of rounded corner texture to generate in fonts
// Bit mask for which stroke widths should have textures generated for them (the default of 0x0B means widths 1, 2 and 4)
// Only bits up to ImFontAtlasRoundCornersMaxStrokeWidth are considered, and bit 0 (stroke width 1) must always be set
// Optimally there should be an odd number of bits set, as the texture packing packs the data in pairs, with one half of one pair being occupied by the filled texture
const int ImFontAtlasRoundCornersStrokeWidthMask = 0xD;
const int ImFontAtlasRoundCornersStrokeWidthMask = 0x0B;
//-----------------------------------------------------------------------------
// [SECTION] Test Engine specific hooks (imgui_test_engine)

Loading…
Cancel
Save