… | |
… | |
2 | |
2 | |
3 | #include "oct.h" |
3 | #include "oct.h" |
4 | #include "view.h" |
4 | #include "view.h" |
5 | |
5 | |
6 | view::view () |
6 | view::view () |
7 | : mode(LIGHTED) |
7 | : gamma(1.0) |
8 | { |
8 | { |
9 | } |
9 | } |
10 | |
10 | |
11 | view::~view () |
11 | view::~view () |
12 | { |
12 | { |
… | |
… | |
19 | |
19 | |
20 | drawn.insert (e); |
20 | drawn.insert (e); |
21 | return true; |
21 | return true; |
22 | } |
22 | } |
23 | |
23 | |
24 | void view::draw () |
24 | void view::reset_projection () |
25 | { |
25 | { |
26 | // check occlusion queries here |
|
|
27 | |
|
|
28 | generation++; |
|
|
29 | |
|
|
30 | renormalize (orig, p); |
26 | renormalize (orig, p); |
31 | |
27 | |
32 | glDisable (GL_ALPHA_TEST); |
|
|
33 | glDisable (GL_BLEND); |
|
|
34 | |
|
|
35 | if (mode == view::DEPTH) |
|
|
36 | { |
|
|
37 | glEnable (GL_POLYGON_OFFSET_FILL); |
|
|
38 | glPolygonOffset (0, 1); |
|
|
39 | glDepthFunc (GL_LESS); |
|
|
40 | glDisable (GL_LIGHTING); |
|
|
41 | glColorMask (0, 0, 0, 0); |
|
|
42 | //cgGLDisableProfile (CG_PROFILE_ARBVP1); |
|
|
43 | cgGLDisableProfile (CG_PROFILE_ARBFP1); |
|
|
44 | } |
|
|
45 | else |
|
|
46 | { |
|
|
47 | glEnable (GL_MINMAX); |
|
|
48 | glDisable (GL_POLYGON_OFFSET_FILL); |
|
|
49 | glDepthFunc (GL_LESS); |
|
|
50 | glDepthMask (0); |
|
|
51 | cgGLEnableProfile (CG_PROFILE_ARBVP1); |
|
|
52 | cgGLEnableProfile (CG_PROFILE_ARBFP1); |
|
|
53 | } |
|
|
54 | |
|
|
55 | glViewport (0, 0, w, h); |
28 | glViewport (0, 0, w, h); |
56 | |
29 | |
57 | glMatrixMode (GL_PROJECTION); |
30 | glMatrixMode (GL_PROJECTION); |
58 | glLoadIdentity (); |
31 | glLoadIdentity (); |
59 | |
32 | |
… | |
… | |
88 | frustum.f = plane ( m(3,0) - m(2,0), m(3,1) - m(2,1), m(3,2) - m(2,2), m(3,3) - m(2,3) ); |
61 | frustum.f = plane ( m(3,0) - m(2,0), m(3,1) - m(2,1), m(3,2) - m(2,2), m(3,3) - m(2,3) ); |
89 | |
62 | |
90 | glMatrixMode (GL_MODELVIEW); |
63 | glMatrixMode (GL_MODELVIEW); |
91 | glLoadIdentity (); |
64 | glLoadIdentity (); |
92 | glTranslatef (-p.x, -p.y, -p.z); |
65 | glTranslatef (-p.x, -p.y, -p.z); |
|
|
66 | } |
93 | |
67 | |
|
|
68 | void view::begin () |
|
|
69 | { |
94 | vislist.clear (); |
70 | vismap.clear (); |
|
|
71 | |
|
|
72 | generation++; |
|
|
73 | |
|
|
74 | reset_projection (); |
|
|
75 | |
|
|
76 | // check occlusion queries here |
95 | checklist.clear (); |
77 | checklist.clear (); |
|
|
78 | |
96 | world.detect_visibility (*this); |
79 | world.detect_visibility (*this); |
|
|
80 | } |
97 | |
81 | |
|
|
82 | void view::end () |
|
|
83 | { |
|
|
84 | vismap.clear (); |
|
|
85 | } |
|
|
86 | |
|
|
87 | void view::pass (enum mode m) |
|
|
88 | { |
|
|
89 | mode = m; |
|
|
90 | |
|
|
91 | glDisable (GL_ALPHA_TEST); |
|
|
92 | glDisable (GL_BLEND); |
|
|
93 | |
|
|
94 | if (mode == view::DEPTH) |
|
|
95 | { |
|
|
96 | glEnable (GL_POLYGON_OFFSET_FILL); |
|
|
97 | glPolygonOffset (0, 1); |
|
|
98 | glDepthFunc (GL_LESS); |
|
|
99 | glDisable (GL_LIGHTING); |
|
|
100 | glColorMask (0, 0, 0, 0); |
|
|
101 | //cgGLDisableProfile (CG_PROFILE_ARBVP1); |
|
|
102 | cgGLDisableProfile (CG_PROFILE_ARBFP1); |
|
|
103 | } |
|
|
104 | else |
|
|
105 | { |
|
|
106 | glEnable (GL_MINMAX); |
|
|
107 | glDisable (GL_POLYGON_OFFSET_FILL); |
|
|
108 | glDepthFunc (GL_LESS); |
|
|
109 | glDepthMask (0); |
|
|
110 | cgGLEnableProfile (CG_PROFILE_ARBVP1); |
|
|
111 | cgGLEnableProfile (CG_PROFILE_ARBFP1); |
|
|
112 | } |
|
|
113 | |
98 | for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i) |
114 | for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i) |
99 | (*i)->display (*this); |
115 | (*i)->display (*this); |
100 | |
116 | |
101 | drawn.clear (); |
117 | drawn.clear (); |
102 | |
118 | |