Revision: 55321
http://sourceforge.net/p/brlcad/code/55321
Author: bob1961
Date: 2013-05-08 11:21:11 +0000 (Wed, 08 May 2013)
Log Message:
-----------
This fixes the lighting problem exhibited in Archer when displaying geometry in
shaded mode with perspective. The main issue here is that the perspective
matrix needs to be fed separately to openGl's projection matrix stack instead
of feeding the modelview matrix stack a matrix that has both view and
perspective rolled into a single matrix.
Modified Paths:
--------------
brlcad/trunk/include/dm-Null.h
brlcad/trunk/include/dm.h
brlcad/trunk/src/libdm/dm-Null.c
brlcad/trunk/src/libdm/dm-X.c
brlcad/trunk/src/libdm/dm-ogl.c
brlcad/trunk/src/libdm/dm-plot.c
brlcad/trunk/src/libdm/dm-ps.c
brlcad/trunk/src/libdm/dm-rtgl.c
brlcad/trunk/src/libdm/dm-tk.c
brlcad/trunk/src/libdm/dm-wgl.c
brlcad/trunk/src/libtclcad/tclcad_obj.c
Modified: brlcad/trunk/include/dm-Null.h
===================================================================
--- brlcad/trunk/include/dm-Null.h 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/include/dm-Null.h 2013-05-08 11:21:11 UTC (rev 55321)
@@ -50,6 +50,10 @@
DM_EXPORT extern int
+null_loadPMatrix(fastf_t *mat);
+
+
+DM_EXPORT extern int
null_drawString2D(struct dm *dmp, const char *str, fastf_t x, fastf_t y, int
size, int use_aspect);
Modified: brlcad/trunk/include/dm.h
===================================================================
--- brlcad/trunk/include/dm.h 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/include/dm.h 2013-05-08 11:21:11 UTC (rev 55321)
@@ -223,6 +223,7 @@
int (*dm_drawEnd)(struct dm *dmp); /**< @brief formerly dmr_epilog
*/
int (*dm_normal)(struct dm *dmp);
int (*dm_loadMatrix)(struct dm *dmp, fastf_t *mat, int which_eye);
+ int (*dm_loadPMatrix)(fastf_t *mat);
int (*dm_drawString2D)(struct dm *dmp, const char *str, fastf_t x, fastf_t
y, int size, int use_aspect); /**< @brief formerly dmr_puts */
int (*dm_drawLine2D)(struct dm *dmp, fastf_t x_1, fastf_t y_1, fastf_t
x_2, fastf_t y_2); /**< @brief formerly dmr_2d_line */
int (*dm_drawLine3D)(struct dm *dmp, point_t pt1, point_t pt2);
@@ -294,6 +295,7 @@
#define DM_DRAW_END(_dmp) _dmp->dm_drawEnd(_dmp)
#define DM_NORMAL(_dmp) _dmp->dm_normal(_dmp)
#define DM_LOADMATRIX(_dmp, _mat, _eye) _dmp->dm_loadMatrix(_dmp, _mat, _eye)
+#define DM_LOADPMATRIX(_dmp, _mat) _dmp->dm_loadPMatrix(_mat)
#define DM_DRAW_STRING_2D(_dmp, _str, _x, _y, _size, _use_aspect)
_dmp->dm_drawString2D(_dmp, _str, _x, _y, _size, _use_aspect)
#define DM_DRAW_LINE_2D(_dmp, _x1, _y1, _x2, _y2) _dmp->dm_drawLine2D(_dmp,
_x1, _y1, _x2, _y2)
#define DM_DRAW_LINE_3D(_dmp, _pt1, _pt2) _dmp->dm_drawLine3D(_dmp, _pt1, _pt2)
Modified: brlcad/trunk/src/libdm/dm-Null.c
===================================================================
--- brlcad/trunk/src/libdm/dm-Null.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-Null.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -72,6 +72,13 @@
int
+null_loadPMatrix(fastf_t *UNUSED(mat))
+{
+ return 0;
+}
+
+
+int
null_drawString2D(struct dm *UNUSED(dmp), const char *UNUSED(str), fastf_t
UNUSED(x), fastf_t UNUSED(y), int UNUSED(size), int UNUSED(use_aspect))
{
return 0;
@@ -264,6 +271,7 @@
null_drawEnd,
null_normal,
null_loadMatrix,
+ null_loadPMatrix,
null_drawString2D,
null_drawLine2D,
null_drawLine3D,
Modified: brlcad/trunk/src/libdm/dm-X.c
===================================================================
--- brlcad/trunk/src/libdm/dm-X.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-X.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -1653,6 +1653,7 @@
X_drawEnd,
X_normal,
X_loadMatrix,
+ null_loadPMatrix,
X_drawString2D,
X_drawLine2D,
X_drawLine3D,
Modified: brlcad/trunk/src/libdm/dm-ogl.c
===================================================================
--- brlcad/trunk/src/libdm/dm-ogl.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-ogl.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -102,6 +102,7 @@
HIDDEN int ogl_drawEnd(struct dm *dmp);
HIDDEN int ogl_normal(struct dm *dmp);
HIDDEN int ogl_loadMatrix(struct dm *dmp, fastf_t *mat, int which_eye);
+HIDDEN int ogl_loadPMatrix(fastf_t *mat);
HIDDEN int ogl_drawString2D(struct dm *dmp, const char *str, fastf_t x,
fastf_t y, int size, int use_aspect);
HIDDEN int ogl_drawLine2D(struct dm *dmp, fastf_t X1, fastf_t Y1, fastf_t X2,
fastf_t Y2);
HIDDEN int ogl_drawLine3D(struct dm *dmp, point_t pt1, point_t pt2);
@@ -141,6 +142,7 @@
ogl_drawEnd,
ogl_normal,
ogl_loadMatrix,
+ ogl_loadPMatrix,
ogl_drawString2D,
ogl_drawLine2D,
ogl_drawLine3D,
@@ -1383,6 +1385,48 @@
/*
+ * O G L _ L O A D P M A T R I X
+ *
+ * Load a new projection matrix. This will be followed by
+ * many calls to ogl_draw().
+ */
+HIDDEN int
+ogl_loadPMatrix(fastf_t *mat)
+{
+ fastf_t *mptr;
+ GLfloat gtmat[16];
+
+ mptr = mat;
+
+ gtmat[0] = *(mptr++);
+ gtmat[4] = *(mptr++);
+ gtmat[8] = *(mptr++);
+ gtmat[12] = *(mptr++);
+
+ gtmat[1] = *(mptr++);
+ gtmat[5] = *(mptr++);
+ gtmat[9] = *(mptr++);
+ gtmat[13] = *(mptr++);
+
+ gtmat[2] = *(mptr++);
+ gtmat[6] = *(mptr++);
+ gtmat[10] = -*(mptr++);
+ gtmat[14] = -*(mptr++);
+
+ gtmat[3] = *(mptr++);
+ gtmat[7] = *(mptr++);
+ gtmat[11] = *(mptr++);
+ gtmat[15] = *(mptr++);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glLoadMatrixf(gtmat);
+
+ return TCL_OK;
+}
+
+
+/*
* O G L _ D R A W V L I S T H I D D E N L I N E
*
*/
Modified: brlcad/trunk/src/libdm/dm-plot.c
===================================================================
--- brlcad/trunk/src/libdm/dm-plot.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-plot.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -507,6 +507,7 @@
plot_drawEnd,
plot_normal,
plot_loadMatrix,
+ null_loadPMatrix,
plot_drawString2D,
plot_drawLine2D,
plot_drawLine3D,
Modified: brlcad/trunk/src/libdm/dm-ps.c
===================================================================
--- brlcad/trunk/src/libdm/dm-ps.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-ps.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -511,6 +511,7 @@
ps_drawEnd,
ps_normal,
ps_loadMatrix,
+ null_loadPMatrix,
ps_drawString2D,
ps_drawLine2D,
ps_drawLine3D,
Modified: brlcad/trunk/src/libdm/dm-rtgl.c
===================================================================
--- brlcad/trunk/src/libdm/dm-rtgl.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-rtgl.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -93,6 +93,7 @@
rtgl_drawEnd,
rtgl_normal,
rtgl_loadMatrix,
+ null_loadPMatrix,
rtgl_drawString2D,
rtgl_drawLine2D,
rtgl_drawLine3D,
Modified: brlcad/trunk/src/libdm/dm-tk.c
===================================================================
--- brlcad/trunk/src/libdm/dm-tk.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-tk.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -814,6 +814,7 @@
tk_drawEnd,
tk_normal,
tk_loadMatrix,
+ null_loadPMatrix,
tk_drawString2D,
tk_drawLine2D,
tk_drawLine3D,
Modified: brlcad/trunk/src/libdm/dm-wgl.c
===================================================================
--- brlcad/trunk/src/libdm/dm-wgl.c 2013-05-08 02:59:47 UTC (rev 55320)
+++ brlcad/trunk/src/libdm/dm-wgl.c 2013-05-08 11:21:11 UTC (rev 55321)
@@ -906,6 +906,48 @@
/*
+ * W G L _ L O A D P M A T R I X
+ *
+ * Load a new projection matrix. This will be followed by
+ * many calls to ogl_draw().
+ */
+HIDDEN int
+wgl_loadPMatrix(fastf_t *mat)
+{
+ fastf_t *mptr;
+ GLfloat gtmat[16];
+
+ mptr = mat;
+
+ gtmat[0] = *(mptr++);
+ gtmat[4] = *(mptr++);
+ gtmat[8] = *(mptr++);
+ gtmat[12] = *(mptr++);
+
+ gtmat[1] = *(mptr++);
+ gtmat[5] = *(mptr++);
+ gtmat[9] = *(mptr++);
+ gtmat[13] = *(mptr++);
+
+ gtmat[2] = *(mptr++);
+ gtmat[6] = *(mptr++);
+ gtmat[10] = -*(mptr++);
+ gtmat[14] = -*(mptr++);
+
+ gtmat[3] = *(mptr++);
+ gtmat[7] = *(mptr++);
+ gtmat[11] = *(mptr++);
+ gtmat[15] = *(mptr++);
+
+ glMatrixMode(GL_PROJECTION);
+ glLoadIdentity();
+ glLoadMatrixf(gtmat);
+
+ return TCL_OK;
+}
+
+
+/*
* W G L _ D R A W V L I S T H I D D E N L I N E
*
*/
@@ -2099,6 +2141,7 @@
wgl_drawEnd,
wgl_normal,
wgl_loadMatrix,
+ wgl_loadPMatrix,
wgl_drawString2D,
wgl_drawLine2D,
wgl_drawLine3D,
Modified: brlcad/trunk/src/libtclcad/tclcad_obj.c
===================================================================
--- brlcad/trunk/src/libtclcad/tclcad_obj.c 2013-05-08 02:59:47 UTC (rev
55320)
+++ brlcad/trunk/src/libtclcad/tclcad_obj.c 2013-05-08 11:21:11 UTC (rev
55321)
@@ -13214,6 +13214,10 @@
HIDDEN void
go_draw(struct ged_dm_view *gdvp)
{
+#if 1
+ DM_LOADMATRIX(gdvp->gdv_dmp, gdvp->gdv_view->gv_model2view, 0);
+ DM_LOADPMATRIX(gdvp->gdv_dmp, gdvp->gdv_view->gv_pmat);
+#else
matp_t mat;
if (SMALL_FASTF < gdvp->gdv_view->gv_perspective)
@@ -13222,6 +13226,7 @@
mat = gdvp->gdv_view->gv_model2view;
DM_LOADMATRIX(gdvp->gdv_dmp, mat, 0);
+#endif
go_draw_dlist(gdvp->gdv_gop, gdvp->gdv_dmp,
&gdvp->gdv_gop->go_gedp->ged_gdp->gd_headDisplay);
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and
their applications. This 200-page book is written by three acclaimed
leaders in the field. The early access version is available now.
Download your free book today! http://p.sf.net/sfu/neotech_d2d_may
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits