Mercurial > hg > octave-nkf
changeset 19012:096b1a159d1f
Correctly render unclosed contour of a patch object.
* gl-render.cc (draw_patch): Use GL_LINE_STRIP for an unclosed contour rather
than tesselator. Add vertices in reverse order to match Matlab coloring.
Add implementation for per vertex colors to support "flat" and "interp" edgecolor
modes.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 10 Jun 2014 09:08:33 -0700 |
parents | e275d15c27b5 |
children | 87c3848cf3c0 |
files | libinterp/corefcn/gl-render.cc |
diffstat | 1 files changed, 31 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/libinterp/corefcn/gl-render.cc +++ b/libinterp/corefcn/gl-render.cc @@ -2215,7 +2215,6 @@ Matrix a; int nv = v.rows (); - // int vmax = v.columns (); int nf = f.rows (); int fcmax = f.columns (); @@ -2477,10 +2476,14 @@ { if (clip_f(i)) { - // This is an unclosed contour. Draw it as a line. + // This is an unclosed contour. Draw it as a line. bool flag = false; - for (int j = 0; j < count_f(i); j++) + glShadeModel ((ec_mode == INTERP || el_mode == GOURAUD) + ? GL_SMOOTH : GL_FLAT); + + // Add vertices in reverse order for Matlab compatibility + for (int j = count_f(i)-1; j >= 0; j--) { if (! clip(int (f(i,j) - 1))) { @@ -2492,6 +2495,13 @@ flag = true; glBegin (GL_LINE_STRIP); } + if (ec_mode != UNIFORM) + { + Matrix col = vv->color; + + if (col.numel () == 3) + glColor3dv (col.data ()); + } glVertex3d (m(0), m(1), m(2)); } else if (flag) @@ -2500,11 +2510,28 @@ glEnd (); } } + // Do loop body with vertex N to "close" GL_LINE_STRIP + // from vertex 0 to vertex N. + int j = count_f(i)-1; + if (flag && ! clip(int (f(i,j) - 1))) + { + vertex_data::vertex_data_rep *vv + = vdata[i+j*fr].get_rep (); + const Matrix m = vv->coords; + if (ec_mode != UNIFORM) + { + Matrix col = vv->color; + + if (col.numel () == 3) + glColor3dv (col.data ()); + } + glVertex3d (m(0), m(1), m(2)); + } if (flag) glEnd (); } - else + else // Normal edge contour drawn with tesselator { tess.begin_polygon (false); tess.begin_contour ();