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
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.
18 //============================================================================
20 //============================================================================
23 # include <simgear_config.h>
34 //----------------------------------------------------------------------------
35 // OPENGL CAMERA FRUSTUM DRAWING ROUTINES
36 //----------------------------------------------------------------------------
37 void Camera::Display() const
39 // CALC EIGHT CORNERS OF FRUSTUM (NEAR PTS AND FAR PTS)
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));
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));
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));
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));
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));
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));
70 // DRAW PROJECTOR LINES FROM EYE TO CORNERS OF VIEWPLANE WINDOW
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));
79 void Camera::DisplayInGreen() const
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);