From: Andy Spencer Date: Thu, 27 Oct 2011 07:28:47 +0000 (+0000) Subject: Use rounded corners for GritsPoly X-Git-Tag: v0.6~7 X-Git-Url: http://pileus.org/git/?p=grits;a=commitdiff_plain;h=f54436e90fe38ef17e85dbdfea64a8916ceae872 Use rounded corners for GritsPoly --- diff --git a/src/objects/grits-poly.c b/src/objects/grits-poly.c index 720e3b1..e33ca2d 100644 --- a/src/objects/grits-poly.c +++ b/src/objects/grits-poly.c @@ -88,18 +88,54 @@ static void grits_poly_draw(GritsObject *_poly, GritsOpenGL *opengl) glDisable(GL_ALPHA_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); + glEnable(GL_POLYGON_OFFSET_FILL); - glPolygonOffset(1, 1); + glEnable(GL_POLYGON_OFFSET_LINE); + glEnable(GL_POLYGON_OFFSET_POINT); + if (poly->color[3]) { + /* Draw background farthest back */ + glPolygonOffset(3, 3); glColor4dv(poly->color); + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); grits_poly_runlist(poly, 0, grits_poly_tess); } - glLineWidth(poly->width); - glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + + glEnable(GL_POLYGON_SMOOTH); + glEnable(GL_LINE_SMOOTH); + glEnable(GL_POINT_SMOOTH); + + if (!poly->color[3] && poly->border[3] && poly->width > 1) { + /* Draw line border in the middle */ + glColor4d(0,0,0,1); + + glPointSize(poly->width*2); + glLineWidth(poly->width*2); + + glPolygonOffset(2, 2); + + glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); + grits_poly_runlist(poly, 1, grits_poly_outline); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + grits_poly_runlist(poly, 1, grits_poly_outline); + } + if (poly->border[3]) { + /* Draw border front-most */ glColor4dv(poly->border); + + glPointSize(poly->width); + glLineWidth(poly->width); + + glPolygonOffset(1, 1); + if (poly->width > 1) { + glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); + grits_poly_runlist(poly, 1, grits_poly_outline); + } + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); grits_poly_runlist(poly, 1, grits_poly_outline); } + glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); glPopAttrib(); } diff --git a/src/plugins/test.c b/src/plugins/test.c index 44e39d0..b7435ab 100644 --- a/src/plugins/test.c +++ b/src/plugins/test.c @@ -125,7 +125,7 @@ void _load_poly(GritsPluginTest *test) test->poly->color[2] = test->poly->border[2] = 0; test->poly->color[3] = 0.2; test->poly->border[3] = 1; - test->poly->width = 10; + test->poly->width = 6; grits_viewer_add(test->viewer, GRITS_OBJECT(test->poly), GRITS_LEVEL_OVERLAY, TRUE); g_signal_connect(test->poly, "enter", G_CALLBACK(on_poly_enter), NULL); g_signal_connect(test->poly, "leave", G_CALLBACK(on_poly_leave), NULL);