Snap text vertices to pixels in ui painter

This commit is contained in:
Nikita Lisitsa 2021-08-06 16:09:29 +03:00
parent ef9e820e90
commit f15dd26bb9

View file

@ -284,10 +284,17 @@ void main()
std::uint32_t const depth = impl().depth++;
std::uint32_t const base = batch.vertices.size();
batch.vertices.push_back({rect.corner(0.f, 0.f), depth, color, tc(0.f, 0.f)});
batch.vertices.push_back({rect.corner(1.f, 0.f), depth, color, tc(1.f, 0.f)});
batch.vertices.push_back({rect.corner(0.f, 1.f), depth, color, tc(0.f, 1.f)});
batch.vertices.push_back({rect.corner(1.f, 1.f), depth, color, tc(1.f, 1.f)});
auto round = [](geom::point<float, 2> p)
{
p[0] = std::round(p[0]);
p[1] = std::round(p[1]);
return p;
};
batch.vertices.push_back({round(rect.corner(0.f, 0.f)), depth, color, tc(0.f, 0.f)});
batch.vertices.push_back({round(rect.corner(1.f, 0.f)), depth, color, tc(1.f, 0.f)});
batch.vertices.push_back({round(rect.corner(0.f, 1.f)), depth, color, tc(0.f, 1.f)});
batch.vertices.push_back({round(rect.corner(1.f, 1.f)), depth, color, tc(1.f, 1.f)});
batch.indices.insert(batch.indices.end(), {base + 0, base + 1, base + 2, base + 2, base + 1, base + 3});
}