home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / vos2-121.zip / v / vopengl / gears / gearcnv.cpp < prev    next >
C/C++ Source or Header  |  1998-11-03  |  16KB  |  632 lines

  1. //=======================================================================
  2. //@V@:Note: This file generated by vgen V1.04 (10:25:37 22 Jun 1998).
  3. //    gearcnv.cpp:    Source for gearOGLCanvasPane class
  4. //=======================================================================
  5.  
  6. #include "gearcnv.h"
  7.  
  8. #include <stdlib.h>
  9. #include <math.h>
  10. #if !defined (_WIN32) && !defined (OS2)
  11. #include <unistd.h>
  12. #endif
  13. /* Some <math.h> files do not define M_PI... */
  14. #ifndef M_PI
  15. #define M_PI 3.14159265
  16. #endif
  17. #include <sys/types.h>
  18. #include <stdio.h>
  19.  
  20. /* For portability... */
  21. #undef fcos
  22. #undef fsin
  23. #undef fsqrt
  24. #define fcos  cos
  25. #define fsin  sin
  26. #define fsqrt sqrt
  27.  
  28. static double d_near = 1.0;
  29. static double d_far = 2000;
  30. static int poo = 0;
  31.  
  32. typedef struct {
  33.   float rad, wid;
  34. } Profile;
  35.  
  36. void flat_face(float ir, float or, float wd);
  37. void draw_inside(float w1, float w2, float rad);
  38. void draw_outside(float w1, float w2, float rad);
  39. void tooth_side(int nt, float ir, float or, float tp, float tip, float wd);
  40.  
  41. int circle_subdiv;
  42.  
  43. void
  44. gear(int nt, float wd, float ir, float or, float tp, float tip, int ns, Profile * ip)
  45. {
  46.   /**
  47.    * nt - number of teeth 
  48.    * wd - width of gear at teeth
  49.    * ir - inside radius absolute scale
  50.    * or - radius at outside of wheel (tip of tooth) ratio of ir
  51.    * tp - ratio of tooth in slice of circle (0..1] (1 = teeth are touching at base)
  52.    * tip - ratio of tip of tooth (0..tp] (cant be wider that base of tooth)
  53.    * ns - number of elements in wheel width profile
  54.    * *ip - list of float pairs {start radius, width, ...} (width is ratio to wd)
  55.    *
  56.    */
  57.  
  58.   /* gear lying on xy plane, z for width. all normals calulated 
  59.      (normalized) */
  60.  
  61.   float prev;
  62.   int k, t;
  63.  
  64.   /* estimat # times to divide circle */
  65.   if (nt <= 0)
  66.     circle_subdiv = 64;
  67.   else {
  68.     /* lowest multiple of number of teeth */
  69.     circle_subdiv = nt;
  70.     while (circle_subdiv < 64)
  71.       circle_subdiv += nt;
  72.   }
  73.  
  74.   /* --- draw wheel face --- */
  75.  
  76.   /* draw horzontal, vertical faces for each section. if first
  77.      section radius not zero, use wd for 0.. first if ns == 0
  78.      use wd for whole face. last width used to edge.  */
  79.  
  80.   if (ns <= 0) {
  81.     flat_face(0.0, ir, wd);
  82.   } else {
  83.     /* draw first flat_face, then continue in loop */
  84.     if (ip[0].rad > 0.0) {
  85.       flat_face(0.0, ip[0].rad * ir, wd);
  86.       prev = wd;
  87.       t = 0;
  88.     } else {
  89.       flat_face(0.0, ip[1].rad * ir, ip[0].wid * wd);
  90.       prev = ip[0].wid;
  91.       t = 1;
  92.     }
  93.     for (k = t; k < ns; k++) {
  94.       if (prev < ip[k].wid) {
  95.         draw_inside(prev * wd, ip[k].wid * wd, ip[k].rad * ir);
  96.       } else {
  97.         draw_outside(prev * wd, ip[k].wid * wd, ip[k].rad * ir);
  98.       }
  99.       prev = ip[k].wid;
  100.       /* - draw to edge of wheel, add final face if needed - */
  101.       if (k == ns - 1) {
  102.         flat_face(ip[k].rad * ir, ir, ip[k].wid * wd);
  103.  
  104.         /* now draw side to match tooth rim */
  105.         if (ip[k].wid < 1.0) {
  106.           draw_inside(ip[k].wid * wd, wd, ir);
  107.         } else {
  108.           draw_outside(ip[k].wid * wd, wd, ir);
  109.         }
  110.       } else {
  111.         flat_face(ip[k].rad * ir, ip[k + 1].rad * ir, ip[k].wid * wd);
  112.       }
  113.     }
  114.   }
  115.  
  116.   /* --- tooth side faces --- */
  117.   tooth_side(nt, ir, or, tp, tip, wd);
  118.  
  119.   /* --- tooth hill surface --- */
  120. }
  121.  
  122. void 
  123. tooth_side(int nt, float ir, float or, float tp, float tip, float wd)
  124. {
  125.  
  126.   float i;
  127.   float end = 2.0 * M_PI / nt;
  128.   float x[6], y[6];
  129.   float s[3], c[3];
  130.  
  131.   or = or * ir;         /* or is really a ratio of ir */
  132.   for (i = 0; i < 2.0 * M_PI - end / 4.0; i += end) {
  133.  
  134.     c[0] = fcos(i);
  135.     s[0] = fsin(i);
  136.     c[1] = fcos(i + end * (0.5 - tip / 2));
  137.     s[1] = fsin(i + end * (0.5 - tip / 2));
  138.     c[2] = fcos(i + end * (0.5 + tp / 2));
  139.     s[2] = fsin(i + end * (0.5 + tp / 2));
  140.  
  141.     x[0] = ir * c[0];
  142.     y[0] = ir * s[0];
  143.     x[5] = ir * fcos(i + end);
  144.     y[5] = ir * fsin(i + end);
  145.     /* ---treat veritices 1,4 special to match strait edge of
  146.        face */
  147.     x[1] = x[0] + (x[5] - x[0]) * (0.5 - tp / 2);
  148.     y[1] = y[0] + (y[5] - y[0]) * (0.5 - tp / 2);
  149.     x[4] = x[0] + (x[5] - x[0]) * (0.5 + tp / 2);
  150.     y[4] = y[0] + (y[5] - y[0]) * (0.5 + tp / 2);
  151.     x[2] = or * fcos(i + end * (0.5 - tip / 2));
  152.     y[2] = or * fsin(i + end * (0.5 - tip / 2));
  153.     x[3] = or * fcos(i + end * (0.5 + tip / 2));
  154.     y[3] = or * fsin(i + end * (0.5 + tip / 2));
  155.  
  156.     /* draw face trapezoids as 2 tmesh */
  157.     glNormal3f(0.0, 0.0, 1.0);
  158.     glBegin(GL_TRIANGLE_STRIP);
  159.     glVertex3f(x[2], y[2], wd / 2);
  160.     glVertex3f(x[1], y[1], wd / 2);
  161.     glVertex3f(x[3], y[3], wd / 2);
  162.     glVertex3f(x[4], y[4], wd / 2);
  163.     glEnd();
  164.  
  165.     glNormal3f(0.0, 0.0, -1.0);
  166.     glBegin(GL_TRIANGLE_STRIP);
  167.     glVertex3f(x[2], y[2], -wd / 2);
  168.     glVertex3f(x[1], y[1], -wd / 2);
  169.     glVertex3f(x[3], y[3], -wd / 2);
  170.     glVertex3f(x[4], y[4], -wd / 2);
  171.     glEnd();
  172.  
  173.     /* draw inside rim pieces */
  174.     glNormal3f(c[0], s[0], 0.0);
  175.     glBegin(GL_TRIANGLE_STRIP);
  176.     glVertex3f(x[0], y[0], -wd / 2);
  177.     glVertex3f(x[1], y[1], -wd / 2);
  178.     glVertex3f(x[0], y[0], wd / 2);
  179.     glVertex3f(x[1], y[1], wd / 2);
  180.     glEnd();
  181.  
  182.     /* draw up hill side */
  183.     {
  184.       float a, b, n;
  185.       /* calculate normal of face */
  186.       a = x[2] - x[1];
  187.       b = y[2] - y[1];
  188.       n = 1.0 / fsqrt(a * a + b * b);
  189.       a = a * n;
  190.       b = b * n;
  191.       glNormal3f(b, -a, 0.0);
  192.     }
  193.     glBegin(GL_TRIANGLE_STRIP);
  194.     glVertex3f(x[1], y[1], -wd / 2);
  195.     glVertex3f(x[2], y[2], -wd / 2);
  196.     glVertex3f(x[1], y[1], wd / 2);
  197.     glVertex3f(x[2], y[2], wd / 2);
  198.     glEnd();
  199.     /* draw top of hill */
  200.     glNormal3f(c[1], s[1], 0.0);
  201.     glBegin(GL_TRIANGLE_STRIP);
  202.     glVertex3f(x[2], y[2], -wd / 2);
  203.     glVertex3f(x[3], y[3], -wd / 2);
  204.     glVertex3f(x[2], y[2], wd / 2);
  205.     glVertex3f(x[3], y[3], wd / 2);
  206.     glEnd();
  207.  
  208.     /* draw down hill side */
  209.     {
  210.       float a, b, c;
  211.       /* calculate normal of face */
  212.       a = x[4] - x[3];
  213.       b = y[4] - y[3];
  214.       c = 1.0 / fsqrt(a * a + b * b);
  215.       a = a * c;
  216.       b = b * c;
  217.       glNormal3f(b, -a, 0.0);
  218.     }
  219.     glBegin(GL_TRIANGLE_STRIP);
  220.     glVertex3f(x[3], y[3], -wd / 2);
  221.     glVertex3f(x[4], y[4], -wd / 2);
  222.     glVertex3f(x[3], y[3], wd / 2);
  223.     glVertex3f(x[4], y[4], wd / 2);
  224.     glEnd();
  225.     /* inside rim part */
  226.     glNormal3f(c[2], s[2], 0.0);
  227.     glBegin(GL_TRIANGLE_STRIP);
  228.     glVertex3f(x[4], y[4], -wd / 2);
  229.     glVertex3f(x[5], y[5], -wd / 2);
  230.     glVertex3f(x[4], y[4], wd / 2);
  231.     glVertex3f(x[5], y[5], wd / 2);
  232.     glEnd();
  233.   }
  234. }
  235.  
  236. void 
  237. flat_face(float ir, float or, float wd)
  238. {
  239.  
  240.   int i;
  241.   float w;
  242.  
  243.   /* draw each face (top & bottom ) * */
  244.   if (poo)
  245.     printf("Face  : %f..%f wid=%f\n", ir, or, wd);
  246.   if (wd == 0.0)
  247.     return;
  248.   for (w = wd / 2; w > -wd; w -= wd) {
  249.     if (w > 0.0)
  250.       glNormal3f(0.0, 0.0, 1.0);
  251.     else
  252.       glNormal3f(0.0, 0.0, -1.0);
  253.  
  254.     if (ir == 0.0) {
  255.       /* draw as t-fan */
  256.       glBegin(GL_TRIANGLE_FAN);
  257.       glVertex3f(0.0, 0.0, w);  /* center */
  258.       glVertex3f(or, 0.0, w);
  259.       for (i = 1; i < circle_subdiv; i++) {
  260.         glVertex3f(fcos(2.0 * M_PI * i / circle_subdiv) * or,
  261.           fsin(2.0 * M_PI * i / circle_subdiv) * or,
  262.           w);
  263.       }
  264.       glVertex3f(or, 0.0, w);
  265.       glEnd();
  266.     } else {
  267.       /* draw as tmesh */
  268.       glBegin(GL_TRIANGLE_STRIP);
  269.       glVertex3f(or, 0.0, w);
  270.       glVertex3f(ir, 0.0, w);
  271.       for (i = 1; i < circle_subdiv; i++) {
  272.         glVertex3f(fcos(2.0 * M_PI * i / circle_subdiv) * or,
  273.           fsin(2.0 * M_PI * i / circle_subdiv) * or,
  274.           w);
  275.         glVertex3f(fcos(2.0 * M_PI * i / circle_subdiv) * ir,
  276.           fsin(2.0 * M_PI * i / circle_subdiv) * ir,
  277.           w);
  278.       }
  279.       glVertex3f(or, 0.0, w);
  280.       glVertex3f(ir, 0.0, w);
  281.       glEnd();
  282.  
  283.     }
  284.   }
  285. }
  286.  
  287. void 
  288. draw_inside(float w1, float w2, float rad)
  289. {
  290.  
  291.   int i, j;
  292.   float c, s;
  293.   if (poo)
  294.     printf("Inside: wid=%f..%f rad=%f\n", w1, w2, rad);
  295.   if (w1 == w2)
  296.     return;
  297.  
  298.   w1 = w1 / 2;
  299.   w2 = w2 / 2;
  300.   for (j = 0; j < 2; j++) {
  301.     if (j == 1) {
  302.       w1 = -w1;
  303.       w2 = -w2;
  304.     }
  305.     glBegin(GL_TRIANGLE_STRIP);
  306.     glNormal3f(-1.0, 0.0, 0.0);
  307.     glVertex3f(rad, 0.0, w1);
  308.     glVertex3f(rad, 0.0, w2);
  309.     for (i = 1; i < circle_subdiv; i++) {
  310.       c = fcos(2.0 * M_PI * i / circle_subdiv);
  311.       s = fsin(2.0 * M_PI * i / circle_subdiv);
  312.       glNormal3f(-c, -s, 0.0);
  313.       glVertex3f(c * rad,
  314.         s * rad,
  315.         w1);
  316.       glVertex3f(c * rad,
  317.         s * rad,
  318.         w2);
  319.     }
  320.     glNormal3f(-1.0, 0.0, 0.0);
  321.     glVertex3f(rad, 0.0, w1);
  322.     glVertex3f(rad, 0.0, w2);
  323.     glEnd();
  324.   }
  325. }
  326.  
  327. void 
  328. draw_outside(float w1, float w2, float rad)
  329. {
  330.  
  331.   int i, j;
  332.   float c, s;
  333.   if (poo)
  334.     printf("Outsid: wid=%f..%f rad=%f\n", w1, w2, rad);
  335.   if (w1 == w2)
  336.     return;
  337.  
  338.   w1 = w1 / 2;
  339.   w2 = w2 / 2;
  340.   for (j = 0; j < 2; j++) {
  341.     if (j == 1) {
  342.       w1 = -w1;
  343.       w2 = -w2;
  344.     }
  345.     glBegin(GL_TRIANGLE_STRIP);
  346.     glNormal3f(1.0, 0.0, 0.0);
  347.     glVertex3f(rad, 0.0, w1);
  348.     glVertex3f(rad, 0.0, w2);
  349.     for (i = 1; i < circle_subdiv; i++) {
  350.       c = fcos(2.0 * M_PI * i / circle_subdiv);
  351.       s = fsin(2.0 * M_PI * i / circle_subdiv);
  352.       glNormal3f(c, s, 0.0);
  353.       glVertex3f(c * rad,
  354.         s * rad,
  355.         w1);
  356.       glVertex3f(c * rad,
  357.         s * rad,
  358.         w2);
  359.     }
  360.     glNormal3f(1.0, 0.0, 0.0);
  361.     glVertex3f(rad, 0.0, w1);
  362.     glVertex3f(rad, 0.0, w2);
  363.     glEnd();
  364.   }
  365. }
  366.  
  367. Profile gear_profile[] =
  368. {0.000, 0.0,
  369.   0.300, 7.0,
  370.   0.340, 0.4,
  371.   0.550, 0.64,
  372.   0.600, 0.4,
  373.   0.950, 1.0
  374. };
  375.  
  376. float a1 = 27.0;
  377. float a2 = 67.0;
  378. float a3 = 47.0;
  379. float a4 = 87.0;
  380. float i1 = 1.2;
  381. float i2 = 3.1;
  382. float i3 = 2.3;
  383. float i4 = 1.1;
  384.  
  385. void
  386. oneFrame(void)
  387. {
  388.  
  389.   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  390.  
  391.   glPushMatrix();
  392.   glTranslatef(0.0, 0.0, -4.0);
  393.   glRotatef(a3, 1.0, 1.0, 1.0);
  394.   glRotatef(a4, 0.0, 0.0, -1.0);
  395.   glTranslatef(0.14, 0.2, 0.0);
  396.   gear(76,
  397.     0.4, 2.0, 1.1,
  398.     0.4, 0.04,
  399.     sizeof(gear_profile) / sizeof(Profile), gear_profile);
  400.   glPopMatrix();
  401.  
  402.   glPushMatrix();
  403.   glTranslatef(0.1, 0.2, -3.8);
  404.   glRotatef(a2, -4.0, 2.0, -1.0);
  405.   glRotatef(a1, 1.0, -3.0, 1.0);
  406.   glTranslatef(0.0, -0.2, 0.0);
  407.   gear(36,
  408.     0.4, 2.0, 1.1,
  409.     0.7, 0.2,
  410.     sizeof(gear_profile) / sizeof(Profile), gear_profile);
  411.   glPopMatrix();
  412.  
  413.   a1 += i1;
  414.   if (a1 > 360.0)
  415.     a1 -= 360.0;
  416.   if (a1 < 0.0)
  417.     a1 -= 360.0;
  418.   a2 += i2;
  419.   if (a2 > 360.0)
  420.     a2 -= 360.0;
  421.   if (a2 < 0.0)
  422.     a2 -= 360.0;
  423.   a3 += i3;
  424.   if (a3 > 360.0)
  425.     a3 -= 360.0;
  426.   if (a3 < 0.0)
  427.     a3 -= 360.0;
  428.   a4 += i4;
  429.   if (a4 > 360.0)
  430.     a4 -= 360.0;
  431.   if (a4 < 0.0)
  432.     a4 -= 360.0;
  433. }
  434.  
  435. void
  436.  
  437. display(void)
  438. {
  439.   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  440. }
  441.  
  442. void
  443. myReshape(int w, int h)
  444. {
  445.   glViewport(0, 0, w, h);
  446.   glMatrixMode(GL_PROJECTION);
  447.   glLoadIdentity();
  448.   glFrustum(-1.0, 1.0, -1.0, 1.0, d_near, d_far);
  449.   /**
  450.     use perspective instead:
  451.  
  452.     if (w <= h){
  453.         glOrtho( 0.0, 1.0,
  454.                  0.0, 1.0 * (GLfloat) h / (GLfloat) w,
  455.                 -16.0, 4.0);
  456.     }else{
  457.         glOrtho( 0.0, 1.0 * (GLfloat) w / (GLfloat) h,
  458.                  0.0, 1.0,
  459.                 -16.0, 4.0);
  460.     }
  461.    */
  462.   glMatrixMode(GL_MODELVIEW);
  463.   glLoadIdentity();
  464.   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  465. }
  466.  
  467. void
  468. myinit(void)
  469. {
  470.   float f[20];
  471.   glClearColor(0.0, 0.0, 0.0, 0.0);
  472.   myReshape(300, 300);
  473.   /* glShadeModel(GL_FLAT); */
  474.   glEnable(GL_DEPTH_TEST);
  475.   glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  476.  
  477.   glEnable(GL_LIGHTING);
  478.  
  479.   glLightf(GL_LIGHT0, GL_SHININESS, 1.0);
  480.   f[0] = 1.3;
  481.   f[1] = 1.3;
  482.   f[2] = -3.3;
  483.   f[3] = 1.0;
  484.   glLightfv(GL_LIGHT0, GL_POSITION, f);
  485.   f[0] = 0.8;
  486.   f[1] = 1.0;
  487.   f[2] = 0.83;
  488.   f[3] = 1.0;
  489.   glLightfv(GL_LIGHT0, GL_SPECULAR, f);
  490.   glLightfv(GL_LIGHT0, GL_DIFFUSE, f);
  491.   glEnable(GL_LIGHT0);
  492.  
  493.   glLightf(GL_LIGHT1, GL_SHININESS, 1.0);
  494.   f[0] = -2.3;
  495.   f[1] = 0.3;
  496.   f[2] = -7.3;
  497.   f[3] = 1.0;
  498.   glLightfv(GL_LIGHT1, GL_POSITION, f);
  499.   f[0] = 1.0;
  500.   f[1] = 0.8;
  501.   f[2] = 0.93;
  502.   f[3] = 1.0;
  503.   glLightfv(GL_LIGHT1, GL_SPECULAR, f);
  504.   glLightfv(GL_LIGHT1, GL_DIFFUSE, f);
  505.   glEnable(GL_LIGHT1);
  506.  
  507.   /* gear material */
  508.   f[0] = 0.1;
  509.   f[1] = 0.15;
  510.   f[2] = 0.2;
  511.   f[3] = 1.0;
  512.   glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, f);
  513.  
  514.   f[0] = 0.9;
  515.   f[1] = 0.3;
  516.   f[2] = 0.3;
  517.   f[3] = 1.0;
  518.   glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, f);
  519.  
  520.   f[0] = 0.4;
  521.   f[1] = 0.9;
  522.   f[2] = 0.6;
  523.   f[3] = 1.0;
  524.   glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, f);
  525.  
  526.   glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 4);
  527. }
  528.  
  529.  
  530. //===================>>> gearOGLCanvasPane::gearOGLCanvasPane <<<====================
  531.   gearOGLCanvasPane::gearOGLCanvasPane()
  532.   {
  533.     initDone = 0;
  534.   }
  535.  
  536. //===================>>> gearOGLCanvasPane::~gearOGLCanvasPane <<<====================
  537.   gearOGLCanvasPane::~gearOGLCanvasPane()
  538.   {
  539.   }
  540.  
  541. //======================>>> gearOGLCanvasPane::TimerAnimate <<<========================
  542.   void gearOGLCanvasPane::TimerAnimate(void)
  543.   {
  544.     // **** Called by CmdWindow AuxTimer for animation.
  545.     vglMakeCurrent();  // Typically done here
  546.     oneFrame();
  547.     vglFlush();  // After you draw, typically flush
  548.  
  549.   }
  550. //======================>>> gearOGLCanvasPane::graphicsInit <<<========================
  551.   void gearOGLCanvasPane::graphicsInit(void)
  552.   {
  553.     vBaseGLCanvasPane::graphicsInit();    // Always call the superclass first!
  554.  
  555.     // **** Your OpenGL initialization code goes here!
  556.  
  557.     myinit();
  558.     initDone = 1;
  559.   }
  560. //======================>>> gearOGLCanvasPane::HPage <<<========================
  561.   void gearOGLCanvasPane::HPage(int shown, int top)
  562.   {
  563.     vBaseGLCanvasPane::HPage(shown, top);
  564.   }
  565.  
  566. //======================>>> gearOGLCanvasPane::VPage <<<========================
  567.   void gearOGLCanvasPane::VPage(int shown, int top)
  568.   {
  569.     vBaseGLCanvasPane::VPage(shown, top);
  570.   }
  571.  
  572. //=======================>>> gearOGLCanvasPane::HScroll <<<======================
  573.   void gearOGLCanvasPane::HScroll(int step)
  574.   {
  575.     vBaseGLCanvasPane::HScroll(step);
  576.   }
  577.  
  578. //======================>>> gearOGLCanvasPane::VScroll <<<======================
  579.   void gearOGLCanvasPane::VScroll(int step)
  580.   {
  581.     vBaseGLCanvasPane::VScroll(step);
  582.   }
  583.  
  584. //======================>>> gearOGLCanvasPane::MouseDown <<<======================
  585.   void gearOGLCanvasPane::MouseDown(int X, int Y, int button)
  586.   {
  587.     vBaseGLCanvasPane::MouseDown(X,Y,button);
  588.   }
  589.  
  590. //========================>>> gearOGLCanvasPane::MouseUp <<<======================
  591.   void gearOGLCanvasPane::MouseUp(int X, int Y, int button)
  592.   {
  593.     vBaseGLCanvasPane::MouseUp(X,Y,button);
  594.   }
  595.  
  596. //======================>>> gearCanvasPane::MouseMove <<<======================
  597.   void gearOGLCanvasPane::MouseMove(int x, int y, int button)
  598.   {
  599.     vBaseGLCanvasPane::MouseMove(x,y,button);
  600.   }
  601.  
  602. //=========================>>> gearOGLCanvasPane::Redraw <<<======================
  603.   void gearOGLCanvasPane::Redraw(int x, int y, int w, int h)
  604.   {
  605.     static int inRedraw = 0;
  606.  
  607.     if (inRedraw || !initDone)  // Don't draw until initialized
  608.         return;
  609.  
  610.     inRedraw = 1;  // Don't allow recursive redraws.
  611.  
  612.     vglMakeCurrent();  // Typically done here
  613.  
  614.     // *** Your drawing code typically goes here. You may
  615.     // insert it here, or just call a drawing routine.
  616.  
  617.     display();
  618.  
  619.     vglFlush();  // After you draw, typically flush
  620.  
  621.     inRedraw = 0;  // Out of Redraw
  622.  
  623.   }
  624.  
  625. //======================>>> gearOGLCanvasPane::Resize <<<======================
  626.   void gearOGLCanvasPane::Resize(int w, int h)
  627.   {
  628.     vBaseGLCanvasPane::Resize(w,h);
  629.     myReshape(w,h);
  630.   }
  631.  
  632.