Revision: 44151
          http://brlcad.svn.sourceforge.net/brlcad/?rev=44151&view=rev
Author:   bob1961
Date:     2011-04-01 16:12:53 +0000 (Fri, 01 Apr 2011)

Log Message:
-----------
Added the dm_reshape function to struct dm. This splits out the bits of code in 
dm-ogl and dm-wgl that reconfigure the openGL window after a resize.

Modified Paths:
--------------
    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

Modified: brlcad/trunk/include/dm.h
===================================================================
--- brlcad/trunk/include/dm.h   2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/include/dm.h   2011-04-01 16:12:53 UTC (rev 44151)
@@ -247,6 +247,7 @@
     int (*dm_drawDList)();
     int (*dm_freeDLists)();
     int (*dm_getDisplayImage)(struct dm *dmp, unsigned char **image);
+    void (*dm_reshape)();
     unsigned long dm_id;          /**< @brief window id */
     int dm_displaylist;                /**< @brief !0 means device has 
displaylist */
     int dm_stereo;                /**< @brief stereo flag */

Modified: brlcad/trunk/src/libdm/dm-Null.c
===================================================================
--- brlcad/trunk/src/libdm/dm-Null.c    2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-Null.c    2011-04-01 16:12:53 UTC (rev 44151)
@@ -129,6 +129,7 @@
     Nu_int0,
     Nu_int0,
     Nu_getDisplayImage, /* display to image function */
+    Nu_void,
     0,
     0,                         /* no displaylist */
     0,                         /* no stereo */

Modified: brlcad/trunk/src/libdm/dm-X.c
===================================================================
--- brlcad/trunk/src/libdm/dm-X.c       2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-X.c       2011-04-01 16:12:53 UTC (rev 44151)
@@ -134,6 +134,15 @@
 }
 
 
+HIDDEN void
+X_reshape(struct dm *dmp, int width, int height)
+{
+    dmp->dm_height = height;
+    dmp->dm_width = width;
+    dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
+}
+
+
 HIDDEN int
 X_configureWin_guts(struct dm *dmp, int force)
 {
@@ -152,9 +161,7 @@
        dmp->dm_width == xwa.width)
        return TCL_OK;
 
-    dmp->dm_height = xwa.height;
-    dmp->dm_width = xwa.width;
-    dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
+    X_reshape(dmp, xwa.width, xwa.height);
 
     if (dmp->dm_debugLevel) {
        bu_log("X_configureWin_guts()\n");
@@ -1617,6 +1624,7 @@
     return TCL_OK;
 }
 
+
 /* Display Manager package interface */
 struct dm dm_X = {
     X_close,
@@ -1647,6 +1655,7 @@
     Nu_int0,
     Nu_int0,
     X_getDisplayImage, /* display to image function */
+    X_reshape,
     0,
     0,                         /* no displaylist */
     0,                            /* no stereo */

Modified: brlcad/trunk/src/libdm/dm-ogl.c
===================================================================
--- brlcad/trunk/src/libdm/dm-ogl.c     2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-ogl.c     2011-04-01 16:12:53 UTC (rev 44151)
@@ -128,11 +128,13 @@
 HIDDEN int ogl_drawDList(struct dm *dmp, unsigned int list);
 HIDDEN int ogl_freeDLists(struct dm *dmp, unsigned int list, int range);
 HIDDEN int ogl_getDisplayImage(struct dm *dmp, unsigned char **image);
+HIDDEN void ogl_reshape(struct dm *dmp, int width, int height);
 
 HIDDEN int ogl_drawString2D(struct dm *dmp, char *str, fastf_t x, fastf_t y, 
int size, int use_aspect);
 HIDDEN int ogl_setLight(struct dm *dmp, int lighting_on);
 HIDDEN int ogl_setZBuffer(struct dm *dmp, int zbuffer_on);
 
+
 struct dm dm_ogl = {
     ogl_close,
     ogl_drawBegin,
@@ -162,6 +164,7 @@
     ogl_drawDList,
     ogl_freeDLists,
     ogl_getDisplayImage, /* display to image function */
+    ogl_reshape,
     0,
     1,                         /* has displaylist */
     0,                          /* no stereo by default */
@@ -271,7 +274,6 @@
 HIDDEN int
 ogl_configureWin_guts(struct dm *dmp, int force)
 {
-    GLint mm;
     XWindowAttributes xwa;
     XFontStruct *newfontstruct;
 
@@ -294,39 +296,8 @@
        dmp->dm_width == xwa.width)
        return TCL_OK;
 
-    dmp->dm_height = xwa.height;
-    dmp->dm_width = xwa.width;
-    dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
+    ogl_reshape(dmp, xwa.width, xwa.height);
 
-    if (dmp->dm_debugLevel) {
-       bu_log("ogl_configureWin_guts()\n");
-       bu_log("width = %d, height = %d\n", dmp->dm_width, dmp->dm_height);
-    }
-
-    glViewport(0, 0, dmp->dm_width, dmp->dm_height);
-#if 0
-    glScissor(0,  0, (dmp->dm_width)+1,
-             (dmp->dm_height)+1);
-#endif
-
-    if (dmp->dm_zbuffer)
-       ogl_setZBuffer(dmp, dmp->dm_zbuffer);
-
-    ogl_setLight(dmp, dmp->dm_light);
-
-    glClearColor(((struct ogl_vars *)dmp->dm_vars.priv_vars)->r,
-                ((struct ogl_vars *)dmp->dm_vars.priv_vars)->g,
-                ((struct ogl_vars *)dmp->dm_vars.priv_vars)->b,
-                0.0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-    /*CJXX this might cause problems in perspective mode? */
-    glGetIntegerv(GL_MATRIX_MODE, &mm);
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-    glOrtho(-xlim_view, xlim_view, -ylim_view, ylim_view, 0.0, 2.0);
-    glMatrixMode(mm);
-
     /* First time through, load a font or quit */
     if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->fontstruct == NULL) {
        if ((((struct dm_xvars *)dmp->dm_vars.pub_vars)->fontstruct =
@@ -443,6 +414,48 @@
 }
 
 
+HIDDEN void
+ogl_reshape(struct dm *dmp, int width, int height)
+{
+    GLint mm;
+
+    dmp->dm_height = height;
+    dmp->dm_width = width;
+    dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
+
+    if (dmp->dm_debugLevel) {
+       bu_log("ogl_configureWin_guts()\n");
+       bu_log("width = %d, height = %d\n", dmp->dm_width, dmp->dm_height);
+    }
+
+    glViewport(0, 0, dmp->dm_width, dmp->dm_height);
+#if 0
+    glScissor(0,  0, (dmp->dm_width)+1,
+             (dmp->dm_height)+1);
+#endif
+
+#if 0
+    if (dmp->dm_zbuffer)
+       ogl_setZBuffer(dmp, dmp->dm_zbuffer);
+
+    ogl_setLight(dmp, dmp->dm_light);
+#endif
+
+    glClearColor(((struct ogl_vars *)dmp->dm_vars.priv_vars)->r,
+                ((struct ogl_vars *)dmp->dm_vars.priv_vars)->g,
+                ((struct ogl_vars *)dmp->dm_vars.priv_vars)->b,
+                0.0);
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+    /*CJXX this might cause problems in perspective mode? */
+    glGetIntegerv(GL_MATRIX_MODE, &mm);
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glOrtho(-xlim_view, xlim_view, -ylim_view, ylim_view, 0.0, 2.0);
+    glMatrixMode(mm);
+}
+
+
 HIDDEN int
 ogl_configureWin(struct dm *dmp, int force)
 {

Modified: brlcad/trunk/src/libdm/dm-plot.c
===================================================================
--- brlcad/trunk/src/libdm/dm-plot.c    2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-plot.c    2011-04-01 16:12:53 UTC (rev 44151)
@@ -531,6 +531,7 @@
     Nu_int0,
     Nu_int0,
     Nu_int0, /* display to image function */
+    Nu_void,
     0,
     0,                         /* no displaylist */
     0,                         /* no stereo */

Modified: brlcad/trunk/src/libdm/dm-ps.c
===================================================================
--- brlcad/trunk/src/libdm/dm-ps.c      2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-ps.c      2011-04-01 16:12:53 UTC (rev 44151)
@@ -540,6 +540,7 @@
     Nu_int0,
     Nu_int0,
     Nu_int0, /* display to image function */
+    Nu_void,
     0,
     0,                         /* no displaylist */
     0,                            /* no stereo */

Modified: brlcad/trunk/src/libdm/dm-rtgl.c
===================================================================
--- brlcad/trunk/src/libdm/dm-rtgl.c    2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-rtgl.c    2011-04-01 16:12:53 UTC (rev 44151)
@@ -116,6 +116,7 @@
     rtgl_drawDList,
     rtgl_freeDLists,
     Nu_int0, /* display to image function */
+    Nu_void,
     0,
     1,                         /* has displaylist */
     0,                          /* no stereo by default */

Modified: brlcad/trunk/src/libdm/dm-tk.c
===================================================================
--- brlcad/trunk/src/libdm/dm-tk.c      2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-tk.c      2011-04-01 16:12:53 UTC (rev 44151)
@@ -830,6 +830,7 @@
     Nu_int0,
     Nu_int0,
     Nu_int0, /* display to image function */
+    Nu_void,
     0,
     0,                         /* no displaylist */
     0,                            /* no stereo */

Modified: brlcad/trunk/src/libdm/dm-wgl.c
===================================================================
--- brlcad/trunk/src/libdm/dm-wgl.c     2011-04-01 14:45:20 UTC (rev 44150)
+++ brlcad/trunk/src/libdm/dm-wgl.c     2011-04-01 16:12:53 UTC (rev 44151)
@@ -68,6 +68,7 @@
 HIDDEN int     wgl_configureWin_guts();
 HIDDEN int     wgl_setLight();
 HIDDEN int     wgl_setZBuffer();
+HIDDEN void    wgl_reshape(struct dm *dmp, int width, int height);
 
 static fastf_t default_viewscale = 1000.0;
 static double  xlim_view = 1.0;        /* args for glOrtho*/
@@ -1512,7 +1513,6 @@
 wgl_configureWin_guts(struct dm *dmp,
                      int force)
 {
-    GLint mm;
     HFONT newfontstruct, oldfont;
     LOGFONT logfont;
     HWND hwnd;
@@ -1536,35 +1536,8 @@
        dmp->dm_width == (xwa.right-xwa.left))
        return TCL_OK;
 
-    dmp->dm_height = xwa.bottom-xwa.top;
-    dmp->dm_width = xwa.right-xwa.left;
-    dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
+    wgl_reshape(dmp, xwa.width, xwa.height);
 
-    if (dmp->dm_debugLevel) {
-       bu_log("wgl_configureWin_guts()\n");
-       bu_log("width = %d, height = %d\n", dmp->dm_width, dmp->dm_height);
-    }
-
-    glViewport(0, 0, dmp->dm_width, dmp->dm_height);
-
-    if (dmp->dm_zbuffer)
-       wgl_setZBuffer(dmp, dmp->dm_zbuffer);
-
-    wgl_setLight(dmp, dmp->dm_light);
-
-    glClearColor(((struct wgl_vars *)dmp->dm_vars.priv_vars)->r,
-                ((struct wgl_vars *)dmp->dm_vars.priv_vars)->g,
-                ((struct wgl_vars *)dmp->dm_vars.priv_vars)->b,
-                0.0);
-    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
-
-    /*CJXX this might cause problems in perspective mode? */
-    glGetIntegerv(GL_MATRIX_MODE, &mm);
-    glMatrixMode(GL_PROJECTION);
-    glLoadIdentity();
-    glOrtho( -xlim_view, xlim_view, -ylim_view, ylim_view, 0.0, 2.0 );
-    glMatrixMode(mm);
-
     /* First time through, load a font or quit */
     if (((struct dm_xvars *)dmp->dm_vars.pub_vars)->fontstruct == NULL) {
        logfont.lfHeight = 18;
@@ -1865,12 +1838,51 @@
 }
 
 
+HIDDEN void
+wgl_reshape(struct dm *dmp, int width, int height)
+{
+    GLint mm;
+
+    dmp->dm_height = height;
+    dmp->dm_width = width;
+    dmp->dm_aspect = (fastf_t)dmp->dm_width / (fastf_t)dmp->dm_height;
+
+    if (dmp->dm_debugLevel) {
+       bu_log("wgl_configureWin_guts()\n");
+       bu_log("width = %d, height = %d\n", dmp->dm_width, dmp->dm_height);
+    }
+
+    glViewport(0, 0, dmp->dm_width, dmp->dm_height);
+
+#if 0
+    if (dmp->dm_zbuffer)
+       wgl_setZBuffer(dmp, dmp->dm_zbuffer);
+
+    wgl_setLight(dmp, dmp->dm_light);
+#endif
+
+    glClearColor(((struct wgl_vars *)dmp->dm_vars.priv_vars)->r,
+                ((struct wgl_vars *)dmp->dm_vars.priv_vars)->g,
+                ((struct wgl_vars *)dmp->dm_vars.priv_vars)->b,
+                0.0);
+    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
+
+    /*CJXX this might cause problems in perspective mode? */
+    glGetIntegerv(GL_MATRIX_MODE, &mm);
+    glMatrixMode(GL_PROJECTION);
+    glLoadIdentity();
+    glOrtho( -xlim_view, xlim_view, -ylim_view, ylim_view, 0.0, 2.0 );
+    glMatrixMode(mm);
+}
+
+
 HIDDEN int
 wgl_configureWin(struct dm *dmp, int force)
 {
     return wgl_configureWin_guts(dmp, force);
 }
 
+
 HIDDEN int
 wgl_setLight(struct dm *dmp, int lighting_on)
 {
@@ -2069,6 +2081,7 @@
     wgl_drawDList,
     wgl_freeDLists,
     Nu_int0, /* display to image function */
+    wgl_reshape,
     0,
     1,                         /* has displaylist */
     0,                            /* no stereo by default */


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Create and publish websites with WebMatrix
Use the most popular FREE web apps or write code yourself; 
WebMatrix provides all the features you need to develop and 
publish your website. http://p.sf.net/sfu/ms-webmatrix-sf
_______________________________________________
BRL-CAD Source Commits mailing list
brlcad-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to