]> Pileus Git - grits/blobdiff - src/objects/grits-poly.c
Update windowing system tests
[grits] / src / objects / grits-poly.c
index 720e3b1bed37ea29f5af2d7c94104b8a6d539eb9..5d54a70da80d06d6f22ff2939c03d97af2421f44 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Andy Spencer <andy753421@gmail.com>
+ * Copyright (C) 2010-2011 Andy Spencer <andy753421@gmail.com>
  *
  * This program is free software: you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -23,8 +23,7 @@
  */
 
 #include <config.h>
-#include <GL/gl.h>
-#include <GL/glu.h>
+#include "gtkgl.h"
 #include "grits-poly.h"
 
 /* Drawing */
@@ -83,23 +82,60 @@ static void grits_poly_draw(GritsObject *_poly, GritsOpenGL *opengl)
        //g_debug("GritsPoly: draw");
        GritsPoly *poly = GRITS_POLY(_poly);
 
-       glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT);
+       glPushAttrib(GL_COLOR_BUFFER_BIT | GL_ENABLE_BIT | GL_CURRENT_BIT |
+                       GL_POINT_BIT | GL_LINE_BIT | GL_POLYGON_BIT);
        glDisable(GL_TEXTURE_2D);
        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();
 }
@@ -116,7 +152,7 @@ static void grits_poly_pick(GritsObject *_poly, GritsOpenGL *opengl)
 
 static gboolean grits_poly_delete(gpointer list)
 {
-       glDeleteLists((guint)list, 1);
+       glDeleteLists((guintptr)list, 1);
        return FALSE;
 }
 
@@ -205,8 +241,8 @@ static void grits_poly_finalize(GObject *_poly)
 {
        //g_debug("GritsPoly: finalize");
        GritsPoly *poly = GRITS_POLY(_poly);
-       if (poly->list[0]) g_idle_add(grits_poly_delete, (gpointer)poly->list[0]);
-       if (poly->list[1]) g_idle_add(grits_poly_delete, (gpointer)poly->list[1]);
+       if (poly->list[0]) g_idle_add(grits_poly_delete, (gpointer)(guintptr)poly->list[0]);
+       if (poly->list[1]) g_idle_add(grits_poly_delete, (gpointer)(guintptr)poly->list[1]);
 }
 
 static void grits_poly_class_init(GritsPolyClass *klass)