]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/camdisplay.cpp
Initial revision.
[simgear.git] / simgear / scene / sky / clouds3d / camdisplay.cpp
1 //------------------------------------------------------------------------------
2 // File : camdisplay.cpp
3 //------------------------------------------------------------------------------
4 // GLVU : Copyright 1997 - 2002 
5 //        The University of North Carolina at Chapel Hill
6 //------------------------------------------------------------------------------
7 // Permission to use, copy, modify, distribute and sell this software and its 
8 // documentation for any purpose is hereby granted without fee, provided that 
9 // the above copyright notice appear in all copies and that both that copyright 
10 // notice and this permission notice appear in supporting documentation. 
11 // Binaries may be compiled with this software without any royalties or 
12 // restrictions. 
13 //
14 // The University of North Carolina at Chapel Hill makes no representations 
15 // about the suitability of this software for any purpose. It is provided 
16 // "as is" without express or implied warranty.
17
18 //============================================================================
19 // camdisplay.cpp
20 //============================================================================
21
22 #include <GL/glut.h>
23 #include "camera.hpp"
24
25 //----------------------------------------------------------------------------
26 // OPENGL CAMERA FRUSTUM DRAWING ROUTINES
27 //----------------------------------------------------------------------------
28 void Camera::Display() const
29 {
30   // CALC EIGHT CORNERS OF FRUSTUM (NEAR PTS AND FAR PTS)
31   Vec3f V[8];
32   CalcVerts(V);
33
34
35   // DRAW THE FRUSTUM IN WIREFRAME
36   glBegin(GL_LINE_LOOP);  // TOP FACE
37     glVertex3fv(&(V[4].x)); glVertex3fv(&(V[5].x)); 
38     glVertex3fv(&(V[1].x)); glVertex3fv(&(V[0].x));
39   glEnd();
40   glBegin(GL_LINE_LOOP);  // BOTTOM FACE
41     glVertex3fv(&(V[3].x)); glVertex3fv(&(V[2].x));
42     glVertex3fv(&(V[6].x)); glVertex3fv(&(V[7].x)); 
43   glEnd();
44   glBegin(GL_LINE_LOOP);  // LEFT FACE
45     glVertex3fv(&(V[1].x)); glVertex3fv(&(V[5].x));
46     glVertex3fv(&(V[6].x)); glVertex3fv(&(V[2].x)); 
47   glEnd();
48   glBegin(GL_LINE_LOOP);  // RIGHT FACE
49     glVertex3fv(&(V[0].x)); glVertex3fv(&(V[3].x));
50     glVertex3fv(&(V[7].x)); glVertex3fv(&(V[4].x)); 
51   glEnd();
52   glBegin(GL_LINE_LOOP);  // NEAR FACE
53     glVertex3fv(&(V[1].x)); glVertex3fv(&(V[2].x));
54     glVertex3fv(&(V[3].x)); glVertex3fv(&(V[0].x)); 
55   glEnd();
56   glBegin(GL_LINE_LOOP);  // FAR FACE
57     glVertex3fv(&(V[4].x)); glVertex3fv(&(V[7].x));
58     glVertex3fv(&(V[6].x)); glVertex3fv(&(V[5].x)); 
59   glEnd();
60
61   // DRAW PROJECTOR LINES FROM EYE TO CORNERS OF VIEWPLANE WINDOW
62   glBegin(GL_LINES);
63     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[1].x));
64     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[2].x));
65     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[3].x));
66     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[0].x));
67   glEnd();
68
69 }
70 void Camera::DisplayInGreen() const
71 {
72   //draws the camera in unlit green lines, then restores the GL state
73   glPushAttrib(GL_LIGHTING_BIT);
74   glDisable(GL_LIGHTING);
75   glPushAttrib(GL_LINE_BIT);
76   glLineWidth(1.0);
77   glColor3f(0,1,0);
78
79   Display();
80
81   glPopAttrib();
82   glPopAttrib();
83   
84 }