Fix line number clipping, rendering issue
This commit is contained in:
@@ -90,6 +90,14 @@ Vec2I GetMid(Rect2I r) {
|
||||
return result;
|
||||
}
|
||||
|
||||
Rect2 Round(Rect2 r) {
|
||||
r.min.x = roundf(r.min.x);
|
||||
r.max.x = roundf(r.max.x);
|
||||
r.min.y = roundf(r.min.y);
|
||||
r.max.y = roundf(r.max.y);
|
||||
return r;
|
||||
}
|
||||
|
||||
Rect2I CutLeft(Rect2I *r, Int value) {
|
||||
Int minx = r->min.x;
|
||||
r->min.x = Min(r->min.x + value, r->max.x);
|
||||
|
||||
@@ -288,7 +288,7 @@ void PushVertex2D(Allocator allocator, VertexList2D *list, Vertex2D *vertices, i
|
||||
for (int i = 0; i < count; i += 1) result[i] = vertices[i];
|
||||
}
|
||||
|
||||
void PushQuad2D(Allocator arena, VertexList2D *list, Rect2 rect, Rect2 tex, Color color, float rotation = 0.f, Vec2 rotation_point = {}) {
|
||||
void PushQuad2D(Allocator arena, VertexList2D *list, Rect2 rect, Rect2 tex, Color color) {
|
||||
Vertex2D *v = AllocVertex2D(arena, list, 6);
|
||||
v[0] = { {rect.min.x, rect.max.y}, { tex.min.x, tex.max.y}, color };
|
||||
v[1] = { {rect.max.x, rect.max.y}, { tex.max.x, tex.max.y}, color };
|
||||
@@ -296,15 +296,6 @@ void PushQuad2D(Allocator arena, VertexList2D *list, Rect2 rect, Rect2 tex, Colo
|
||||
v[3] = { {rect.min.x, rect.min.y}, { tex.min.x, tex.min.y}, color };
|
||||
v[4] = { {rect.max.x, rect.max.y}, { tex.max.x, tex.max.y}, color };
|
||||
v[5] = { {rect.max.x, rect.min.y}, { tex.max.x, tex.min.y}, color };
|
||||
if (rotation != 0.f) {
|
||||
float s = sinf(rotation);
|
||||
float c = cosf(rotation);
|
||||
for (int i = 0; i < 6; i += 1) {
|
||||
v[i].pos -= rotation_point;
|
||||
v[i].pos = {v[i].pos.x * c + v[i].pos.y * (-s), v[i].pos.x * s + v[i].pos.y * c};
|
||||
v[i].pos += rotation_point;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DrawRect(Rect2 rect, Color color) {
|
||||
@@ -336,7 +327,7 @@ Vec2 DrawString(Font *font, String16 string, Vec2 pos, Color color, bool draw =
|
||||
Glyph *g = GetGlyph(font, it);
|
||||
Rect2 rect = Rect2FromSize(pos + g->offset, g->size);
|
||||
if (draw && it != '\n' && it != ' ' && it != '\t') {
|
||||
PushQuad2D(RenderArena, &Vertices, rect, g->atlas_bounding_box, color);
|
||||
PushQuad2D(RenderArena, &Vertices, Round(rect), g->atlas_bounding_box, color);
|
||||
}
|
||||
pos.x += g->xadvance;
|
||||
}
|
||||
|
||||
@@ -65,7 +65,7 @@ void DrawVisibleText(Window *window, Color tint) {
|
||||
Rect2 rect = Rect2FromSize(p + g->offset, g->size);
|
||||
|
||||
if (codepoint != '\n' && codepoint != '\r' && codepoint != ' ' && codepoint != '\t') {
|
||||
PushQuad2D(RenderArena, &Vertices, rect, g->atlas_bounding_box, tint);
|
||||
PushQuad2D(RenderArena, &Vertices, Round(rect), g->atlas_bounding_box, tint);
|
||||
}
|
||||
|
||||
text_offset_x += window->font->char_spacing;
|
||||
|
||||
Reference in New Issue
Block a user