Revision: 75509
http://sourceforge.net/p/brlcad/code/75509
Author: starseeker
Date: 2020-04-21 21:42:16 +0000 (Tue, 21 Apr 2020)
Log Message:
-----------
Push backend specific versions of axis drawing down behind call table
Modified Paths:
--------------
brlcad/branches/dm-fb-merge/src/libdm/axes.c
brlcad/branches/dm-fb-merge/src/libdm/glx/dm-ogl.c
brlcad/branches/dm-fb-merge/src/libdm/osgl/dm-osgl.cpp
brlcad/branches/dm-fb-merge/src/libdm/wgl/dm-wgl.c
Modified: brlcad/branches/dm-fb-merge/src/libdm/axes.c
===================================================================
--- brlcad/branches/dm-fb-merge/src/libdm/axes.c 2020-04-21 20:54:39 UTC
(rev 75508)
+++ brlcad/branches/dm-fb-merge/src/libdm/axes.c 2020-04-21 21:42:16 UTC
(rev 75509)
@@ -45,6 +45,12 @@
fastf_t sf,
struct bview_data_axes_state *bndasp)
{
+
+ if (dmp->i->dm_draw_data_axes) {
+ dmp->i->dm_draw_data_axes(dmp, sf, bndasp);
+ return;
+ }
+
int i, j;
fastf_t halfAxesSize; /* half the length of an axis */
point_t ptA, ptB;
@@ -60,22 +66,6 @@
/* set color */
dm_set_fg(dmp, bndasp->color[0], bndasp->color[1], bndasp->color[2], 1,
1.0);
-#if defined(IF_OGL) || defined(IF_WGL)
- if (bndasp->draw > 1) {
- if (dmp->i->dm_light)
- glDisable(GL_LIGHTING);
-
- glPointSize(bndasp->size);
- dm_draw_points_3d(dmp, bndasp->num_points, bndasp->points);
- glPointSize(1);
-
- if (dmp->i->dm_light)
- glEnable(GL_LIGHTING);
-
- return;
- }
-#endif
-
points = (point_t *)bu_calloc(npoints, sizeof(point_t), "data axes
points");
halfAxesSize = bndasp->size * 0.5 * sf;
Modified: brlcad/branches/dm-fb-merge/src/libdm/glx/dm-ogl.c
===================================================================
--- brlcad/branches/dm-fb-merge/src/libdm/glx/dm-ogl.c 2020-04-21 20:54:39 UTC
(rev 75508)
+++ brlcad/branches/dm-fb-merge/src/libdm/glx/dm-ogl.c 2020-04-21 21:42:16 UTC
(rev 75509)
@@ -1893,7 +1893,7 @@
int
ogl_draw_data_axes(struct dm *dmp,
- fastf_t UNUSED(sf),
+ fastf_t sf,
struct bview_data_axes_state *bndasp)
{
int npoints = bndasp->num_points * 6;
@@ -1914,8 +1914,56 @@
if (dmp->i->dm_light)
glEnable(GL_LIGHTING);
+ return 0;
}
+ int i, j;
+ fastf_t halfAxesSize; /* half the length of an axis */
+ point_t ptA, ptB;
+ point_t *points;
+ /* Save the line attributes */
+ int saveLineWidth = dmp->i->dm_lineWidth;
+ int saveLineStyle = dmp->i->dm_lineStyle;
+
+ points = (point_t *)bu_calloc(npoints, sizeof(point_t), "data axes
points");
+ halfAxesSize = bndasp->size * 0.5 * sf;
+
+ /* set linewidth */
+ dm_set_line_attr(dmp, bndasp->line_width, 0); /* solid lines */
+
+ for (i = 0, j = -1; i < bndasp->num_points; ++i) {
+ /* draw X axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X] - halfAxesSize, bndasp->points[i][Y],
bndasp->points[i][Z]);
+ VSET(ptB, bndasp->points[i][X] + halfAxesSize, bndasp->points[i][Y],
bndasp->points[i][Z]);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+
+ /* draw Y axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X], bndasp->points[i][Y] - halfAxesSize,
bndasp->points[i][Z]);
+ VSET(ptB, bndasp->points[i][X], bndasp->points[i][Y] + halfAxesSize,
bndasp->points[i][Z]);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+
+ /* draw Z axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X], bndasp->points[i][Y],
bndasp->points[i][Z] - halfAxesSize);
+ VSET(ptB, bndasp->points[i][X], bndasp->points[i][Y],
bndasp->points[i][Z] + halfAxesSize);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+ }
+
+ dm_draw_lines_3d(dmp, npoints, points, 0);
+ bu_free((void *)points, "data axes points");
+
+ /* Restore the line attributes */
+ dm_set_line_attr(dmp, saveLineWidth, saveLineStyle);
+
+
return 0;
}
Modified: brlcad/branches/dm-fb-merge/src/libdm/osgl/dm-osgl.cpp
===================================================================
--- brlcad/branches/dm-fb-merge/src/libdm/osgl/dm-osgl.cpp 2020-04-21
20:54:39 UTC (rev 75508)
+++ brlcad/branches/dm-fb-merge/src/libdm/osgl/dm-osgl.cpp 2020-04-21
21:42:16 UTC (rev 75509)
@@ -1434,6 +1434,82 @@
}
+int
+osgl_draw_data_axes(struct dm *dmp,
+ fastf_t sf,
+ struct bview_data_axes_state *bndasp)
+{
+ int npoints = bndasp->num_points * 6;
+ if (npoints < 1)
+ return 0;
+
+ /* set color */
+ dm_set_fg(dmp, bndasp->color[0], bndasp->color[1], bndasp->color[2], 1,
1.0);
+
+ if (bndasp->draw > 1) {
+ if (dmp->i->dm_light)
+ glDisable(GL_LIGHTING);
+
+ glPointSize(bndasp->size);
+ dm_draw_points_3d(dmp, bndasp->num_points, bndasp->points);
+ glPointSize(1);
+
+ if (dmp->i->dm_light)
+ glEnable(GL_LIGHTING);
+
+ return 0;
+ }
+
+ int i, j;
+ fastf_t halfAxesSize; /* half the length of an axis */
+ point_t ptA, ptB;
+ point_t *points;
+ /* Save the line attributes */
+ int saveLineWidth = dmp->i->dm_lineWidth;
+ int saveLineStyle = dmp->i->dm_lineStyle;
+
+ points = (point_t *)bu_calloc(npoints, sizeof(point_t), "data axes
points");
+ halfAxesSize = bndasp->size * 0.5 * sf;
+
+ /* set linewidth */
+ dm_set_line_attr(dmp, bndasp->line_width, 0); /* solid lines */
+
+ for (i = 0, j = -1; i < bndasp->num_points; ++i) {
+ /* draw X axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X] - halfAxesSize, bndasp->points[i][Y],
bndasp->points[i][Z]);
+ VSET(ptB, bndasp->points[i][X] + halfAxesSize, bndasp->points[i][Y],
bndasp->points[i][Z]);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+ /* draw Y axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X], bndasp->points[i][Y] - halfAxesSize,
bndasp->points[i][Z]);
+ VSET(ptB, bndasp->points[i][X], bndasp->points[i][Y] + halfAxesSize,
bndasp->points[i][Z]);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+
+ /* draw Z axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X], bndasp->points[i][Y],
bndasp->points[i][Z] - halfAxesSize);
+ VSET(ptB, bndasp->points[i][X], bndasp->points[i][Y],
bndasp->points[i][Z] + halfAxesSize);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+ }
+
+ dm_draw_lines_3d(dmp, npoints, points, 0);
+ bu_free((void *)points, "data axes points");
+
+ /* Restore the line attributes */
+ dm_set_line_attr(dmp, saveLineWidth, saveLineStyle);
+
+
+ return 0;
+}
+
+
HIDDEN int
osgl_drawVList(struct dm *dmp, struct bn_vlist *vp)
{
@@ -2566,7 +2642,7 @@
osgl_drawPoints3D,
osgl_drawVList,
osgl_drawVListHiddenLine,
- NULL,
+ osgl_draw_data_axes,
osgl_draw,
osgl_setFGColor,
osgl_setBGColor,
Modified: brlcad/branches/dm-fb-merge/src/libdm/wgl/dm-wgl.c
===================================================================
--- brlcad/branches/dm-fb-merge/src/libdm/wgl/dm-wgl.c 2020-04-21 20:54:39 UTC
(rev 75508)
+++ brlcad/branches/dm-fb-merge/src/libdm/wgl/dm-wgl.c 2020-04-21 21:42:16 UTC
(rev 75509)
@@ -1125,6 +1125,82 @@
}
+int
+wgl_draw_data_axes(struct dm *dmp,
+ fastf_t sf,
+ struct bview_data_axes_state *bndasp)
+{
+ int npoints = bndasp->num_points * 6;
+ if (npoints < 1)
+ return 0;
+
+ /* set color */
+ dm_set_fg(dmp, bndasp->color[0], bndasp->color[1], bndasp->color[2], 1,
1.0);
+
+ if (bndasp->draw > 1) {
+ if (dmp->i->dm_light)
+ glDisable(GL_LIGHTING);
+
+ glPointSize(bndasp->size);
+ dm_draw_points_3d(dmp, bndasp->num_points, bndasp->points);
+ glPointSize(1);
+
+ if (dmp->i->dm_light)
+ glEnable(GL_LIGHTING);
+
+ return 0;
+ }
+
+ int i, j;
+ fastf_t halfAxesSize; /* half the length of an axis */
+ point_t ptA, ptB;
+ point_t *points;
+ /* Save the line attributes */
+ int saveLineWidth = dmp->i->dm_lineWidth;
+ int saveLineStyle = dmp->i->dm_lineStyle;
+
+ points = (point_t *)bu_calloc(npoints, sizeof(point_t), "data axes
points");
+ halfAxesSize = bndasp->size * 0.5 * sf;
+
+ /* set linewidth */
+ dm_set_line_attr(dmp, bndasp->line_width, 0); /* solid lines */
+
+ for (i = 0, j = -1; i < bndasp->num_points; ++i) {
+ /* draw X axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X] - halfAxesSize, bndasp->points[i][Y],
bndasp->points[i][Z]);
+ VSET(ptB, bndasp->points[i][X] + halfAxesSize, bndasp->points[i][Y],
bndasp->points[i][Z]);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+
+ /* draw Y axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X], bndasp->points[i][Y] - halfAxesSize,
bndasp->points[i][Z]);
+ VSET(ptB, bndasp->points[i][X], bndasp->points[i][Y] + halfAxesSize,
bndasp->points[i][Z]);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+
+ /* draw Z axis with x/y offsets */
+ VSET(ptA, bndasp->points[i][X], bndasp->points[i][Y],
bndasp->points[i][Z] - halfAxesSize);
+ VSET(ptB, bndasp->points[i][X], bndasp->points[i][Y],
bndasp->points[i][Z] + halfAxesSize);
+ ++j;
+ VMOVE(points[j], ptA);
+ ++j;
+ VMOVE(points[j], ptB);
+ }
+
+ dm_draw_lines_3d(dmp, npoints, points, 0);
+ bu_free((void *)points, "data axes points");
+
+ /* Restore the line attributes */
+ dm_set_line_attr(dmp, saveLineWidth, saveLineStyle);
+
+
+ return 0;
+}
+
HIDDEN int
wgl_drawVList(struct dm *dmp, struct bn_vlist *vp)
{
@@ -2507,7 +2583,7 @@
wgl_drawPoints3D,
wgl_drawVList,
wgl_drawVListHiddenLine,
- NULL,
+ wgl_draw_data_axes,
wgl_draw,
wgl_setFGColor,
wgl_setBGColor,
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits