# HG changeset patch # User Rik # Date 1389940428 28800 # Node ID c8d6ca222bccbc8cbeb1fa3cf2a23639ec036319 # Parent 2ed9498e4a74be0c8e58244ea05c2fc1c0ea9cca 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. diff -r 2ed9498e4a74 -r c8d6ca222bcc libinterp/corefcn/gl-render.cc --- 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 (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 ();