New renderer is feature-complete

master
Joey Pollack 3 years ago
parent 7f9cb5ce58
commit 225199dfcc

@ -5,6 +5,7 @@
☐ Binary serializeable ☐ Binary serializeable
Renderer rewrite: Renderer rewrite:
☐ Re-integrate the new renderer into the editor
✔ Add double buffer to the VertexBuffer class with a Flush method to send the verts to the gpu @high @done(22-08-29 15:14) ✔ Add double buffer to the VertexBuffer class with a Flush method to send the verts to the gpu @high @done(22-08-29 15:14)
✔ Add Draw method to the VertexBuffer class @high @done(22-08-29 15:06) ✔ Add Draw method to the VertexBuffer class @high @done(22-08-29 15:06)
✔ Batch rendering minimally working @done(22-08-12 19:19) ✔ Batch rendering minimally working @done(22-08-12 19:19)
@ -22,9 +23,9 @@ Renderer rewrite:
✔ Generate single conposite texture of all font bitmap data @done(22-08-18 16:13) ✔ Generate single conposite texture of all font bitmap data @done(22-08-18 16:13)
✔ DrawString @done(22-08-18 16:14) ✔ DrawString @done(22-08-18 16:14)
☐ DrawElipse @low ✔ DrawElipse @low @done(22-08-30 14:26)
☐ Elipse Shader ✔ Elipse Shader @done(22-08-30 14:26)
☐ Elipse Batch data ✔ Elipse Batch data @done(22-08-30 14:26)
✔ DrawLine @low @done(22-08-29 15:14) ✔ DrawLine @low @done(22-08-29 15:14)
✔ Line Shader @done(22-08-22 19:46) ✔ Line Shader @done(22-08-22 19:46)

@ -269,12 +269,30 @@ namespace lunarium
void Renderer2D::DrawBox(Rectangle box, Color color, float thickness, float angle) void Renderer2D::DrawBox(Rectangle box, Color color, float thickness, float angle)
{ {
// TODO: Use DrawLine to make a box DrawLine(glm::vec2(box.left(), box.top()), glm::vec2(box.right(), box.top()), color, thickness, angle);
DrawLine(glm::vec2(box.right(), box.top()), glm::vec2(box.right(), box.bottom()), color, thickness, angle);
DrawLine(glm::vec2(box.right(), box.bottom()), glm::vec2(box.left(), box.bottom()), color, thickness, angle);
DrawLine(glm::vec2(box.left(), box.bottom()), glm::vec2(box.left(), box.top()), color, thickness, angle);
} }
void Renderer2D::DrawEllipse(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution, float thickness, float angle) void Renderer2D::DrawEllipse(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution, float thickness, float angle)
{ {
// TODO: Use DrawLine to make ellipse float stride = 362.0f / resolution;
float cur_deg = 0.0f;
float rad = cur_deg * 3.14159f / 180.0f;
glm::vec2 prev_point = glm::vec2(center_point.x + (radii.x * cos(rad)), center_point.y + (radii.y * sin(rad)));
glm::vec2 first_point = prev_point;
cur_deg += stride;
for (int i = 1; i <= resolution; i++, cur_deg += stride)
{
rad = cur_deg * 3.14159f / 180.0f;
glm::vec2 cur_point(center_point.x + (radii.x * cos(rad)), center_point.y + (radii.y * sin(rad)));
DrawLine(prev_point, cur_point, color, thickness, angle);
prev_point = cur_point;
}
DrawLine(prev_point, first_point, color, thickness, angle);
} }
void Renderer2D::DrawEllipseFilled(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution, float angle) void Renderer2D::DrawEllipseFilled(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution, float angle)

@ -52,11 +52,11 @@ namespace lunarium
/// sub_texture_area is the area of the texture to draw /// sub_texture_area is the area of the texture to draw
void DrawQuad(Rectangle quad, Color color, Texture* texture = nullptr, float angle = 0.0f, Rectangle sub_texture_area = Rectangle(-1, -1, -1, -1)); void DrawQuad(Rectangle quad, Color color, Texture* texture = nullptr, float angle = 0.0f, Rectangle sub_texture_area = Rectangle(-1, -1, -1, -1));
void DrawLine(glm::vec2 point_a, glm::vec2 point_b, Color color, float thickness = 1.0f, float angle = 0.0f); void DrawLine(glm::vec2 point_a, glm::vec2 point_b, Color color, float thickness = 1.0f, float angle = 0.0f);
void DrawBox(Rectangle box, Color color, float thickness = 1.0f, float angle = 0.0f); void DrawBox(Rectangle box, Color color, float thickness = 1.5f, float angle = 0.0f);
/// Resolution is the number of sides the ellipse will have. /// Resolution is the number of sides the ellipse will have.
/// So small numbers can be used to make ngon shapes /// So small numbers can be used to make ngon shapes
void DrawEllipse(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution = 50, float thickness = 1.0f, float angle = 0.0f); void DrawEllipse(glm::vec2 center_point, glm::vec2 radii, Color color, int resolution = 50, float thickness = 1.5f, float angle = 0.0f);
/// Resolution is the number of sides the ellipse will have. /// Resolution is the number of sides the ellipse will have.
/// So small numbers can be used to make ngon shapes /// So small numbers can be used to make ngon shapes

@ -252,6 +252,7 @@ namespace lunarium
{ {
case ShapeMode::Boxes: case ShapeMode::Boxes:
{ {
g.DrawBox(Rectangle(300, 300, 50, 50), Color::Green());
} break; } break;
@ -268,7 +269,8 @@ namespace lunarium
case ShapeMode::Ellipses: case ShapeMode::Ellipses:
{ {
g.DrawEllipseFilled(glm::vec2(300.0f, 300.0f), glm::vec2(mEllipseRadii[0], mEllipseRadii[1]), Color::Blue(), mEllipseResolution); g.DrawEllipseFilled(glm::vec2(350.0f, 300.0f), glm::vec2(mEllipseRadii[0], mEllipseRadii[1]), Color::Blue(), mEllipseResolution);
g.DrawEllipse(glm::vec2(800.0f, 300.0f), glm::vec2(mEllipseRadii[0], mEllipseRadii[1]), Color::Red(), mEllipseResolution);
} break; } break;
} }

Loading…
Cancel
Save