]> git.mxchange.org Git - simgear.git/blob - simgear/scene/sky/clouds3d/camdisplay.cpp
Clouds3D crashes because there is no Light
[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 #ifdef HAVE_CONFIG_H
23 #  include <simgear_config.h>
24 #endif
25
26 #ifdef HAVE_WINDOWS_H
27 #  include <windows.h>
28 #endif
29
30 #include GLUT_H
31
32 #include "camera.hpp"
33
34 //----------------------------------------------------------------------------
35 // OPENGL CAMERA FRUSTUM DRAWING ROUTINES
36 //----------------------------------------------------------------------------
37 void Camera::Display() const
38 {
39   // CALC EIGHT CORNERS OF FRUSTUM (NEAR PTS AND FAR PTS)
40   Vec3f V[8];
41   CalcVerts(V);
42
43
44   // DRAW THE FRUSTUM IN WIREFRAME
45   glBegin(GL_LINE_LOOP);  // TOP FACE
46     glVertex3fv(&(V[4].x)); glVertex3fv(&(V[5].x)); 
47     glVertex3fv(&(V[1].x)); glVertex3fv(&(V[0].x));
48   glEnd();
49   glBegin(GL_LINE_LOOP);  // BOTTOM FACE
50     glVertex3fv(&(V[3].x)); glVertex3fv(&(V[2].x));
51     glVertex3fv(&(V[6].x)); glVertex3fv(&(V[7].x)); 
52   glEnd();
53   glBegin(GL_LINE_LOOP);  // LEFT FACE
54     glVertex3fv(&(V[1].x)); glVertex3fv(&(V[5].x));
55     glVertex3fv(&(V[6].x)); glVertex3fv(&(V[2].x)); 
56   glEnd();
57   glBegin(GL_LINE_LOOP);  // RIGHT FACE
58     glVertex3fv(&(V[0].x)); glVertex3fv(&(V[3].x));
59     glVertex3fv(&(V[7].x)); glVertex3fv(&(V[4].x)); 
60   glEnd();
61   glBegin(GL_LINE_LOOP);  // NEAR FACE
62     glVertex3fv(&(V[1].x)); glVertex3fv(&(V[2].x));
63     glVertex3fv(&(V[3].x)); glVertex3fv(&(V[0].x)); 
64   glEnd();
65   glBegin(GL_LINE_LOOP);  // FAR FACE
66     glVertex3fv(&(V[4].x)); glVertex3fv(&(V[7].x));
67     glVertex3fv(&(V[6].x)); glVertex3fv(&(V[5].x)); 
68   glEnd();
69
70   // DRAW PROJECTOR LINES FROM EYE TO CORNERS OF VIEWPLANE WINDOW
71   glBegin(GL_LINES);
72     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[1].x));
73     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[2].x));
74     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[3].x));
75     glVertex3fv(&(Orig.x)); glVertex3fv(&(V[0].x));
76   glEnd();
77
78 }
79 void Camera::DisplayInGreen() const
80 {
81   //draws the camera in unlit green lines, then restores the GL state
82   glPushAttrib(GL_LIGHTING_BIT);
83   glDisable(GL_LIGHTING);
84   glPushAttrib(GL_LINE_BIT);
85   glLineWidth(1.0);
86   glColor3f(0,1,0);
87
88   Display();
89
90   glPopAttrib();
91   glPopAttrib();
92   
93 }