changeset 18296:c8d6ca222bcc

Make "edgecolor"="flat" for patch objects compatible with Matlab. * gl-render.cc (patch_tesselator::vertex): Apply per edge-coloring if color_mode==1 (flat) and polygon is being used to draw edges of patch. * gl-render.cc (draw_patch): Reverse the order of vertices presented to OpenGL.
author Rik <rik@octave.org>
date Thu, 16 Jan 2014 22:33:48 -0800
parents 2ed9498e4a74
children 1589b2fc74ae
files libinterp/corefcn/gl-render.cc
diffstat 1 files changed, 6 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc	Thu Jan 16 21:44:07 2014 -0800
+++ b/libinterp/corefcn/gl-render.cc	Thu Jan 16 22:33:48 2014 -0800
@@ -437,12 +437,11 @@
       = reinterpret_cast<vertex_data::vertex_data_rep *> (data);
     //printf ("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2));
 
-    // FIXME: why did I need to keep the first vertex of the face
-    // in JHandles? I think it's related to the fact that the
-    // tessellation process might re-order the vertices, such that
-    // the first one you get here might not be the first one of the face;
-    // but I can't figure out the actual reason.
-    if (color_mode == 2)
+    // NOTE: OpenGL can re-order vertices so "first" is basically meaningless
+    // in this callback routine.  For "flat" coloring of FaceColor the first
+    // vertex must be identified in the draw_patch routine.
+
+    if (color_mode == 2 || (color_mode == 1 && ! is_filled ()))
       {
         Matrix col = v->color;
 
@@ -2457,7 +2456,7 @@
                   tess.begin_polygon (false);
                   tess.begin_contour ();
 
-                  for (int j = 0; j < count_f(i); j++)
+                  for (int j = count_f(i)-1; j >= 0; j--)
                     {
                       vertex_data::vertex_data_rep *vv
                         = vdata[i+j*fr].get_rep ();