comparison src/gl-render.cc @ 11586:12df7854fa7c

strip trailing whitespace from source files
author John W. Eaton <jwe@octave.org>
date Thu, 20 Jan 2011 17:24:59 -0500
parents 1473d0cf86d2
children f4689107dd8c
comparison
equal deleted inserted replaced
11585:1473d0cf86d2 11586:12df7854fa7c
61 { 61 {
62 protected: 62 protected:
63 class texture_rep 63 class texture_rep
64 { 64 {
65 public: 65 public:
66 texture_rep (void) 66 texture_rep (void)
67 : id (), w (), h (), tw (), th (), tx (), ty (), 67 : id (), w (), h (), tw (), th (), tx (), ty (),
68 valid (false), count (1) 68 valid (false), count (1)
69 { } 69 { }
70 70
71 texture_rep (GLuint id_arg, int w_arg, int h_arg, int tw_arg, int th_arg) 71 texture_rep (GLuint id_arg, int w_arg, int h_arg, int tw_arg, int th_arg)
72 : id (id_arg), w (w_arg), h (h_arg), tw (tw_arg), th (th_arg), 72 : id (id_arg), w (w_arg), h (h_arg), tw (tw_arg), th (th_arg),
73 tx (double(w)/tw), ty (double(h)/th), valid (true), 73 tx (double(w)/tw), ty (double(h)/th), valid (true),
129 void bind (int mode = GL_TEXTURE_2D) const 129 void bind (int mode = GL_TEXTURE_2D) const
130 { rep->bind (mode); } 130 { rep->bind (mode); }
131 131
132 void tex_coord (double q, double r) const 132 void tex_coord (double q, double r) const
133 { rep->tex_coord (q, r); } 133 { rep->tex_coord (q, r); }
134 134
135 bool is_valid (void) const 135 bool is_valid (void) const
136 { return rep->valid; } 136 { return rep->valid; }
137 }; 137 };
138 138
139 static int 139 static int
303 bool is_filled (void) const { return fill; } 303 bool is_filled (void) const { return fill; }
304 304
305 private: 305 private:
306 static void CALLBACK tess_begin (GLenum type, void *t) 306 static void CALLBACK tess_begin (GLenum type, void *t)
307 { reinterpret_cast<opengl_tesselator *> (t)->begin (type); } 307 { reinterpret_cast<opengl_tesselator *> (t)->begin (type); }
308 308
309 static void CALLBACK tess_end (void *t) 309 static void CALLBACK tess_end (void *t)
310 { reinterpret_cast<opengl_tesselator *> (t)->end (); } 310 { reinterpret_cast<opengl_tesselator *> (t)->end (); }
311 311
312 static void CALLBACK tess_vertex (void *v, void *t) 312 static void CALLBACK tess_vertex (void *v, void *t)
313 { reinterpret_cast<opengl_tesselator *> (t)->vertex (v); } 313 { reinterpret_cast<opengl_tesselator *> (t)->vertex (v); }
314 314
315 static void CALLBACK tess_combine (GLdouble c[3], void *v[4], GLfloat w[4], 315 static void CALLBACK tess_combine (GLdouble c[3], void *v[4], GLfloat w[4],
316 void **out, void *t) 316 void **out, void *t)
317 { reinterpret_cast<opengl_tesselator *> (t)->combine (c, v, w, out); } 317 { reinterpret_cast<opengl_tesselator *> (t)->combine (c, v, w, out); }
318 318
319 static void CALLBACK tess_edge_flag (GLboolean flag, void *t) 319 static void CALLBACK tess_edge_flag (GLboolean flag, void *t)
320 { reinterpret_cast<opengl_tesselator *> (t)->edge_flag (flag); } 320 { reinterpret_cast<opengl_tesselator *> (t)->edge_flag (flag); }
321 321
322 static void CALLBACK tess_error (GLenum err, void *t) 322 static void CALLBACK tess_error (GLenum err, void *t)
323 { reinterpret_cast<opengl_tesselator *> (t)->error (err); } 323 { reinterpret_cast<opengl_tesselator *> (t)->error (err); }
324 324
325 private: 325 private:
326 GLUtesselator *glu_tess; 326 GLUtesselator *glu_tess;
344 float specular_exp; 344 float specular_exp;
345 345
346 // reference counter 346 // reference counter
347 int count; 347 int count;
348 348
349 vertex_data_rep (void) 349 vertex_data_rep (void)
350 : coords (), color (), normal (), alpha (), 350 : coords (), color (), normal (), alpha (),
351 ambient (), diffuse (), specular (), specular_exp (),count (1) { } 351 ambient (), diffuse (), specular (), specular_exp (),count (1) { }
352 352
353 vertex_data_rep (const Matrix& c, const Matrix& col, const Matrix& n, 353 vertex_data_rep (const Matrix& c, const Matrix& col, const Matrix& n,
354 double a, float as, float ds, float ss, float se) 354 double a, float as, float ds, float ss, float se)
440 vertex_data::vertex_data_rep *v 440 vertex_data::vertex_data_rep *v
441 = reinterpret_cast<vertex_data::vertex_data_rep *> (data); 441 = reinterpret_cast<vertex_data::vertex_data_rep *> (data);
442 //printf("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2)); 442 //printf("patch_tesselator::vertex (%g, %g, %g)\n", v->coords(0), v->coords(1), v->coords(2));
443 443
444 // FIXME: why did I need to keep the first vertex of the face 444 // FIXME: why did I need to keep the first vertex of the face
445 // in JHandles? I think it's related to the fact that the 445 // in JHandles? I think it's related to the fact that the
446 // tessellation process might re-order the vertices, such that 446 // tessellation process might re-order the vertices, such that
447 // the first one you get here might not be the first one of the face; 447 // the first one you get here might not be the first one of the face;
448 // but I can't figure out the actual reason. 448 // but I can't figure out the actual reason.
449 if (color_mode > 0 && (first || color_mode == 2)) 449 if (color_mode > 0 && (first || color_mode == 2))
450 { 450 {
538 void 538 void
539 opengl_renderer::draw (const graphics_object& go) 539 opengl_renderer::draw (const graphics_object& go)
540 { 540 {
541 if (! go.valid_object ()) 541 if (! go.valid_object ())
542 return; 542 return;
543 543
544 const base_properties& props = go.get_properties (); 544 const base_properties& props = go.get_properties ();
545 545
546 if (go.isa ("figure")) 546 if (go.isa ("figure"))
547 draw_figure (dynamic_cast<const figure::properties&> (props)); 547 draw_figure (dynamic_cast<const figure::properties&> (props));
548 else if (go.isa ("axes")) 548 else if (go.isa ("axes"))
611 // setup OpenGL transformation 611 // setup OpenGL transformation
612 612
613 Matrix x_zlim = props.get_transform_zlim (); 613 Matrix x_zlim = props.get_transform_zlim ();
614 Matrix x_mat1 = props.get_opengl_matrix_1 (); 614 Matrix x_mat1 = props.get_opengl_matrix_1 ();
615 Matrix x_mat2 = props.get_opengl_matrix_2 (); 615 Matrix x_mat2 = props.get_opengl_matrix_2 ();
616 616
617 xZ1 = x_zlim(0)-(x_zlim(1)-x_zlim(0))/2; 617 xZ1 = x_zlim(0)-(x_zlim(1)-x_zlim(0))/2;
618 xZ2 = x_zlim(1)+(x_zlim(1)-x_zlim(0))/2; 618 xZ2 = x_zlim(1)+(x_zlim(1)-x_zlim(0))/2;
619 619
620 #if defined (HAVE_FRAMEWORK_OPENGL) 620 #if defined (HAVE_FRAMEWORK_OPENGL)
621 GLint vw[4]; 621 GLint vw[4];
638 glClear (GL_DEPTH_BUFFER_BIT); 638 glClear (GL_DEPTH_BUFFER_BIT);
639 639
640 // store axes transformation data 640 // store axes transformation data
641 641
642 xform = props.get_transform (); 642 xform = props.get_transform ();
643 643
644 // draw axes object 644 // draw axes object
645 645
646 GLboolean antialias; 646 GLboolean antialias;
647 glGetBooleanv (GL_LINE_SMOOTH, &antialias); 647 glGetBooleanv (GL_LINE_SMOOTH, &antialias);
648 glDisable (GL_LINE_SMOOTH); 648 glDisable (GL_LINE_SMOOTH);
649 649
650 Matrix xlim = xform.xscale (props.get_xlim ().matrix_value ()); 650 Matrix xlim = xform.xscale (props.get_xlim ().matrix_value ());
651 Matrix ylim = xform.yscale (props.get_ylim ().matrix_value ()); 651 Matrix ylim = xform.yscale (props.get_ylim ().matrix_value ());
652 Matrix zlim = xform.zscale (props.get_zlim ().matrix_value ()); 652 Matrix zlim = xform.zscale (props.get_zlim ().matrix_value ());
653 double x_min = xlim(0), x_max = xlim(1); 653 double x_min = xlim(0), x_max = xlim(1);
654 double y_min = ylim(0), y_max = ylim(1); 654 double y_min = ylim(0), y_max = ylim(1);
1025 { 1025 {
1026 // FIXME: as tick text is transparent, shouldn't be 1026 // FIXME: as tick text is transparent, shouldn't be
1027 // drawn after axes object, for correct rendering? 1027 // drawn after axes object, for correct rendering?
1028 Matrix b = render_text (xticklabels(i), 1028 Matrix b = render_text (xticklabels(i),
1029 tickpos(i,0), tickpos(i,1), tickpos(i,2), 1029 tickpos(i,0), tickpos(i,1), tickpos(i,2),
1030 halign, valign); 1030 halign, valign);
1031 1031
1032 wmax = std::max (wmax, static_cast<int> (b(2))); 1032 wmax = std::max (wmax, static_cast<int> (b(2)));
1033 hmax = std::max (hmax, static_cast<int> (b(3))); 1033 hmax = std::max (hmax, static_cast<int> (b(3)));
1034 } 1034 }
1035 } 1035 }
1056 } 1056 }
1057 } 1057 }
1058 glEnd (); 1058 glEnd ();
1059 set_linestyle ("-", true); 1059 set_linestyle ("-", true);
1060 } 1060 }
1061 1061
1062 // minor tick marks 1062 // minor tick marks
1063 if (do_xminortick) 1063 if (do_xminortick)
1064 { 1064 {
1065 if (tick_along_z) 1065 if (tick_along_z)
1066 { 1066 {
1168 { 1168 {
1169 gh_manager::get_object (props.get_xlabel ()).set ("visible", "off"); 1169 gh_manager::get_object (props.get_xlabel ()).set ("visible", "off");
1170 } 1170 }
1171 1171
1172 // Y grid 1172 // Y grid
1173 1173
1174 if (ystate != AXE_DEPTH_DIR && visible) 1174 if (ystate != AXE_DEPTH_DIR && visible)
1175 { 1175 {
1176 bool do_ygrid = (props.is_ygrid () && (gridstyle != "none")); 1176 bool do_ygrid = (props.is_ygrid () && (gridstyle != "none"));
1177 bool do_yminorgrid = (props.is_yminorgrid () && (minorgridstyle != "none")); 1177 bool do_yminorgrid = (props.is_yminorgrid () && (minorgridstyle != "none"));
1178 bool do_yminortick = props.is_yminortick (); 1178 bool do_yminortick = props.is_yminortick ();
1275 { 1275 {
1276 // FIXME: as tick text is transparent, shouldn't be 1276 // FIXME: as tick text is transparent, shouldn't be
1277 // drawn after axes object, for correct rendering? 1277 // drawn after axes object, for correct rendering?
1278 Matrix b = render_text (yticklabels(i), 1278 Matrix b = render_text (yticklabels(i),
1279 tickpos(i,0), tickpos(i,1), tickpos(i,2), 1279 tickpos(i,0), tickpos(i,1), tickpos(i,2),
1280 halign, valign); 1280 halign, valign);
1281 1281
1282 wmax = std::max (wmax, static_cast<int> (b(2))); 1282 wmax = std::max (wmax, static_cast<int> (b(2)));
1283 hmax = std::max (hmax, static_cast<int> (b(3))); 1283 hmax = std::max (hmax, static_cast<int> (b(3)));
1284 } 1284 }
1285 } 1285 }
1416 } 1416 }
1417 else 1417 else
1418 { 1418 {
1419 gh_manager::get_object (props.get_ylabel ()).set ("visible", "off"); 1419 gh_manager::get_object (props.get_ylabel ()).set ("visible", "off");
1420 } 1420 }
1421 1421
1422 // Z Grid 1422 // Z Grid
1423 1423
1424 if (zstate != AXE_DEPTH_DIR && visible) 1424 if (zstate != AXE_DEPTH_DIR && visible)
1425 { 1425 {
1426 bool do_zgrid = (props.is_zgrid () && (gridstyle != "none")); 1426 bool do_zgrid = (props.is_zgrid () && (gridstyle != "none"));
1563 { 1563 {
1564 // FIXME: as tick text is transparent, shouldn't be 1564 // FIXME: as tick text is transparent, shouldn't be
1565 // drawn after axes object, for correct rendering? 1565 // drawn after axes object, for correct rendering?
1566 Matrix b = render_text (zticklabels(i), 1566 Matrix b = render_text (zticklabels(i),
1567 tickpos(i,0), tickpos(i,1), tickpos(i,2), 1567 tickpos(i,0), tickpos(i,1), tickpos(i,2),
1568 halign, valign); 1568 halign, valign);
1569 1569
1570 wmax = std::max (wmax, static_cast<int> (b(2))); 1570 wmax = std::max (wmax, static_cast<int> (b(2)));
1571 hmax = std::max (hmax, static_cast<int> (b(3))); 1571 hmax = std::max (hmax, static_cast<int> (b(3)));
1572 } 1572 }
1573 } 1573 }
1763 1763
1764 // Title 1764 // Title
1765 1765
1766 text::properties& title_props = 1766 text::properties& title_props =
1767 reinterpret_cast<text::properties&> (gh_manager::get_object (props.get_title ()).get_properties ()); 1767 reinterpret_cast<text::properties&> (gh_manager::get_object (props.get_title ()).get_properties ());
1768 1768
1769 if (! title_props.get_string ().empty () && title_props.positionmode_is("auto")) 1769 if (! title_props.get_string ().empty () && title_props.positionmode_is("auto"))
1770 { 1770 {
1771 ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10), 1771 ColumnVector p = xform.untransform (bbox(0)+bbox(2)/2, (bbox(1)-10),
1772 (x_zlim(0)+x_zlim(1))/2, true); 1772 (x_zlim(0)+x_zlim(1))/2, true);
1773 title_props.set_position (p.extract_n(0, 3).transpose ()); 1773 title_props.set_position (p.extract_n(0, 3).transpose ());
1919 } 1919 }
1920 1920
1921 if (flag) 1921 if (flag)
1922 glEnd (); 1922 glEnd ();
1923 } 1923 }
1924 1924
1925 set_linewidth (0.5); 1925 set_linewidth (0.5);
1926 set_linestyle ("-"); 1926 set_linestyle ("-");
1927 } 1927 }
1928 1928
1929 set_clipping (false); 1929 set_clipping (false);
1955 lc, fc); 1955 lc, fc);
1956 } 1956 }
1957 1957
1958 end_marker (); 1958 end_marker ();
1959 } 1959 }
1960 1960
1961 set_clipping (props.is_clipping ()); 1961 set_clipping (props.is_clipping ());
1962 } 1962 }
1963 1963
1964 void 1964 void
1965 opengl_renderer::draw_surface (const surface::properties& props) 1965 opengl_renderer::draw_surface (const surface::properties& props)
2112 if (fl_mode > 0) 2112 if (fl_mode > 0)
2113 { 2113 {
2114 for (int k = 0; k < 3; k++) 2114 for (int k = 0; k < 3; k++)
2115 cb[k] *= as; 2115 cb[k] *= as;
2116 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); 2116 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
2117 2117
2118 for (int k = 0; k < 3; k++) 2118 for (int k = 0; k < 3; k++)
2119 cb[k] = ds * c(j-1, i-1, k); 2119 cb[k] = ds * c(j-1, i-1, k);
2120 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); 2120 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
2121 } 2121 }
2122 } 2122 }
2141 if (fl_mode > 0) 2141 if (fl_mode > 0)
2142 { 2142 {
2143 for (int k = 0; k < 3; k++) 2143 for (int k = 0; k < 3; k++)
2144 cb[k] *= as; 2144 cb[k] *= as;
2145 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); 2145 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
2146 2146
2147 for (int k = 0; k < 3; k++) 2147 for (int k = 0; k < 3; k++)
2148 cb[k] = ds * c(j-1, i, k); 2148 cb[k] = ds * c(j-1, i, k);
2149 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); 2149 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
2150 } 2150 }
2151 } 2151 }
2157 + n(j-1,i,2) * n(j-1,i,2)); 2157 + n(j-1,i,2) * n(j-1,i,2));
2158 glNormal3d (n(j-1,i,0)/d, n(j-1,i,1)/d, n(j-1,i,2)/d); 2158 glNormal3d (n(j-1,i,0)/d, n(j-1,i,1)/d, n(j-1,i,2)/d);
2159 } 2159 }
2160 2160
2161 glVertex3d (x(j1,i), y(j-1,i2), z(j-1,i)); 2161 glVertex3d (x(j1,i), y(j-1,i2), z(j-1,i));
2162 2162
2163 // Vertex 3 2163 // Vertex 3
2164 if (fc_mode == 3) 2164 if (fc_mode == 3)
2165 tex.tex_coord (double (i) / (zc-1), double (j) / (zr-1)); 2165 tex.tex_coord (double (i) / (zc-1), double (j) / (zr-1));
2166 else if (fc_mode == 2) 2166 else if (fc_mode == 2)
2167 { 2167 {
2172 if (fl_mode > 0) 2172 if (fl_mode > 0)
2173 { 2173 {
2174 for (int k = 0; k < 3; k++) 2174 for (int k = 0; k < 3; k++)
2175 cb[k] *= as; 2175 cb[k] *= as;
2176 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); 2176 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
2177 2177
2178 for (int k = 0; k < 3; k++) 2178 for (int k = 0; k < 3; k++)
2179 cb[k] = ds * c(j, i, k); 2179 cb[k] = ds * c(j, i, k);
2180 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); 2180 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
2181 } 2181 }
2182 } 2182 }
2201 if (fl_mode > 0) 2201 if (fl_mode > 0)
2202 { 2202 {
2203 for (int k = 0; k < 3; k++) 2203 for (int k = 0; k < 3; k++)
2204 cb[k] *= as; 2204 cb[k] *= as;
2205 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb); 2205 glMaterialfv (LIGHT_MODE, GL_AMBIENT, cb);
2206 2206
2207 for (int k = 0; k < 3; k++) 2207 for (int k = 0; k < 3; k++)
2208 cb[k] = ds * c(j, i-1, k); 2208 cb[k] = ds * c(j, i-1, k);
2209 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb); 2209 glMaterialfv (LIGHT_MODE, GL_DIFFUSE, cb);
2210 } 2210 }
2211 } 2211 }
2394 + n(j,i-1,1) * n(j,i-1,1) 2394 + n(j,i-1,1) * n(j,i-1,1)
2395 + n(j,i-1,2) * n(j,i-1,2)); 2395 + n(j,i-1,2) * n(j,i-1,2));
2396 glNormal3d (n(j,i-1,0)/d, n(j,i-1,1)/d, n(j,i-1,2)/d); 2396 glNormal3d (n(j,i-1,0)/d, n(j,i-1,1)/d, n(j,i-1,2)/d);
2397 } 2397 }
2398 glVertex3d (x(j2,i-1), y(j,i1), z(j,i-1)); 2398 glVertex3d (x(j2,i-1), y(j,i1), z(j,i-1));
2399 2399
2400 // Vertex 2 2400 // Vertex 2
2401 if (ec_mode == 2) 2401 if (ec_mode == 2)
2402 { 2402 {
2403 for (int k = 0; k < 3; k++) 2403 for (int k = 0; k < 3; k++)
2404 cb[k] = c(j, i, k); 2404 cb[k] = c(j, i, k);
2421 + n(j,i,1) * n(j,i,1) 2421 + n(j,i,1) * n(j,i,1)
2422 + n(j,i,2) * n(j,i,2)); 2422 + n(j,i,2) * n(j,i,2));
2423 glNormal3d (n(j,i,0)/d, n(j,i,1)/d, n(j,i,2)/d); 2423 glNormal3d (n(j,i,0)/d, n(j,i,1)/d, n(j,i,2)/d);
2424 } 2424 }
2425 glVertex3d (x(j2,i), y(j,i2), z(j,i)); 2425 glVertex3d (x(j2,i), y(j,i2), z(j,i));
2426 2426
2427 glEnd (); 2427 glEnd ();
2428 } 2428 }
2429 } 2429 }
2430 } 2430 }
2431 2431
2477 2477
2478 for (int i = 0; i < zc; i++) 2478 for (int i = 0; i < zc; i++)
2479 { 2479 {
2480 if (y_mat) 2480 if (y_mat)
2481 i1 = i; 2481 i1 = i;
2482 2482
2483 for (int j = 0; j < zr; j++) 2483 for (int j = 0; j < zr; j++)
2484 { 2484 {
2485 if (clip(j,i)) 2485 if (clip(j,i))
2486 continue; 2486 continue;
2487 2487
2524 2524
2525 bool has_z = (v.columns () > 2); 2525 bool has_z = (v.columns () > 2);
2526 bool has_facecolor = false; 2526 bool has_facecolor = false;
2527 bool has_facealpha = false; 2527 bool has_facealpha = false;
2528 2528
2529 int fc_mode = ((props.facecolor_is("none") 2529 int fc_mode = ((props.facecolor_is("none")
2530 || props.facecolor_is_rgb ()) ? 0 : 2530 || props.facecolor_is_rgb ()) ? 0 :
2531 (props.facecolor_is("flat") ? 1 : 2)); 2531 (props.facecolor_is("flat") ? 1 : 2));
2532 int fl_mode = (props.facelighting_is ("none") ? 0 : 2532 int fl_mode = (props.facelighting_is ("none") ? 0 :
2533 (props.facelighting_is ("flat") ? 1 : 2)); 2533 (props.facelighting_is ("flat") ? 1 : 2));
2534 int fa_mode = (props.facealpha_is_double () ? 0 : 2534 int fa_mode = (props.facealpha_is_double () ? 0 :
2535 (props.facealpha_is ("flat") ? 1 : 2)); 2535 (props.facealpha_is ("flat") ? 1 : 2));
2536 int ec_mode = ((props.edgecolor_is("none") 2536 int ec_mode = ((props.edgecolor_is("none")
2537 || props.edgecolor_is_rgb ()) ? 0 : 2537 || props.edgecolor_is_rgb ()) ? 0 :
2538 (props.edgecolor_is("flat") ? 1 : 2)); 2538 (props.edgecolor_is("flat") ? 1 : 2));
2539 int el_mode = (props.edgelighting_is ("none") ? 0 : 2539 int el_mode = (props.edgelighting_is ("none") ? 0 :
2540 (props.edgelighting_is ("flat") ? 1 : 2)); 2540 (props.edgelighting_is ("flat") ? 1 : 2));
2541 int ea_mode = (props.edgealpha_is_double () ? 0 : 2541 int ea_mode = (props.edgealpha_is_double () ? 0 :
2542 (props.edgealpha_is ("flat") ? 1 : 2)); 2542 (props.edgealpha_is ("flat") ? 1 : 2));
2543 2543
2544 Matrix fcolor = props.get_facecolor_rgb (); 2544 Matrix fcolor = props.get_facecolor_rgb ();
2545 Matrix ecolor = props.get_edgecolor_rgb (); 2545 Matrix ecolor = props.get_edgecolor_rgb ();
2546 2546
2547 float as = props.get_ambientstrength (); 2547 float as = props.get_ambientstrength ();
2548 float ds = props.get_diffusestrength (); 2548 float ds = props.get_diffusestrength ();
2549 float ss = props.get_specularstrength (); 2549 float ss = props.get_specularstrength ();
2550 float se = props.get_specularexponent (); 2550 float se = props.get_specularexponent ();
2551 2551
2578 c = props.get_color_data ().matrix_value (); 2578 c = props.get_color_data ().matrix_value ();
2579 2579
2580 if (c.rows () == 1) 2580 if (c.rows () == 1)
2581 { 2581 {
2582 // Single color specifications, we can simplify a little bit 2582 // Single color specifications, we can simplify a little bit
2583 2583
2584 if (fc_mode > 0) 2584 if (fc_mode > 0)
2585 { 2585 {
2586 fcolor = c; 2586 fcolor = c;
2587 fc_mode = 0; 2587 fc_mode = 0;
2588 } 2588 }
2689 tess.begin_contour (); 2689 tess.begin_contour ();
2690 2690
2691 for (int j = 0; j < count_f(i); j++) 2691 for (int j = 0; j < count_f(i); j++)
2692 { 2692 {
2693 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep (); 2693 vertex_data::vertex_data_rep *vv = vdata[i+j*fr].get_rep ();
2694 2694
2695 tess.add_vertex (vv->coords.fortran_vec (), vv); 2695 tess.add_vertex (vv->coords.fortran_vec (), vv);
2696 } 2696 }
2697 2697
2698 tess.end_contour (); 2698 tess.end_contour ();
2699 tess.end_polygon (); 2699 tess.end_polygon ();
2884 { 2884 {
2885 octave_value cdata = props.get_color_data (); 2885 octave_value cdata = props.get_color_data ();
2886 dim_vector dv (cdata.dims ()); 2886 dim_vector dv (cdata.dims ());
2887 int h = dv(0), w = dv(1); 2887 int h = dv(0), w = dv(1);
2888 bool ok = true; 2888 bool ok = true;
2889 2889
2890 Matrix x = props.get_xdata ().matrix_value (); 2890 Matrix x = props.get_xdata ().matrix_value ();
2891 Matrix y = props.get_ydata ().matrix_value (); 2891 Matrix y = props.get_ydata ().matrix_value ();
2892 2892
2893 if (w > 1 && x(1) == x(0)) 2893 if (w > 1 && x(1) == x(0))
2894 x(1) = x(1) + (w-1); 2894 x(1) = x(1) + (w-1);
2895 2895
2896 if (h > 1 && y(1) == y(0)) 2896 if (h > 1 && y(1) == y(0))
2897 y(1) = y(1) + (h-1); 2897 y(1) = y(1) + (h-1);
2898 2898
2899 const ColumnVector p0 = xform.transform (x(0), y(0), 0); 2899 const ColumnVector p0 = xform.transform (x(0), y(0), 0);
2900 const ColumnVector p1 = xform.transform (x(1), y(1), 0); 2900 const ColumnVector p1 = xform.transform (x(1), y(1), 0);
2901 2901
2902 // image pixel size in screen pixel units 2902 // image pixel size in screen pixel units
2903 float pix_dx, pix_dy; 2903 float pix_dx, pix_dy;
2904 // image pixel size in normalized units 2904 // image pixel size in normalized units
2905 float nor_dx, nor_dy; 2905 float nor_dx, nor_dy;
2906 2906
2907 if (w > 1) 2907 if (w > 1)
2908 { 2908 {
2909 pix_dx = (p1(0) - p0(0))/(w-1); 2909 pix_dx = (p1(0) - p0(0))/(w-1);
2910 nor_dx = (x(1) - x(0))/(w-1); 2910 nor_dx = (x(1) - x(0))/(w-1);
2911 } 2911 }
2912 else 2912 else
2955 else // clip to viewport 2955 else // clip to viewport
2956 { 2956 {
2957 GLfloat vp[4]; 2957 GLfloat vp[4];
2958 glGetFloatv(GL_VIEWPORT, vp); 2958 glGetFloatv(GL_VIEWPORT, vp);
2959 // FIXME -- actually add the code to do it! 2959 // FIXME -- actually add the code to do it!
2960 2960
2961 } 2961 }
2962 2962
2963 if (i0 >= i1 || j0 >= j1) 2963 if (i0 >= i1 || j0 >= j1)
2964 return; 2964 return;
2965 2965
2966 glPixelZoom (pix_dx, -pix_dy); 2966 glPixelZoom (pix_dx, -pix_dy);
2967 glRasterPos3d (im_xmin + nor_dx*j0, im_ymin + nor_dy*i0, 0); 2967 glRasterPos3d (im_xmin + nor_dx*j0, im_ymin + nor_dy*i0, 0);
2968 2968
3032 { 3032 {
3033 ok = false; 3033 ok = false;
3034 warning ("opengl_texture::draw: invalid image data type (expected double, uint16, or uint8)"); 3034 warning ("opengl_texture::draw: invalid image data type (expected double, uint16, or uint8)");
3035 } 3035 }
3036 } 3036 }
3037 else 3037 else
3038 { 3038 {
3039 ok = false; 3039 ok = false;
3040 warning ("opengl_texture::draw: invalid image size (expected n*m*3 or n*m)"); 3040 warning ("opengl_texture::draw: invalid image size (expected n*m*3 or n*m)");
3041 } 3041 }
3042 glPixelZoom (1, 1); 3042 glPixelZoom (1, 1);
3211 void 3211 void
3212 opengl_renderer::draw_marker (double x, double y, double z, 3212 opengl_renderer::draw_marker (double x, double y, double z,
3213 const Matrix& lc, const Matrix& fc) 3213 const Matrix& lc, const Matrix& fc)
3214 { 3214 {
3215 ColumnVector tmp = xform.transform (x, y, z, false); 3215 ColumnVector tmp = xform.transform (x, y, z, false);
3216 3216
3217 glLoadIdentity (); 3217 glLoadIdentity ();
3218 glTranslated (tmp(0), tmp(1), -tmp(2)); 3218 glTranslated (tmp(0), tmp(1), -tmp(2));
3219 3219
3220 if (filled_marker_id > 0 && fc.numel () > 0) 3220 if (filled_marker_id > 0 && fc.numel () > 0)
3221 { 3221 {
3355 case 'p': 3355 case 'p':
3356 { 3356 {
3357 double ang; 3357 double ang;
3358 double r; 3358 double r;
3359 double dr = 1.0 - sin(M_PI/10)/sin(3*M_PI/10)*1.02; 3359 double dr = 1.0 - sin(M_PI/10)/sin(3*M_PI/10)*1.02;
3360 3360
3361 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); 3361 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
3362 for (int i = 0; i < 2*5; i++) 3362 for (int i = 0; i < 2*5; i++)
3363 { 3363 {
3364 ang = (-0.5 + double(i+1)/5) * M_PI; 3364 ang = (-0.5 + double(i+1)/5) * M_PI;
3365 r = 1.0 - (dr * fmod(double(i+1), 2.0)); 3365 r = 1.0 - (dr * fmod(double(i+1), 2.0));
3371 case 'h': 3371 case 'h':
3372 { 3372 {
3373 double ang; 3373 double ang;
3374 double r; 3374 double r;
3375 double dr = 1.0 - 0.5/sin(M_PI/3)*1.02; 3375 double dr = 1.0 - 0.5/sin(M_PI/3)*1.02;
3376 3376
3377 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP)); 3377 glBegin ((filled ? GL_POLYGON : GL_LINE_LOOP));
3378 for (int i = 0; i < 2*6; i++) 3378 for (int i = 0; i < 2*6; i++)
3379 { 3379 {
3380 ang = (0.5 + double(i+1)/6.0) * M_PI; 3380 ang = (0.5 + double(i+1)/6.0) * M_PI;
3381 r = 1.0 - (dr * fmod(double(i+1), 2.0)); 3381 r = 1.0 - (dr * fmod(double(i+1), 2.0));