23 #if defined (HAVE_CONFIG_H)
29 #if defined (HAVE_WINDOWS_H)
30 # define WIN32_LEAN_AND_MEAN
43 #if defined (HAVE_OPENGL)
60 #if defined (HAVE_OPENGL)
62 #define LIGHT_MODE GL_FRONT_AND_BACK
92 #if ! defined (CALLBACK)
104 :
id (),
w (),
h (), tw (), th (), tx (), ty (),
105 valid (
false), count (1)
108 texture_rep (GLuint id_arg,
int w_arg,
int h_arg,
int tw_arg,
int th_arg)
109 :
id (id_arg),
w (w_arg),
h (h_arg), tw (tw_arg), th (th_arg),
116 glDeleteTextures (1, &
id);
120 {
if (valid) glBindTexture (mode,
id); }
123 {
if (valid) glTexCoord2d (q*tx, r*ty); }
149 if (--rep->
count == 0)
155 if (--rep->
count == 0)
173 {
return rep->
valid; }
189 h =
dv(0), w =
dv(1);
196 glGenTextures (1, &
id);
197 glBindTexture (GL_TEXTURE_2D,
id);
205 for (
int i = 0;
i <
h;
i++)
207 for (
int j = 0, idx =
i*tw*3; j <
w; j++, idx += 3)
209 a[idx] = xdata(
i,j,0);
210 a[idx+1] = xdata(
i,j,1);
211 a[idx+2] = xdata(
i,j,2);
215 glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0, GL_RGB, GL_FLOAT,
a);
223 for (
int i = 0;
i <
h;
i++)
225 for (
int j = 0, idx =
i*tw*3; j <
w; j++, idx += 3)
227 a[idx] = xdata(
i,j,0);
228 a[idx+1] = xdata(
i,j,1);
229 a[idx+2] = xdata(
i,j,2);
233 glTexImage2D (GL_TEXTURE_2D, 0, 3, tw, th, 0,
234 GL_RGB, GL_UNSIGNED_BYTE,
a);
239 warning (
"opengl_texture::create: invalid texture data type (double or uint8 required)");
244 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
245 glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
247 if (glGetError () != GL_NO_ERROR)
248 warning (
"opengl_texture::create: OpenGL error while generating texture data");
254 warning (
"opengl_texture::create: invalid texture data size");
263 #if defined (HAVE_FRAMEWORK_OPENGL) && defined (HAVE_GLUTESSCALLBACK_THREEDOTS)
274 {
if (glu_tess) gluDeleteTess (glu_tess); }
278 gluTessProperty (glu_tess, GLU_TESS_BOUNDARY_ONLY,
279 (filled ? GL_FALSE : GL_TRUE));
281 gluTessBeginPolygon (glu_tess,
this);
285 { gluTessEndPolygon (glu_tess); }
288 { gluTessBeginContour (glu_tess); }
291 { gluTessEndContour (glu_tess); }
294 { gluTessVertex (glu_tess, loc, data); }
299 virtual void end (
void) { }
303 virtual void combine (GLdouble [3] ,
void * [4] ,
304 GLfloat [4] ,
void ** ) { }
309 {
::error (
"OpenGL tesselation error (%d)", err); }
313 glu_tess = gluNewTess ();
315 gluTessCallback (glu_tess, GLU_TESS_BEGIN_DATA,
316 reinterpret_cast<fcn> (tess_begin));
317 gluTessCallback (glu_tess, GLU_TESS_END_DATA,
318 reinterpret_cast<fcn> (tess_end));
319 gluTessCallback (glu_tess, GLU_TESS_VERTEX_DATA,
320 reinterpret_cast<fcn> (tess_vertex));
321 gluTessCallback (glu_tess, GLU_TESS_COMBINE_DATA,
322 reinterpret_cast<fcn> (tess_combine));
323 gluTessCallback (glu_tess, GLU_TESS_EDGE_FLAG_DATA,
324 reinterpret_cast<fcn> (tess_edge_flag));
325 gluTessCallback (glu_tess, GLU_TESS_ERROR_DATA,
326 reinterpret_cast<fcn> (tess_error));
384 : coords (), color (), normal (), alpha (),
385 ambient (), diffuse (), specular (), specular_exp (),
386 specular_color_refl (), count (1) { }
389 double a,
float as,
float ds,
float ss,
float se,
391 : coords (c), color (col), normal (n), alpha (a),
392 ambient (as), diffuse (ds), specular (ss), specular_exp (se),
393 specular_color_refl (scr), count (1) { }
414 double a,
float as,
float ds,
float ss,
float se,
424 if (--rep->
count == 0)
430 if (--rep->
count == 0)
448 color_mode (cmode), light_mode (lmode), index (idx),
449 first (true), tmp_vdata ()
459 glShadeModel (GL_SMOOTH);
461 glShadeModel (GL_FLAT);
464 renderer->set_polygon_offset (
true, index);
473 renderer->set_polygon_offset (
false);
485 if (color_mode ==
INTERP || (color_mode ==
FLAT && ! is_filled ()))
489 if (col.
numel () == 3)
491 glColor3dv (col.
data ());
494 float buf[4] = { 0, 0, 0, 1 };
496 for (
int k = 0;
k < 3;
k++)
500 for (
int k = 0;
k < 3;
k++)
504 for (
int k = 0;
k < 3;
k++)
521 void combine (GLdouble xyz[3],
void *data[4], GLfloat
w[4],
void **out_data)
528 for (
int i = 0;
i < 4;
i++)
532 if (vmax == 4 && ! v[
i])
545 if (v[0]->color.numel ())
548 for (
int ic = 0; ic < 3; ic++)
549 for (
int iv = 0; iv < vmax; iv++)
550 cc(ic) += (w[iv] * v[iv]->
color (ic));
553 if (v[0]->normal.numel () > 0)
555 for (
int in = 0; in < 3; in++)
556 for (
int iv = 0; iv < vmax; iv++)
557 nn(in) += (w[iv] * v[iv]->
normal (in));
560 for (
int iv = 0; iv < vmax; iv++)
561 aa += (w[iv] * v[iv]->alpha);
563 vertex_data new_v (vv, cc, nn, aa, v[0]->ambient, v[0]->diffuse,
564 v[0]->specular, v[0]->specular_exp, v[0]->specular_color_refl);
565 tmp_vdata.push_back (new_v);
598 #if defined (HAVE_OPENGL)
604 static int max_lights = 0;
609 for (max_lights = 0; max_lights < GL_MAX_LIGHTS; max_lights++)
611 glDisable (GL_LIGHT0 + max_lights);
627 zmin (), zmax (), xZ1 (), xZ2 (), marker_id (), filled_marker_id (),
628 camera_pos (), camera_dir (),
interpreter (
"none"), txt_renderer ()
634 #if defined (HAVE_OPENGL)
639 static bool ok = (
sizeof (
int) <=
sizeof (GLsizei));
642 error (
"the size of GLsizei is smaller than the size of int");
662 if (go.
isa (
"figure"))
663 draw_figure (dynamic_cast<const figure::properties&> (props));
664 else if (go.
isa (
"axes"))
665 draw_axes (dynamic_cast<const axes::properties&> (props));
666 else if (go.
isa (
"line"))
667 draw_line (dynamic_cast<const line::properties&> (props));
668 else if (go.
isa (
"surface"))
669 draw_surface (dynamic_cast<const surface::properties&> (props));
670 else if (go.
isa (
"patch"))
671 draw_patch (dynamic_cast<const patch::properties&> (props));
672 else if (go.
isa (
"light"))
673 draw_light (dynamic_cast<const light::properties&> (props));
674 else if (go.
isa (
"hggroup"))
675 draw_hggroup (dynamic_cast<const hggroup::properties&> (props));
676 else if (go.
isa (
"text"))
677 draw_text (dynamic_cast<const text::properties&> (props));
678 else if (go.
isa (
"image"))
679 draw_image (dynamic_cast<const image::properties&> (props));
680 else if (go.
isa (
"uimenu") || go.
isa (
"uicontrol")
681 || go.
isa (
"uicontextmenu") || go.
isa (
"uitoolbar")
682 || go.
isa (
"uipushtool") || go.
isa (
"uitoggletool"))
684 else if (go.
isa (
"uipanel"))
687 draw_uipanel (dynamic_cast<const uipanel::properties&> (props), go);
689 else if (go.
isa (
"uibuttongroup"))
696 warning (
"opengl_renderer: cannot render object of type '%s'",
700 #if defined (HAVE_OPENGL)
702 GLenum gl_error = glGetError ();
704 warning (
"opengl_renderer: Error %d occurred drawing '%s' object",
710 #if defined (HAVE_OPENGL)
719 std::ostringstream buf;
720 buf << glGetString (
id);
733 #if defined (HAVE_OPENGL)
786 #if defined (HAVE_OPENGL)
790 glEnable (GL_DEPTH_TEST);
791 glDepthFunc (GL_LEQUAL);
792 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
793 glAlphaFunc (GL_GREATER, 0.0
f);
794 glEnable (GL_NORMALIZE);
799 glEnable (GL_MULTISAMPLE);
800 bool has_multisample =
false;
803 GLint iMultiSample, iNumSamples;
804 glGetIntegerv (GL_SAMPLE_BUFFERS, &iMultiSample);
805 glGetIntegerv (GL_SAMPLES, &iNumSamples);
806 if (iMultiSample == GL_TRUE && iNumSamples > 0)
807 has_multisample =
true;
810 if (! has_multisample)
813 glDisable (GL_MULTISAMPLE);
818 glEnable (GL_LINE_SMOOTH);
819 glHint (GL_LINE_SMOOTH_HINT, GL_NICEST);
824 glDisable (GL_BLEND);
825 glDisable (GL_LINE_SMOOTH);
832 glClearColor (
c(0),
c(1),
c(2), 1);
833 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
836 GLenum gl_error = glGetError ();
838 warning (
"opengl_renderer: Error %d occurred in init_gl_context",
843 octave_unused_parameter (enhanced);
844 octave_unused_parameter (c);
857 const Matrix& gridcolor,
const double gridalpha,
858 const Matrix& ticks,
double lim1,
double lim2,
859 double p1,
double p1N,
double p2,
double p2N,
862 #if defined (HAVE_OPENGL)
864 glColor4d (gridcolor(0), gridcolor(1), gridcolor(2), gridalpha);
867 for (
int i = 0;
i < ticks.
numel ();
i++)
869 double val = ticks(
i);
870 if (lim1 <= val && val <= lim2)
874 glVertex3d (val, p1N, p2);
875 glVertex3d (val, p1, p2);
878 glVertex3d (val, p1, p2N);
879 glVertex3d (val, p1, p2);
884 glVertex3d (p1N, val, p2);
885 glVertex3d (p1, val, p2);
888 glVertex3d (p1, val, p2N);
889 glVertex3d (p1, val, p2);
894 glVertex3d (p1N, p2, val);
895 glVertex3d (p1, p2, val);
896 glVertex3d (p1, p2N, val);
897 glVertex3d (p1, p2, val);
903 double black[3] = {0, 0, 0};
908 octave_unused_parameter (linewidth);
909 octave_unused_parameter (gridstyle);
910 octave_unused_parameter (gridcolor);
911 octave_unused_parameter (gridalpha);
912 octave_unused_parameter (ticks);
913 octave_unused_parameter (lim1);
914 octave_unused_parameter (lim2);
915 octave_unused_parameter (p1);
916 octave_unused_parameter (p1N);
917 octave_unused_parameter (p2);
918 octave_unused_parameter (p2N);
919 octave_unused_parameter (xyz);
920 octave_unused_parameter (is_3D);
932 double lim1,
double lim2,
933 double p1,
double p1N,
934 double p2,
double p2N,
935 double dx,
double dy,
double dz,
936 int xyz,
bool mirror)
938 #if defined (HAVE_OPENGL)
942 for (
int i = 0;
i < ticks.
numel ();
i++)
944 double val = ticks(
i);
946 if (lim1 <= val && val <= lim2)
950 glVertex3d (val, p1, p2);
951 glVertex3d (val, p1+dy, p2+dz);
954 glVertex3d (val, p1N, p2N);
955 glVertex3d (val, p1N-dy, p2N-dz);
960 glVertex3d (p1, val, p2);
961 glVertex3d (p1+dx, val, p2+dz);
964 glVertex3d (p1N, val, p2N);
965 glVertex3d (p1N-dx, val, p2N-dz);
970 glVertex3d (p1, p2, val);
971 glVertex3d (p1+dx, p2+dy, val);
974 glVertex3d (p1N, p2N, val);
975 glVertex3d (p1N-dx, p2N-dy, val);
985 octave_unused_parameter (ticks);
986 octave_unused_parameter (lim1);
987 octave_unused_parameter (lim2);
988 octave_unused_parameter (p1);
989 octave_unused_parameter (p1N);
990 octave_unused_parameter (p2);
991 octave_unused_parameter (p2N);
992 octave_unused_parameter (dx);
993 octave_unused_parameter (dy);
994 octave_unused_parameter (dz);
995 octave_unused_parameter (xyz);
996 octave_unused_parameter (mirror);
1009 double lim1,
double lim2,
1010 double p1,
double p2,
1011 int xyz,
int ha,
int va,
1012 int& wmax,
int& hmax)
1014 #if defined (HAVE_OPENGL)
1016 int nticks = ticks.
numel ();
1017 int nlabels = ticklabels.
numel ();
1022 for (
int i = 0;
i < nticks;
i++)
1024 double val = ticks(
i);
1026 if (lim1 <= val && val <= lim2)
1031 label.erase (0, label.find_first_not_of (
" "));
1032 label = label.substr (0, label.find_last_not_of (
" ")+1);
1049 wmax =
std::max (wmax, static_cast<int> (
b(2)));
1050 hmax =
std::max (hmax, static_cast<int> (
b(3)));
1056 octave_unused_parameter (ticks);
1057 octave_unused_parameter (ticklabels);
1058 octave_unused_parameter (lim1);
1059 octave_unused_parameter (lim2);
1060 octave_unused_parameter (p1);
1061 octave_unused_parameter (p2);
1062 octave_unused_parameter (xyz);
1063 octave_unused_parameter (ha);
1064 octave_unused_parameter (va);
1065 octave_unused_parameter (wmax);
1066 octave_unused_parameter (hmax);
1079 #if defined (HAVE_OPENGL)
1096 #if defined (HAVE_OPENGL)
1102 xZ1 = x_zlim(0)-(x_zlim(1)-x_zlim(0))/2;
1103 xZ2 = x_zlim(1)+(x_zlim(1)-x_zlim(0))/2;
1108 #if defined (HAVE_FRAMEWORK_OPENGL)
1114 glGetIntegerv (GL_VIEWPORT, vw);
1116 glMatrixMode (GL_MODELVIEW);
1118 glScaled (1, 1, -1);
1119 glMultMatrixd (x_mat1.
data ());
1120 glMatrixMode (GL_PROJECTION);
1122 glOrtho (0, vw[2], vw[3], 0,
xZ1,
xZ2);
1123 glMultMatrixd (x_mat2.
data ());
1124 glMatrixMode (GL_MODELVIEW);
1126 glClear (GL_DEPTH_BUFFER_BIT);
1134 octave_unused_parameter (props);
1147 #if defined (HAVE_OPENGL)
1170 glVertex3d (xPlane, yPlaneN, zPlaneN);
1171 glVertex3d (xPlane, yPlane, zPlaneN);
1172 glVertex3d (xPlane, yPlane, zPlane);
1173 glVertex3d (xPlane, yPlaneN, zPlane);
1176 glVertex3d (xPlaneN, yPlane, zPlaneN);
1177 glVertex3d (xPlane, yPlane, zPlaneN);
1178 glVertex3d (xPlane, yPlane, zPlane);
1179 glVertex3d (xPlaneN, yPlane, zPlane);
1183 glVertex3d (xPlaneN, yPlaneN, zPlane);
1184 glVertex3d (xPlane, yPlaneN, zPlane);
1185 glVertex3d (xPlane, yPlane, zPlane);
1186 glVertex3d (xPlaneN, yPlane, zPlane);
1194 octave_unused_parameter (props);
1207 #if defined (HAVE_OPENGL)
1230 bool plotyy = (props.
has_property (
"__plotyy_axes__"));
1243 glVertex3d (xPlaneN, ypTick, zpTick);
1244 glVertex3d (xPlane, ypTick, zpTick);
1248 glVertex3d (xPlaneN, ypTickN, zpTick);
1249 glVertex3d (xPlane, ypTickN, zpTick);
1252 glVertex3d (xPlaneN, ypTickN, zpTickN);
1253 glVertex3d (xPlane, ypTickN, zpTickN);
1256 glVertex3d (xPlaneN, ypTick, zpTickN);
1257 glVertex3d (xPlane, ypTick, zpTickN);
1264 glVertex3d (xpTick, yPlaneN, zpTick);
1265 glVertex3d (xpTick, yPlane, zpTick);
1267 if (props.
is_box () && ! plotyy)
1269 glVertex3d (xpTickN, yPlaneN, zpTick);
1270 glVertex3d (xpTickN, yPlane, zpTick);
1274 glVertex3d (xpTickN, yPlaneN, zpTickN);
1275 glVertex3d (xpTickN, yPlane, zpTickN);
1278 glVertex3d (xpTick, yPlaneN, zpTickN);
1279 glVertex3d (xpTick, yPlane, zpTickN);
1291 glVertex3d (xPlaneN, yPlane, zPlaneN);
1292 glVertex3d (xPlaneN, yPlane, zPlane);
1296 glVertex3d (xPlane, yPlaneN, zPlaneN);
1297 glVertex3d (xPlane, yPlaneN, zPlane);
1302 glVertex3d (xPlane, yPlane, zPlaneN);
1303 glVertex3d (xPlane, yPlane, zPlane);
1307 glVertex3d (xPlane, yPlaneN, zPlaneN);
1308 glVertex3d (xPlane, yPlaneN, zPlane);
1312 glVertex3d (xPlaneN, yPlane, zPlaneN);
1313 glVertex3d (xPlaneN, yPlane, zPlane);
1318 glVertex3d (xPlaneN, yPlaneN, zPlaneN);
1319 glVertex3d (xPlaneN, yPlaneN, zPlane);
1328 octave_unused_parameter (props);
1352 double fy = props.
get_fy ();
1353 double fz = props.
get_fz ();
1374 bool do_xgrid = (props.
is_xgrid () && (gridstyle !=
"none"));
1376 && (minorgridstyle !=
"none"));
1396 if (do_xminorgrid && ! do_xgrid)
1398 gridstyle = minorgridstyle;
1399 gridcolor = minorgridcolor;
1400 gridalpha = minorgridalpha;
1407 minorgridstyle, minorgridcolor, minorgridalpha,
1408 xmticks, x_min, x_max,
1409 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1415 gridstyle, gridcolor, gridalpha,
1416 xticks, x_min, x_max,
1417 yPlane, yPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1427 zpTick, zpTickN, 0., 0.,
1441 zpTick, zpTickN, 0., 0.,
1454 if (xticklabels.
numel () > 0)
1456 int halign = (xstate ==
AXE_HORZ_DIR ? 1 : (xyzSym ? 0 : 2));
1457 int valign = (xstate ==
AXE_VERT_DIR ? 1 : (x2Dtop ? 0 : 2));
1462 0, halign, valign, wmax, hmax);
1466 zpTick, 0, halign, valign, wmax, hmax);
1489 double fx = props.
get_fx ();
1490 double fz = props.
get_fz ();
1511 bool do_ygrid = (props.
is_ygrid () && (gridstyle !=
"none"));
1513 && (minorgridstyle !=
"none"));
1534 if (do_yminorgrid && ! do_ygrid)
1536 gridstyle = minorgridstyle;
1537 gridcolor = minorgridcolor;
1538 gridalpha = minorgridalpha;
1545 minorgridstyle, minorgridcolor, minorgridalpha,
1546 ymticks, y_min, y_max,
1547 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1553 gridstyle, gridcolor, gridalpha,
1554 yticks, y_min, y_max,
1555 xPlane, xPlaneN, layer2Dtop ? zPlaneN : zPlane, zPlaneN,
1565 zpTick, zpTickN, 0., 0.,
1578 zpTick, zpTickN, 0., 0.,
1588 if (yticklabels.
numel () > 0)
1591 ? 1 : (! xyzSym || y2Dright ? 0 : 2));
1597 1, halign, valign, wmax, hmax);
1601 zpTick, 1, halign, valign, wmax, hmax);
1621 double fx = props.
get_fx ();
1622 double fy = props.
get_fy ();
1639 bool do_zgrid = (props.
is_zgrid () && (gridstyle !=
"none"));
1641 && (minorgridstyle !=
"none"));
1660 if (do_zminorgrid && ! do_zgrid)
1662 gridstyle = minorgridstyle;
1663 gridcolor = minorgridcolor;
1664 gridalpha = minorgridalpha;
1671 minorgridstyle, minorgridcolor, minorgridalpha,
1672 zmticks, z_min, z_max,
1673 xPlane, xPlaneN, yPlane, yPlaneN, 2,
true);
1678 gridstyle, gridcolor, gridalpha,
1679 zticks, z_min, z_max,
1680 xPlane, xPlaneN, yPlane, yPlaneN, 2,
true);
1704 yPlaneN, yPlane, 0.,
1733 yPlaneN, yPlane, 0.,
1744 if (zticklabels.
numel () > 0)
1747 int valign = (zstate ==
AXE_VERT_DIR ? 1 : (zSign ? 3 : 2));
1754 yPlane, 2, halign, valign, wmax, hmax);
1758 2, halign, valign, wmax, hmax);
1765 2, halign, valign, wmax, hmax);
1769 yPlaneN, 2, halign, valign, wmax, hmax);
1781 std::list<graphics_object>& obj_list)
1783 #if defined (HAVE_OPENGL)
1792 if (go.
isa (
"light"))
1803 "light: Maximum number of lights (%d) in these axes is "
1806 else if (go.
isa (
"hggroup"))
1809 obj_list.push_back (go);
1814 octave_unused_parameter (props);
1815 octave_unused_parameter (obj_list);
1828 #if defined (HAVE_OPENGL)
1830 std::list<graphics_object> obj_list;
1831 std::list<graphics_object>::iterator it;
1850 glDisable (GL_LIGHT0 +
i);
1856 float cb[4] = { 1.0, 1.0, 1.0, 1.0 };
1858 for (
int i = 0;
i < 3;
i++)
1859 cb[
i] = ambient_color(
i);
1860 glLightfv (GL_LIGHT0, GL_AMBIENT, cb);
1864 it = obj_list.begin ();
1865 while (it != obj_list.end ())
1876 it = obj_list.erase (it);
1884 glDisable (GL_DEPTH_TEST);
1886 for (it = obj_list.begin (); it != obj_list.end (); it++)
1894 glEnable (GL_DEPTH_TEST);
1903 octave_unused_parameter (props);
1916 #if defined (HAVE_OPENGL)
1931 if (x_max > floatmax || y_max > floatmax || z_max > floatmax
1932 || x_min < -floatmax || y_min < -floatmax || z_min < -floatmax)
1934 warning (
"opengl_renderer: data values greater than float capacity. (1) Scale data, or (2) Use gnuplot");
1941 GLboolean antialias;
1942 glGetBooleanv (GL_LINE_SMOOTH, &antialias);
1943 if (antialias == GL_TRUE)
1944 glDisable (GL_LINE_SMOOTH);
1962 set_clipbox (x_min, x_max, y_min, y_max, z_min, z_max);
1965 if (antialias == GL_TRUE)
1966 glEnable (GL_LINE_SMOOTH);
1972 octave_unused_parameter (props);
1985 #if defined (HAVE_OPENGL)
1991 bool has_z = (z.
numel () > 0);
1997 std::vector<octave_uint8> clip (n);
2000 for (
int i = 0;
i < n;
i++)
2006 for (
int i = 0;
i < n;
i++)
2020 for (
int i = 1;
i < n;
i++)
2022 if ((clip[
i-1] & clip[
i]) == clip_ok)
2027 glBegin (GL_LINE_STRIP);
2028 glVertex3d (
x(i-1),
y(i-1), z(i-1));
2030 glVertex3d (
x(i),
y(i), z(i));
2046 for (
int i = 1;
i < n;
i++)
2048 if ((clip[
i-1] & clip[
i]) == clip_ok)
2053 glBegin (GL_LINE_STRIP);
2054 glVertex2d (
x(i-1),
y(i-1));
2056 glVertex2d (
x(i),
y(i));
2094 for (
int i = 0;
i < n;
i++)
2096 if (clip[
i] == clip_ok)
2109 octave_unused_parameter (props);
2122 #if defined (HAVE_OPENGL)
2164 float cb[4] = { 0.0, 0.0, 0.0, 1.0 };
2169 bool x_mat = (x.
rows () == z.
rows ());
2172 i1 = i2 = j1 = j2 = 0;
2174 if ((fc_mode > 0 && fc_mode < 3) || ec_mode > 0)
2179 for (
int i = 0;
i < zr;
i++)
2184 for (
int j = 0; j < zc; j++)
2193 if (fa_mode > 0 || ea_mode > 0)
2199 if (fl_mode > 0 || el_mode > 0)
2213 glColor3dv (fcolor.
data ());
2216 for (
int i = 0;
i < 3;
i++)
2217 cb[
i] = as * fcolor(
i);
2220 for (
int i = 0;
i < 3;
i++)
2221 cb[
i] = ds * fcolor(
i);
2224 for (
int i = 0;
i < 3;
i++)
2225 cb[
i] = ss * (scr + (1-scr) * fcolor(
i));
2231 glEnable (GL_LIGHTING);
2232 glShadeModel ((fc_mode ==
INTERP || fl_mode ==
GOURAUD) ? GL_SMOOTH
2236 glEnable (GL_TEXTURE_2D);
2238 for (
int i = 1;
i < zc;
i++)
2246 for (
int j = 1; j < zr; j++)
2249 if (clip(j-1,
i-1) || clip(j,
i-1)
2250 || clip(j-1,
i) || clip(j,
i))
2253 if (fc_mode ==
FLAT)
2259 else if (fc_mode ==
INTERP)
2278 double (j-1) / (zr-1));
2279 else if (fc_mode > 0)
2282 for (
int k = 0;
k < 3;
k++)
2283 cb[
k] =
c(j-1,
i-1,
k);
2288 for (
int k = 0;
k < 3;
k++)
2292 for (
int k = 0;
k < 3;
k++)
2293 cb[
k] = ds *
c(j-1,
i-1,
k);
2296 for (
int k = 0;
k < 3;
k++)
2297 cb[
k] = ss * (scr + (1-scr) *
c(j-1,
i-1,
k));
2304 glVertex3d (
x(j1,
i-1),
y(j-1,i1), z(j-1,
i-1));
2308 tex.
tex_coord (
double (
i) / (zc-1),
double (j-1) / (zr-1));
2309 else if (fc_mode ==
INTERP)
2311 for (
int k = 0;
k < 3;
k++)
2312 cb[
k] =
c(j-1,
i,
k);
2317 for (
int k = 0;
k < 3;
k++)
2321 for (
int k = 0;
k < 3;
k++)
2322 cb[
k] = ds *
c(j-1,
i,
k);
2325 for (
int k = 0;
k < 3;
k++)
2326 cb[
k] = ss * (scr + (1-scr) *
c(j-1,
i,
k));
2334 glVertex3d (
x(j1,
i),
y(j-1,i2), z(j-1,
i));
2338 tex.
tex_coord (
double (
i) / (zc-1),
double (j) / (zr-1));
2339 else if (fc_mode ==
INTERP)
2341 for (
int k = 0;
k < 3;
k++)
2347 for (
int k = 0;
k < 3;
k++)
2351 for (
int k = 0;
k < 3;
k++)
2352 cb[
k] = ds *
c(j,
i,
k);
2355 for (
int k = 0;
k < 3;
k++)
2356 cb[
k] = ss * (scr + (1-scr) *
c(j,
i,
k));
2363 glVertex3d (
x(j2,
i),
y(j,i2), z(j,
i));
2367 tex.
tex_coord (
double (
i-1) / (zc-1),
double (j) / (zr-1));
2368 else if (fc_mode ==
INTERP)
2370 for (
int k = 0;
k < 3;
k++)
2371 cb[
k] =
c(j,
i-1,
k);
2376 for (
int k = 0;
k < 3;
k++)
2380 for (
int k = 0;
k < 3;
k++)
2381 cb[
k] = ds *
c(j,
i-1,
k);
2384 for (
int k = 0;
k < 3;
k++)
2385 cb[
k] = ss * (scr + (1-scr) *
c(j,
i-1,
k));
2392 glVertex3d (
x(j2,
i-1),
y(j,i1), z(j,
i-1));
2400 glDisable (GL_TEXTURE_2D);
2403 glDisable (GL_LIGHTING);
2417 glColor3dv (ecolor.
data ());
2420 for (
int i = 0;
i < 3;
i++)
2421 cb[
i] = as * ecolor(
i);
2424 for (
int i = 0;
i < 3;
i++)
2425 cb[
i] = ds * ecolor(
i);
2428 for (
int i = 0;
i < 3;
i++)
2429 cb[
i] = ss * (scr + (1-scr) * ecolor(
i));
2435 glEnable (GL_LIGHTING);
2436 glShadeModel ((ec_mode ==
INTERP || el_mode ==
GOURAUD) ? GL_SMOOTH
2447 for (
int i = 0;
i < zc;
i++)
2455 for (
int j = 1; j < zr; j++)
2457 if (clip(j-1,
i) || clip(j,
i))
2460 if (ec_mode ==
FLAT)
2466 else if (ec_mode ==
INTERP)
2484 for (
int k = 0;
k < 3;
k++)
2485 cb[
k] =
c(j-1,
i,
k);
2490 for (
int k = 0;
k < 3;
k++)
2494 for (
int k = 0;
k < 3;
k++)
2495 cb[
k] = ds *
c(j-1,
i,
k);
2498 for (
int k = 0;
k < 3;
k++)
2499 cb[
k] = ss * (scr + (1-scr) *
c(j-1,
i,
k));
2506 glVertex3d (
x(j1,
i),
y(j-1,i2), z(j-1,
i));
2511 for (
int k = 0;
k < 3;
k++)
2517 for (
int k = 0;
k < 3;
k++)
2521 for (
int k = 0;
k < 3;
k++)
2522 cb[
k] = ds *
c(j,
i,
k);
2525 for (
int k = 0;
k < 3;
k++)
2526 cb[
k] = ss * (scr + (1-scr) *
c(j,
i,
k));
2533 glVertex3d (
x(j2,
i),
y(j,i2), z(j,
i));
2544 for (
int j = 0; j < zr; j++)
2552 for (
int i = 1;
i < zc;
i++)
2554 if (clip(j,
i-1) || clip(j,
i))
2557 if (ec_mode ==
FLAT)
2563 else if (ec_mode ==
INTERP)
2581 for (
int k = 0;
k < 3;
k++)
2582 cb[
k] =
c(j,
i-1,
k);
2587 for (
int k = 0;
k < 3;
k++)
2591 for (
int k = 0;
k < 3;
k++)
2592 cb[
k] = ds *
c(j,
i-1,
k);
2595 for (
int k = 0;
k < 3;
k++)
2596 cb[
k] = ss * (scr + (1-scr) *
c(j,
i-1,
k));
2603 glVertex3d (
x(j2,
i-1),
y(j,i1), z(j,
i-1));
2608 for (
int k = 0;
k < 3;
k++)
2614 for (
int k = 0;
k < 3;
k++)
2618 for (
int k = 0;
k < 3;
k++)
2619 cb[
k] = ds *
c(j,
i,
k);
2622 for (
int k = 0;
k < 3;
k++)
2623 cb[
k] = ss * (scr + (1-scr) *
c(j,
i,
k));
2630 glVertex3d (
x(j2,
i),
y(j,i2), z(j,
i));
2641 glDisable (GL_LIGHTING);
2662 Matrix cc (1, 3, 0.0);
2682 for (
int i = 0;
i < zc;
i++)
2687 for (
int j = 0; j < zr; j++)
2695 if ((do_edge && mecolor.
is_empty ())
2696 || (do_face && mfcolor.
is_empty ()))
2701 for (
int k = 0;
k < 3;
k++)
2705 Matrix lc = (do_edge ? (mecolor.
is_empty () ? cc : mecolor)
2707 Matrix fc = (do_face ? (mfcolor.
is_empty () ? cc : mfcolor)
2719 octave_unused_parameter (props);
2734 #if defined (HAVE_OPENGL)
2740 warning (
"opengl_renderer: %s. Not rendering.", msg.c_str ());
2754 bool has_z = (v.
columns () > 2);
2755 bool has_facecolor =
false;
2756 bool has_facealpha =
false;
2758 bool has_normals = (n.
rows () == nv);
2789 for (
int i = 0;
i < nv;
i++)
2792 for (
int i = 0;
i < nv;
i++)
2798 for (
int i = 0;
i < nf;
i++)
2804 fclip = (fclip || clip(
int (
f(
i,j) - 1)));
2810 if (fc_mode > 0 || ec_mode > 0)
2833 has_facecolor = ((c.
numel () > 0) && (c.
rows () == f.
rows ()));
2836 if (fa_mode > 0 || ea_mode > 0)
2840 has_facealpha = ((a.
numel () > 0) && (a.
rows () == f.
rows ()));
2844 std::vector<vertex_data> vdata (f.
numel ());
2846 for (
int i = 0;
i < nf;
i++)
2847 for (
int j = 0; j < count_f(
i); j++)
2849 int idx =
int (
f(
i,j) - 1);
2856 vv(0) = v(idx,0); vv(1) = v(idx,1);
2866 ? ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0);
2867 nn(0) = dir * n(idx,0);
2868 nn(1) = dir * n(idx,1);
2869 nn(2) = dir * n(idx,2);
2875 cc(0) =
c(
i,0), cc(1) =
c(
i,1), cc(2) =
c(
i,2);
2877 cc(0) =
c(idx,0), cc(1) =
c(idx,1), cc(2) =
c(idx,2);
2887 vdata[
i+j*fr] =
vertex_data (vv, cc, nn, aa, as, ds, ss, se, scr);
2890 if (fl_mode > 0 || el_mode > 0)
2900 glColor3dv (fcolor.
data ());
2903 float cb[4] = { 0, 0, 0, 1 };
2905 for (
int i = 0;
i < 3;
i++)
2906 cb[
i] = as * fcolor(
i);
2909 for (
int i = 0;
i < 3;
i++)
2910 cb[
i] = ds * fcolor(
i);
2913 for (
int i = 0;
i < 3;
i++)
2914 cb[
i] = ss * (scr + (1-scr) * fcolor(
i));
2919 if ((fl_mode > 0) && (
num_lights > 0) && has_normals)
2920 glEnable (GL_LIGHTING);
2928 for (
int i = 0;
i < nf;
i++)
2937 for (
int j = count_f(
i)-1; j > 0; j--)
2948 if (fc_mode ==
FLAT)
2953 if (col.
numel () == 3)
2955 glColor3dv (col.
data ());
2958 float cb[4] = { 0, 0, 0, 1 };
2960 for (
int k = 0;
k < 3;
k++)
2964 for (
int k = 0;
k < 3;
k++)
2968 for (
int k = 0;
k < 3;
k++)
2983 if ((fl_mode > 0) && (
num_lights > 0) && has_normals)
2984 glDisable (GL_LIGHTING);
2999 glColor3dv (ecolor.
data ());
3002 float cb[4] = { 0, 0, 0, 1 };
3004 for (
int i = 0;
i < 3;
i++)
3005 cb[
i] = (as * ecolor(
i));
3008 for (
int i = 0;
i < 3;
i++)
3009 cb[
i] = ds * ecolor(
i);
3012 for (
int i = 0;
i < 3;
i++)
3013 cb[
i] = ss * (scr + (1-scr) * ecolor(
i));
3018 if ((el_mode > 0) && (
num_lights > 0) && has_normals)
3019 glEnable (GL_LIGHTING);
3032 for (
int i = 0;
i < nf;
i++)
3040 ? GL_SMOOTH : GL_FLAT);
3043 for (
int j = count_f(
i)-1; j >= 0; j--)
3045 if (! clip(
int (
f(
i,j) - 1)))
3048 = vdata[
i+j*fr].get_rep ();
3053 glBegin (GL_LINE_STRIP);
3059 if (col.
numel () == 3)
3060 glColor3dv (col.
data ());
3062 glVertex3d (
m(0),
m(1),
m(2));
3072 int j = count_f(
i)-1;
3073 if (flag && ! clip(
int (
f(
i,j) - 1)))
3076 = vdata[
i+j*fr].get_rep ();
3082 if (col.
numel () == 3)
3083 glColor3dv (col.
data ());
3085 glVertex3d (
m(0),
m(1),
m(2));
3096 for (
int j = count_f(
i)-1; j >= 0; j--)
3099 = vdata[
i+j*fr].get_rep ();
3111 if ((el_mode > 0) && (
num_lights > 0) && has_normals)
3112 glDisable (GL_LIGHTING);
3130 bool has_markerfacecolor =
false;
3137 if (mc.
rows () == 1)
3150 has_markerfacecolor = ((c.
numel () > 0)
3158 for (
int i = 0;
i < nf;
i++)
3159 for (
int j = 0; j < count_f(
i); j++)
3161 int idx =
int (
f(
i,j) - 1);
3170 if (has_markerfacecolor)
3171 cc(0) =
c(
i,0), cc(1) =
c(
i,1), cc(2) =
c(
i,2);
3173 cc(0) =
c(idx,0), cc(1) =
c(idx,1), cc(2) =
c(idx,2);
3181 draw_marker (v(idx,0), v(idx,1), (has_z ? v(idx,2) : 0), lc, fc);
3189 octave_unused_parameter (props);
3202 #if defined (HAVE_OPENGL)
3208 float pos[4] = { 0, 0, 0, 0 };
3210 for (
int i = 0;
i < 3;
i++)
3217 float col[4] = { 1, 1, 1, 1 };
3219 for (
int i = 0;
i < 3;
i++)
3226 octave_unused_parameter (props);
3245 #if defined (HAVE_OPENGL)
3256 bool blend = glIsEnabled (GL_BLEND);
3258 glEnable (GL_BLEND);
3259 glEnable (GL_ALPHA_TEST);
3260 glRasterPos3d (pos(0), pos(1), pos.
numel () > 2 ? pos(2) : 0.0);
3261 glBitmap (0, 0, 0, 0, bbox(0), bbox(1), 0);
3262 glDrawPixels (bbox(2), bbox(3),
3264 glDisable (GL_ALPHA_TEST);
3266 glDisable (GL_BLEND);
3270 octave_unused_parameter (props);
3283 #if defined (HAVE_OPENGL)
3297 if (w > 1 &&
x(1) ==
x(0))
3298 x(1) =
x(1) + (w-1);
3300 if (h > 1 &&
y(1) ==
y(0))
3301 y(1) =
y(1) + (h-1);
3309 warning (
"opengl_renderer: image X,Y data too large to draw");
3314 float pix_dx, pix_dy;
3316 float nor_dx, nor_dy;
3320 pix_dx = (p1(0) - p0(0)) / (w-1);
3321 nor_dx = (
x(1) -
x(0)) / (w-1);
3326 pix_dx = p1w(0) - p0(0);
3332 pix_dy = (p1(1) - p0(1)) / (h-1);
3333 nor_dy = (
y(1) -
y(0)) / (h-1);
3338 pix_dy = p1h(1) - p0(1);
3349 float im_xmin =
x(0) - nor_dx/2;
3350 float im_xmax =
x(1) + nor_dx/2;
3351 float im_ymin =
y(0) - nor_dy/2;
3352 float im_ymax =
y(1) + nor_dy/2;
3356 j0 += (
xmin - im_xmin)/nor_dx + 1;
3358 j1 -= (im_xmax -
xmax)/nor_dx;
3361 i0 += (
ymin - im_ymin)/nor_dy + 1;
3363 i1 -= (im_ymax -
ymax)/nor_dy;
3368 glGetFloatv (GL_VIEWPORT, vp);
3372 if (i0 >= i1 || j0 >= j1)
3375 glPixelZoom (pix_dx, -pix_dy);
3376 glRasterPos3d (im_xmin + nor_dx*j0, im_ymin + nor_dy*i0, 0);
3379 glPixelStorei (GL_UNPACK_ALIGNMENT, 1);
3390 for (
int i = i0;
i < i1;
i++)
3392 for (
int j = j0, idx = (
i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
3394 a[idx] = xcdata(
i,j,0);
3395 a[idx+1] = xcdata(
i,j,1);
3396 a[idx+2] = xcdata(
i,j,2);
3409 for (
int i = i0;
i < i1;
i++)
3411 for (
int j = j0, idx = (
i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
3413 a[idx] = xcdata(
i,j,0);
3414 a[idx+1] = xcdata(
i,j,1);
3415 a[idx+2] = xcdata(
i,j,2);
3428 for (
int i = i0;
i < i1;
i++)
3430 for (
int j = j0, idx = (
i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
3432 a[idx] = xcdata(
i,j,0);
3433 a[idx+1] = xcdata(
i,j,1);
3434 a[idx+2] = xcdata(
i,j,2);
3447 for (
int i = i0;
i < i1;
i++)
3449 for (
int j = j0, idx = (
i-i0)*(j1-j0)*3; j < j1; j++, idx += 3)
3451 a[idx] = xcdata(
i,j,0);
3452 a[idx+1] = xcdata(
i,j,1);
3453 a[idx+2] = xcdata(
i,j,2);
3461 warning (
"opengl_renderer: invalid image data type (expected double, single, uint8, or uint16)");
3464 warning (
"opengl_renderer: invalid image size (expected MxNx3 or MxN)");
3470 octave_unused_parameter (props);
3483 #if defined (HAVE_OPENGL)
3485 glViewport (0, 0, w, h);
3489 octave_unused_parameter (w);
3490 octave_unused_parameter (h);
3503 #if defined (HAVE_OPENGL)
3505 glDrawPixels (width, height, GL_RGB, GL_FLOAT, data);
3509 octave_unused_parameter (width);
3510 octave_unused_parameter (height);
3511 octave_unused_parameter (data);
3524 #if defined (HAVE_OPENGL)
3526 glDrawPixels (width, height, GL_RGB, GL_UNSIGNED_BYTE, data);
3530 octave_unused_parameter (width);
3531 octave_unused_parameter (height);
3532 octave_unused_parameter (data);
3545 #if defined (HAVE_OPENGL)
3547 glDrawPixels (width, height, GL_RGB, GL_UNSIGNED_SHORT, data);
3551 octave_unused_parameter (width);
3552 octave_unused_parameter (height);
3553 octave_unused_parameter (data);
3566 #if defined (HAVE_OPENGL)
3568 glColor3dv (c.
data ());
3574 octave_unused_parameter (c);
3596 #if defined (HAVE_OPENGL)
3600 glEnable (GL_POLYGON_OFFSET_FILL);
3601 glEnable (GL_POLYGON_OFFSET_LINE);
3602 glPolygonOffset (offset, offset);
3606 glDisable (GL_POLYGON_OFFSET_FILL);
3607 glDisable (GL_POLYGON_OFFSET_LINE);
3612 octave_unused_parameter (on);
3613 octave_unused_parameter (offset);
3626 #if defined (HAVE_OPENGL)
3632 octave_unused_parameter (w);
3646 #if defined (HAVE_OPENGL)
3652 glLineStipple (1, static_cast<unsigned short> (0xFFFF));
3656 glLineStipple (linewidth, static_cast<unsigned short> (0x5555));
3658 glLineStipple (linewidth, static_cast<unsigned short> (0x0F0F));
3660 glLineStipple (linewidth, static_cast<unsigned short> (0x6F6F));
3662 glLineStipple (1, static_cast<unsigned short> (0x0000));
3664 if (solid && ! use_stipple)
3665 glDisable (GL_LINE_STIPPLE);
3667 glEnable (GL_LINE_STIPPLE);
3671 octave_unused_parameter (s);
3672 octave_unused_parameter (use_stipple);
3673 octave_unused_parameter (linewidth);
3685 double z1,
double z2)
3687 #if defined (HAVE_OPENGL)
3689 double dx = (x2-x1);
3690 double dy = (y2-y1);
3691 double dz = (z2-z1);
3693 x1 -= 0.001*dx; x2 += 0.001*dx;
3694 y1 -= 0.001*dy; y2 += 0.001*dy;
3695 z1 -= 0.001*dz; z2 += 0.001*dz;
3699 p(0) = -1;
p(3) = x2;
3700 glClipPlane (GL_CLIP_PLANE0, p.
data ());
3701 p(0) = 1;
p(3) = -x1;
3702 glClipPlane (GL_CLIP_PLANE1, p.
data ());
3703 p(0) = 0;
p(1) = -1;
p(3) = y2;
3704 glClipPlane (GL_CLIP_PLANE2, p.
data ());
3705 p(1) = 1;
p(3) = -y1;
3706 glClipPlane (GL_CLIP_PLANE3, p.
data ());
3707 p(1) = 0;
p(2) = -1;
p(3) = z2;
3708 glClipPlane (GL_CLIP_PLANE4, p.
data ());
3709 p(2) = 1;
p(3) = -z1;
3710 glClipPlane (GL_CLIP_PLANE5, p.
data ());
3718 octave_unused_parameter (x1);
3719 octave_unused_parameter (x2);
3720 octave_unused_parameter (y1);
3721 octave_unused_parameter (y2);
3722 octave_unused_parameter (z1);
3723 octave_unused_parameter (z2);
3736 #if defined (HAVE_OPENGL)
3738 bool has_clipping = (glIsEnabled (GL_CLIP_PLANE0) == GL_TRUE);
3740 if (enable != has_clipping)
3743 for (
int i = 0;
i < 6;
i++)
3744 glEnable (GL_CLIP_PLANE0+
i);
3746 for (
int i = 0;
i < 6;
i++)
3747 glDisable (GL_CLIP_PLANE0+
i);
3752 octave_unused_parameter (enable);
3765 #if defined (HAVE_OPENGL)
3767 # if defined (HAVE_FRAMEWORK_OPENGL)
3773 glGetIntegerv (GL_VIEWPORT, vw);
3775 glMatrixMode (GL_PROJECTION);
3778 glOrtho (0, vw[2], vw[3], 0,
xZ1,
xZ2);
3779 glMatrixMode (GL_MODELVIEW);
3790 octave_unused_parameter (m);
3791 octave_unused_parameter (size);
3792 octave_unused_parameter (width);
3805 #if defined (HAVE_OPENGL)
3810 glMatrixMode (GL_MODELVIEW);
3812 glMatrixMode (GL_PROJECTION);
3830 #if defined (HAVE_OPENGL)
3839 glColor3dv (fc.
data ());
3842 if (lc.
numel () > 0)
3844 glColor3dv (lc.
data ());
3845 glPolygonMode (GL_FRONT_AND_BACK, GL_LINE);
3846 glEdgeFlag (GL_TRUE);
3849 glPolygonMode (GL_FRONT_AND_BACK, GL_FILL);
3855 glColor3dv (lc.
data ());
3861 octave_unused_parameter (x);
3862 octave_unused_parameter (y);
3863 octave_unused_parameter (z);
3864 octave_unused_parameter (lc);
3865 octave_unused_parameter (fc);
3878 #if defined (HAVE_OPENGL)
3880 double x = n(j,i,0);
3881 double y = n(j,i,1);
3882 double z = n(j,i,2);
3884 double d = sqrt (x*x + y*y + z*z);
3890 ? ((bfl_mode > 1) ? 0.0 : -1.0) : 1.0);
3892 glNormal3d (dir*x/d, dir*y/d, dir*z/d);
3896 octave_unused_parameter (bfl_mode);
3897 octave_unused_parameter (n);
3898 octave_unused_parameter (j);
3899 octave_unused_parameter (i);
3913 #if defined (HAVE_OPENGL)
3917 if (filled && (c ==
'+' || c ==
'x' || c ==
'*' || c ==
'.'))
3920 unsigned int ID = glGenLists (1);
3924 const double sqrt2d4 = 0.35355339059327;
3925 double tt = sz*sqrt2d4;
3927 glNewList (ID, GL_COMPILE);
3933 glVertex2d (-sz/2, 0);
3934 glVertex2d (sz/2, 0);
3935 glVertex2d (0, -sz/2);
3936 glVertex2d (0, sz/2);
3941 glVertex2d (-sz/2, -sz/2);
3942 glVertex2d (sz/2, sz/2);
3943 glVertex2d (-sz/2, sz/2);
3944 glVertex2d (sz/2, -sz/2);
3949 glVertex2d (-sz/2, 0);
3950 glVertex2d (sz/2, 0);
3951 glVertex2d (0, -sz/2);
3952 glVertex2d (0, sz/2);
3953 glVertex2d (-tt, -tt);
3954 glVertex2d (+tt, +tt);
3955 glVertex2d (-tt, +tt);
3956 glVertex2d (+tt, -tt);
3964 if (sz > 0 && sz < 3)
3967 int div = static_cast <
int> (M_PI * sz / 12);
3971 double ang_step = M_PI / div;
3973 glBegin (GL_POLYGON);
3974 for (
double ang = 0; ang < 2*M_PI; ang += ang_step)
3975 glVertex2d (sz/6*cos (ang), sz/6*sin (ang));
3980 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
3981 glVertex2d (-sz/2, -sz/2);
3982 glVertex2d (-sz/2, sz/2);
3983 glVertex2d (sz/2, sz/2);
3984 glVertex2d (sz/2, -sz/2);
3989 int div = static_cast <
int> (M_PI * sz / 4);
3993 double ang_step = M_PI / div;
3995 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
3996 for (
double ang = 0; ang < 2*M_PI; ang += ang_step)
3997 glVertex2d (sz/2*cos (ang), sz/2*sin (ang));
4002 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
4003 glVertex2d (0, -sz/2);
4004 glVertex2d (sz/2, 0);
4005 glVertex2d (0, sz/2);
4006 glVertex2d (-sz/2, 0);
4010 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
4011 glVertex2d (0, sz/2);
4012 glVertex2d (sz/2, -sz/2);
4013 glVertex2d (-sz/2, -sz/2);
4017 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
4018 glVertex2d (0, -sz/2);
4019 glVertex2d (-sz/2, sz/2);
4020 glVertex2d (sz/2, sz/2);
4024 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
4025 glVertex2d (sz/2, 0);
4026 glVertex2d (-sz/2, sz/2);
4027 glVertex2d (-sz/2, -sz/2);
4031 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
4032 glVertex2d (-sz/2, 0);
4033 glVertex2d (sz/2, -sz/2);
4034 glVertex2d (sz/2, sz/2);
4040 dr = 1.0 - sin (M_PI/10)/sin (3*M_PI/10)*1.02;
4042 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
4043 for (
int i = 0;
i < 2*5;
i++)
4045 ang = (-0.5 +
double (
i+1) / 5) * M_PI;
4046 r = 1.0 - (dr * fmod (
double (
i+1), 2.0));
4047 glVertex2d (sz/2*r*cos (ang), sz/2*r*sin (ang));
4055 dr = 1.0 - 0.5/sin (M_PI/3)*1.02;
4057 glBegin (filled ? GL_POLYGON : GL_LINE_LOOP);
4058 for (
int i = 0;
i < 2*6;
i++)
4060 ang = (0.5 +
double (
i+1) / 6.0) * M_PI;
4061 r = 1.0 - (dr * fmod (
double (
i+1), 2.0));
4062 glVertex2d (sz/2*r*cos (ang), sz/2*r*sin (ang));
4068 warning (
"opengl_renderer: unsupported marker '%s'", marker.c_str ());
4078 octave_unused_parameter (marker);
4079 octave_unused_parameter (size);
4080 octave_unused_parameter (filled);
4094 int halign,
int valign,
double rotation)
4102 std::list<text_renderer::string>& lst,
4104 int halign,
int valign,
double rotation)
4112 double x,
double y,
double z,
4113 int halign,
int valign,
double rotation)
4115 #if defined (HAVE_OPENGL)
4127 bool blend = glIsEnabled (GL_BLEND);
4129 glEnable (GL_BLEND);
4130 glEnable (GL_ALPHA_TEST);
4131 glRasterPos3d (x, y, z);
4132 glBitmap(0, 0, 0, 0, bbox(0), bbox(1), 0);
4133 glDrawPixels (bbox(2), bbox(3),
4134 GL_RGBA, GL_UNSIGNED_BYTE, pixels.
data ());
4135 glDisable (GL_ALPHA_TEST);
4138 glDisable (GL_BLEND);
4145 octave_unused_parameter (txt);
4146 octave_unused_parameter (x);
4147 octave_unused_parameter (y);
4148 octave_unused_parameter (z);
4149 octave_unused_parameter (halign);
4150 octave_unused_parameter (valign);
4151 octave_unused_parameter (rotation);
virtual void draw_pixels(int w, int h, const float *data)
uint8NDArray uint8_array_value(void) const
std::string get_linestyle(void) const
std::string get_marker(void) const
void warning_with_id(const char *id, const char *fmt,...)
bool facealpha_is_double(void) const
octave_value get_xticklabel(void) const
bool is_empty(void) const
float specular_color_refl
double get_zPlaneN(void) const
Matrix get_markeredgecolor_rgb(void) const
Matrix get_opengl_matrix_1(void) const
octave_value get_color_data(void) const
Octave interface to the compression and uncompression libraries.
vertex_data(const Matrix &c, const Matrix &col, const Matrix &n, double a, float as, float ds, float ss, float se, float scr)
Matrix get_markeredgecolor_rgb(void) const
Matrix get_facecolor_rgb(void) const
bool style_is(const std::string &v) const
bool linestyle_is(const std::string &v) const
int get_zstate(void) const
void tex_coord(double q, double r) const
double get_edgealpha_double(void) const
opengl_renderer * renderer
virtual void init_marker(const std::string &m, double size, float width)
bool is_visible(void) const
void combine(GLdouble xyz[3], void *data[4], GLfloat w[4], void **out_data)
bool gridcolormode_is(const std::string &v) const
Matrix get_backgroundcolor_rgb(void) const
double get_x_max(void) const
virtual void draw_text(const text::properties &props)
Matrix get_data_position(void) const
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
octave_int< T > xmax(const octave_int< T > &x, const octave_int< T > &y)
vertex_data(const vertex_data &v)
bool edgealpha_is(const std::string &v) const
texture_rep(GLuint id_arg, int w_arg, int h_arg, int tw_arg, int th_arg)
graphics_handle get_xlabel(void) const
Matrix get_gridcolor_rgb(void) const
void draw_axes_children(const axes::properties &props)
bool isa(const std::string &go_name) const
void text_to_pixels(const std::string &txt, uint8NDArray &pxls, Matrix &bbox, int halign, int valign, double rotation=0.0, const caseless_str &interpreter="tex", bool handle_rotation=true)
virtual void set_polygon_offset(bool on, float offset=0.0f)
bool is_uint16_type(void) const
graphics_handle get_zlabel(void) const
bool linestyle_is(const std::string &v) const
opengl_texture(const opengl_texture &tx)
octave_idx_type numel(void) const
Number of elements in the array.
bool get_nearhoriz(void) const
octave_value get_position(void) const
octave_value get_color(void) const
identity matrix If supplied two scalar respectively For allows like xample val
static octave_idx_type nn
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE * f
virtual void text_to_strlist(const std::string &txt, std::list< text_renderer::string > &lst, Matrix &bbox, int halign=0, int valign=0, double rotation=0.0)
static void tess_error(GLenum err, void *t)
Return the CPU time used by your Octave session The first output is the total time spent executing your process and is equal to the sum of second and third which are the number of CPU seconds spent executing in user mode and the number of CPU seconds spent executing in system mode
virtual void draw_uibuttongroup(const uibuttongroup::properties &props, const graphics_object &go)
std::string get_boxstyle(void) const
Matrix get_color_rgb(void) const
std::list< vertex_data > tmp_vdata
octave_value get_zdata(void) const
virtual void draw(const graphics_object &go, bool toplevel=true)
vertex_data_rep * get_rep(void) const
static void tess_end(void *t)
OCTAVE_EXPORT octave_value_list return the value of the option it must match the dimension of the state and the relative tolerance must also be a vector of the same length tem it must match the dimension of the state and the absolute tolerance must also be a vector of the same length The local error test applied at each integration step is xample roup so it is best to provide a consistent set and leave this option set to zero tem it may help to set this parameter to a nonzero value it is probably best to try leaving this option set to zero first
void draw_axes_z_grid(const axes::properties &props)
std::string get_minorgridlinestyle(void) const
void draw_all_lights(const base_properties &props, std::list< graphics_object > &obj_list)
double get_z_max(void) const
octave_value get_faces(void) const
double get_fy(void) const
bool markerfacecolor_is(const std::string &v) const
octave_refcount< int > count
virtual std::string graphics_object_name(void) const
bool edgelighting_is(const std::string &v) const
void end_polygon(void) const
void error(const char *fmt,...)
std::string get_gridlinestyle(void) const
virtual void draw_image(const image::properties &props)
bool linestyle_is(const std::string &v) const
double get_linewidth(void) const
virtual void error(GLenum err)
bool backfacelighting_is(const std::string &v) const
double get_diffusestrength(void) const
virtual void init_gl_context(bool enhanced, const Matrix &backgroundColor)
vertex_data(vertex_data_rep *new_rep)
double get_ambientstrength(void) const
octave_value get_xdata(void) const
virtual void setup_opengl_transformation(const axes::properties &props)
octave_value get_ymtick(void) const
virtual void render_grid(const double linewidth, const std::string &gridstyle, const Matrix &gridcolor, const double gridalpha, const Matrix &ticks, double lim1, double lim2, double p1, double p1N, double p2, double p2N, int xyz, bool is_3D)
bool has_property(const caseless_str &pname) const
double get_markersize(void) const
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
bool facecolor_is(const std::string &v) const
bool markeredgecolor_is(const std::string &v) const
octave_value get_ytick(void) const
std::string get_marker(void) const
bool edgecolor_is(const std::string &v) const
octave_value get_xmtick(void) const
void bind(int mode) const
double get_xticklen(void) const
double get_facealpha_double(void) const
bool is_zminortick(void) const
virtual void combine(GLdouble[3], void *[4], GLfloat[4], void **)
Matrix get_edgecolor_rgb(void) const
std::string get_tag(void) const
static void tess_begin(GLenum type, void *t)
bool markerfacecolor_is(const std::string &v) const
virtual Matrix render_text(const std::string &txt, double x, double y, double z, int halign, int valign, double rotation=0.0)
std::string get_ticklabelinterpreter(void) const
Matrix get_markerfacecolor_rgb(void) const
octave_idx_type rows(void) const
octave_value get(bool all=false) const
double get_xpTickN(void) const
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE * d
graphics_xform get_transform(void) const
octave_value get_xdata(void) const
void add_vertex(double *loc, void *data) const
bool zcolormode_is(const std::string &v) const
octave_refcount< int > count
calling an anonymous function involves an overhead quite comparable to the overhead of an m file function Passing a handle to a built in function is because the interpreter is not involved in the internal loop For a
octave_value get_ydata(void) const
double get_edgealpha_double(void) const
bool color_is(const std::string &v) const
double get_specularexponent(void) const
double get_diffusestrength(void) const
bool marker_is(const std::string &v) const
bool edgealpha_is_double(void) const
static int next_power_of_2(int n)
bool edgecolor_is(const std::string &v) const
virtual void draw_axes(const axes::properties &props)
octave_uint8 clip_code(double x, double y, double z) const
const dim_vector & dims(void) const
Return a const-reference so that dims ()(i) works efficiently.
double get_zpTickN(void) const
bool get_xyzSym(void) const
FloatNDArray float_array_value(bool frc_str_conv=false) const
void tex_coord(double q, double r) const
double get_specularstrength(void) const
virtual void vertex(void *)
Matrix get_markerfacecolor_rgb(void) const
double get_minorgridalpha(void) const
virtual void set_clipping(bool on)
Matrix get_children(void) const
void begin_polygon(bool filled=true)
text_renderer txt_renderer
virtual void draw_line(const line::properties &props)
Matrix get_ycolor_rgb(void) const
Matrix get_ambientlightcolor_rgb(void) const
octave_value get_zticklabel(void) const
std::string string_value(bool force=false) const
static void tess_combine(GLdouble c[3], void *v[4], GLfloat w[4], void **out, void *t)
void text_to_strlist(const std::string &txt, std::list< string > &lst, Matrix &box, int halign, int valign, double rotation=0.0, const caseless_str &interpreter="tex")
nd deftypefn *octave_map m
double get_markersize(void) const
opengl_texture(texture_rep *_rep)
bool is_filled(void) const
void set_font(const std::string &name, const std::string &weight, const std::string &angle, double size)
int get_ystate(void) const
virtual void draw_hggroup(const hggroup::properties &props)
std::complex< double > w(std::complex< double > z, double relerr=0)
double get_fx(void) const
Matrix get_extent_matrix(void) const
Matrix get_zcolor_rgb(void) const
double get_yPlane(void) const
octave_value get_zmtick(void) const
vertex_data_rep(const Matrix &c, const Matrix &col, const Matrix &n, double a, float as, float ds, float ss, float se, float scr)
double get_specularcolorreflectance(void) const
octave_value get_ydata(void) const
double get_ypTickN(void) const
bool facealpha_is(const std::string &v) const
bool facealpha_is(const std::string &v) const
bool is_double_type(void) const
octave_value get_vertexnormals(void) const
bool is_valid(void) const
std::string get_box(void) const
const T * data(void) const
bool get_y2Dright(void) const
virtual void draw_marker(double x, double y, double z, const Matrix &lc, const Matrix &fc)
Matrix get_edgecolor_rgb(void) const
bool edgecolor_is_rgb(void) const
double get_specularstrength(void) const
bool markeredgecolor_is(const std::string &v) const
void set_color(const Matrix &c)
#define panic_impossible()
virtual void set_linewidth(float w)
virtual void end_marker(void)
std::string get_linestyle(void) const
double get_y_max(void) const
base_properties & get_properties(void)
static void tess_edge_flag(GLboolean flag, void *t)
double get_ytickoffset(void) const
Matrix get_color_rgb(void) const
double get_xPlaneN(void) const
std::string get_marker(void) const
virtual void begin(GLenum)
vertex_data_rep * nil_rep(void) const
static int get_maxlights(void)
bool get_layer2Dtop(void) const
the sparsity preserving column transformation such that that defines the pivoting threshold can be given in which case it defines the c
bool marker_is(const std::string &v) const
graphics_object get_ancestor(const std::string &type) const
dim_vector dims(void) const
octave_value get_cameraposition(void) const
string_vector string_vector_value(bool pad=false) const
Matrix matrix_value(bool frc_str_conv=false) const
virtual void set_linestyle(const std::string &s, bool stipple=false, double linewidth=0.5)
double get_linewidth(void) const
Matrix get_xcolor_rgb(void) const
octave_value get_vertices(void) const
bool is_clipping(void) const
double get_xPlane(void) const
bool get_zSign(void) const
octave_value get_string(void) const
bool edgealpha_is(const std::string &v) const
double get_yPlaneN(void) const
bool is_zminorgrid(void) const
bool edgealpha_is_double(void) const
octave_int< T > xmin(const octave_int< T > &x, const octave_int< T > &y)
virtual void set_viewport(int w, int h)
double get_ypTick(void) const
bool xcolormode_is(const std::string &v) const
void warning(const char *fmt,...)
bool get_xySym(void) const
virtual void set_color(const Matrix &c)
bool valid_object(void) const
bool facecolor_is_rgb(void) const
charNDArray max(char d, const charNDArray &m)
octave_value get_ydata(void) const
bool is_empty(void) const
double get_facealpha_double(void) const
void draw_axes_boxes(const axes::properties &props)
static std::string gl_get_string(GLenum id)
virtual void draw_light(const light::properties &props)
Matrix get_opengl_matrix_2(void) const
NDArray array_value(bool frc_str_conv=false) const
virtual octave_value get(const caseless_str &pname) const
bool is_nan_or_inf(double x, double y, double z) const
bool edgelighting_is(const std::string &v) const
double get_xtickoffset(void) const
unsigned int current_light
double get_fz(void) const
bool is_ygrid(void) const
patch_tesselator(opengl_renderer *r, int cmode, int lmode, float idx=0.0)
=val(i)}if ode{val(i)}occurs in table i
unsigned int filled_marker_id
double get_yticklen(void) const
double get_markersize(void) const
bool is_uint8_type(void) const
static opengl_texture create(const octave_value &data)
virtual void edge_flag(GLboolean)
virtual graphics_toolkit get_toolkit(void) const
int get_xstate(void) const
static void tess_vertex(void *v, void *t)
double get_z_min(void) const
virtual void render_tickmarks(const Matrix &ticks, double lim1, double lim2, double p1, double p1N, double p2, double p2N, double dx, double dy, double dz, int xyz, bool doubleside)
issues an error eealso double
virtual void text_to_pixels(const std::string &txt, uint8NDArray &pixels, Matrix &bbox, int halign=0, int valign=0, double rotation=0.0)
bool is_yminorgrid(void) const
Matrix get_all_children(void) const
double get_specularexponent(void) const
bool is_xminortick(void) const
void begin_contour(void) const
Matrix get_minorgridcolor_rgb(void) const
octave_idx_type ndims(void) const
Number of dimensions.
double get_x_min(void) const
double get_y_min(void) const
the element is set to zero In other the statement xample y
virtual void draw_uipanel(const uipanel::properties &props, const graphics_object &go)
double get_xpTick(void) const
bool facealpha_is_double(void) const
double get_gridalpha(void) const
bool backfacelighting_is(const std::string &v) const
bool ycolormode_is(const std::string &v) const
#define OCTAVE_LOCAL_BUFFER(T, buf, size)
static graphics_object get_object(double val)
bool is_xminorgrid(void) const
bool get_is2D(void) const
double get_zpTick(void) const
double get_specularcolorreflectance(void) const
double get_linewidth(void) const
double get_ambientstrength(void) const
unsigned int make_marker_list(const std::string &m, double size, bool filled) const
virtual void draw_patch(const patch::properties &props)
Matrix get_markeredgecolor_rgb(void) const
octave_value get_ztick(void) const
virtual ~opengl_tesselator(void)
void bind(int mode=GL_TEXTURE_2D) const
octave_value get_color_data(void) const
void draw_axes_x_grid(const axes::properties &props)
double get_zticklen(void) const
OCTAVE_EXPORT octave_value_list error nd deftypefn *const octave_scalar_map err
octave_value get_vertexnormals(void) const
bool facecolor_is(const std::string &v) const
virtual void draw_surface(const surface::properties &props)
octave_value get_color_data(void) const
octave_value get_xdata(void) const
const T * fortran_vec(void) const
virtual void finish(void)
bool is_single_type(void) const
bool minorgridcolormode_is(const std::string &v) const
bool marker_is(const std::string &v) const
Matrix get_markerfacecolor_rgb(void) const
double double_value(bool frc_str_conv=false) const
bool edgecolor_is_rgb(void) const
bool markerfacecolor_is(const std::string &v) const
virtual void draw_figure(const figure::properties &props)
double get_linewidth(void) const
bool facelighting_is(const std::string &v) const
Vector representing the dimensions (size) of an Array.
Matrix get_transform_zlim(void) const
virtual void set_interpreter(const caseless_str &interp)
bool is_yminortick(void) const
bool markeredgecolor_is(const std::string &v) const
bool meshstyle_is(const std::string &v) const
virtual void set_clipbox(double x1, double x2, double y1, double y2, double z1, double z2)
virtual void set_font(const base_properties &props)
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
set(hf,"paperorientation") esult
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
virtual void render_ticktexts(const Matrix &ticks, const string_vector &ticklabels, double lim1, double lim2, double p1, double p2, int xyz, int ha, int va, int &wmax, int &hmax)
const uint8NDArray & get_pixels(void) const
uint16NDArray uint16_array_value(void) const
bool is_zgrid(void) const
void end_contour(void) const
octave_idx_type columns(void) const
double get_ztickoffset(void) const
octave_value get_zdata(void) const
bool has_bad_data(std::string &msg) const
void xform(ColumnVector &v, const Matrix &m)
bool facecolor_is_rgb(void) const
double get_zPlane(void) const
bool facelighting_is(const std::string &v) const
std::string get_linestyle(void) const
graphics_handle get_ylabel(void) const
void set_normal(int bfl_mode, const NDArray &n, int j, int i)
F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_REAL const F77_REAL F77_REAL &F77_RET_T const F77_DBLE const F77_DBLE F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T F77_DBLE &F77_RET_T F77_REAL &F77_RET_T F77_REAL &F77_RET_T F77_DBLE &F77_RET_T const F77_DBLE F77_DBLE &F77_RET_T const F77_REAL F77_REAL &F77_RET_T F77_REAL F77_REAL &F77_RET_T F77_DBLE F77_DBLE &F77_RET_T const F77_DBLE * x
void draw_axes_planes(const axes::properties &props)
void draw_axes_y_grid(const axes::properties &props)
charNDArray min(char d, const charNDArray &m)
bool get_x2Dtop(void) const
Matrix get_facecolor_rgb(void) const
octave_value get_yticklabel(void) const
octave_value get_xtick(void) const
bool is_xgrid(void) const