Implement OutlineRect2D
This commit is contained in:
@@ -47,7 +47,7 @@ namespace JGL {
|
||||
|
||||
Vector2 ScreenToViewport(const Vector2& v)
|
||||
{
|
||||
// TODO: Implement matrix transformation
|
||||
// TODO: Implement (CORRECT!!!) matrix transformation
|
||||
float x = v.x / 600.f;
|
||||
float y = v.y / 600.f;
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace JGL {
|
||||
}
|
||||
Vector2 ViewportToScreen(const Vector2& v)
|
||||
{
|
||||
// TODO: Implement matrix transformation
|
||||
// TODO: Implement (CORRECT!!!) matrix transformation
|
||||
}
|
||||
|
||||
void DrawPixel2D(const Color3 &, int x, int y);
|
||||
@@ -88,7 +88,18 @@ namespace JGL {
|
||||
glVertex2f(vp_pos.x + vp_size.x, vp_pos.y);
|
||||
glEnd();
|
||||
}
|
||||
void OutlineRect2D (const Vector2& pos, const Vector2& size, const Color3& color, float thickness = 1);
|
||||
void OutlineRect2D (const Vector2& pos, const Vector2& size, const Color3& color, float thickness = 1)
|
||||
{
|
||||
auto vp_pos = ScreenToViewport(pos);
|
||||
auto vp_size = ScreenToViewport(size);
|
||||
glBegin(GL_LINE_LOOP);
|
||||
glColor3f(color.r, color.g, color.b);
|
||||
glVertex2f(vp_pos.x, vp_pos.y);
|
||||
glVertex2f(vp_pos.x, vp_pos.y + vp_size.y);
|
||||
glVertex2f(vp_pos.x + vp_size.x, vp_pos.y + vp_size.y);
|
||||
glVertex2f(vp_pos.x + vp_size.x, vp_pos.y);
|
||||
glEnd();
|
||||
}
|
||||
void FillRoundedRect2D (const Vector2& pos, const Vector2& size, const Color3& color, float radius);
|
||||
void OutlineRoundedRect2D(const Vector2& pos, const Vector2& size, const Color3& color, float radius, float thickness = 1);
|
||||
void OutlinePolygon2D ();
|
||||
|
Reference in New Issue
Block a user