home *** CD-ROM | disk | FTP | other *** search
/ OpenGL Superbible (2nd Edition) / OpenGL SuperBible e2.iso / tools / FLTK-1.0.6 / test / CubeView.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-03-10  |  3.3 KB  |  124 lines

  1. //
  2. // "$Id: CubeView.h,v 1.4 1999/03/10 16:40:19 mike Exp $"
  3. //
  4. // CubeView class definitions for the Fast Light Tool Kit (FLTK).
  5. //
  6. // Copyright 1998-1999 by Bill Spitzak and others.
  7. //
  8. // This library is free software; you can redistribute it and/or
  9. // modify it under the terms of the GNU Library General Public
  10. // License as published by the Free Software Foundation; either
  11. // version 2 of the License, or (at your option) any later version.
  12. //
  13. // This library is distributed in the hope that it will be useful,
  14. // but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  16. // Library General Public License for more details.
  17. //
  18. // You should have received a copy of the GNU Library General Public
  19. // License along with this library; if not, write to the Free Software
  20. // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  21. // USA.
  22. //
  23. // Please report all bugs and problems to "fltk-bugs@easysw.com".
  24. //
  25.  
  26. #ifndef CUBEVIEW_H
  27. #define CUBEVIEW_H 1
  28. #include <config.h>
  29. #include <FL/Fl.H>
  30. #if HAVE_GL
  31. #  include <FL/Fl_Gl_Window.H>
  32. #  include <FL/gl.h>
  33. #  include <GL/glu.h>
  34. #else
  35. #  include <FL/Fl_Box.H>
  36. #endif /* HAVE_GL */
  37.  
  38. #include <stdlib.h>
  39.  
  40. #if HAVE_GL
  41. class CubeView : public Fl_Gl_Window {
  42. #else
  43. class CubeView : public Fl_Box {
  44. #endif /* HAVE_GL */
  45.  
  46. public:
  47.     // this value determines the scaling factor used to draw the cube.
  48.     double size;
  49.  
  50.     CubeView(int x,int y,int w,int h,const char *l=0);
  51.  
  52.     /* Set the rotation about the vertical (y ) axis.
  53.      *
  54.      * This function is called by the horizontal roller in CubeViewUI and the
  55.      * initialize button in CubeViewUI.
  56.      */
  57.     void v_angle(float angle){vAng=angle;};
  58.     
  59.     // Return the rotation about the vertical (y ) axis.
  60.     float v_angle(){return vAng;};
  61.  
  62.     /* Set the rotation about the horizontal (x ) axis.
  63.      *
  64.      * This function is called by the vertical roller in CubeViewUI and the
  65.      * initialize button in CubeViewUI.
  66.      */
  67.  
  68.     void h_angle(float angle){hAng=angle;};
  69.  
  70.     // the rotation about the horizontal (x ) axis.
  71.     float h_angle(){return hAng;};
  72.  
  73.     /* Sets the x shift of the cube view camera.
  74.      *
  75.      * This function is called by the slider in CubeViewUI and the
  76.      * initialize button in CubeViewUI.
  77.      */
  78.     void panx(float x){xshift=x;};
  79.     /* Sets the y shift of the cube view camera.
  80.      *
  81.      * This function is called by the slider in CubeViewUI and the
  82.      * initialize button in CubeViewUI.
  83.      */
  84.     void pany(float y){yshift=y;};
  85.  
  86. #if HAVE_GL
  87.     /*The widget class draw() override.
  88.      *
  89.      *The draw() function initialize Gl for another round o f drawing
  90.      * then calls specialized functions for drawing each of the
  91.      * entities displayed in the cube view.
  92.      *
  93.      */
  94.     void draw();    
  95. #endif /* HAVE_GL */
  96. private:
  97.  
  98.     /*  Draw the cube boundaries
  99.      *
  100.      *Draw the faces of the cube using the boxv[] vertices, using
  101.      * GL_LINE_LOOP for the faces. The color is \#defined by CUBECOLOR.
  102.      */
  103. #if HAVE_GL
  104.     void drawCube();
  105. #else
  106.     void drawCube() { }
  107. #endif /* HAVE_GL */
  108.     
  109.     float vAng,hAng;
  110.     float xshift,yshift;
  111.  
  112.  
  113.     float boxv0[3];float boxv1[3];
  114.     float boxv2[3];float boxv3[3];
  115.     float boxv4[3];float boxv5[3];
  116.     float boxv6[3];float boxv7[3];
  117.  
  118. };
  119. #endif
  120.  
  121. //
  122. // End of "$Id: CubeView.h,v 1.4 1999/03/10 16:40:19 mike Exp $".
  123. //
  124.