1 | #include <cmath> |
1 | #include <cmath> |
|
|
2 | |
|
|
3 | #include <GL/gl.h> |
|
|
4 | #include <GL/glext.h> |
2 | |
5 | |
3 | #include "oct.h" |
6 | #include "oct.h" |
4 | #include "view.h" |
7 | #include "view.h" |
5 | |
8 | |
6 | view::view () |
9 | view::view () |
… | |
… | |
73 | generation++; |
76 | generation++; |
74 | |
77 | |
75 | reset_projection (); |
78 | reset_projection (); |
76 | |
79 | |
77 | // check occlusion queries here |
80 | // check occlusion queries here |
|
|
81 | #if 0 |
78 | for (vector<octant *>::iterator i = checklist.begin (); i != checklist.end (); ++i) |
82 | for (vector<octant *>::iterator i = checklist.begin (); i != checklist.end (); ++i) |
79 | printf ("%p %d\n", *i, occ_query_result ((*i)->occ_query)); |
83 | //printf ("%p %d\n", *i, occ_query_result ((*i)->occ_query)); |
|
|
84 | occ_query_result ((*i)->occ_query); |
80 | |
85 | |
81 | checklist.clear (); |
86 | checklist.clear (); |
|
|
87 | #endif |
82 | |
88 | |
83 | world.detect_visibility (*this); |
89 | world.detect_visibility (*this); |
84 | } |
90 | } |
85 | |
91 | |
86 | void view::end () |
92 | void view::end () |
… | |
… | |
100 | glEnable (GL_POLYGON_OFFSET_FILL); |
106 | glEnable (GL_POLYGON_OFFSET_FILL); |
101 | glPolygonOffset (0, 1); |
107 | glPolygonOffset (0, 1); |
102 | glDepthFunc (GL_LESS); |
108 | glDepthFunc (GL_LESS); |
103 | glDisable (GL_LIGHTING); |
109 | glDisable (GL_LIGHTING); |
104 | glColorMask (0, 0, 0, 0); |
110 | glColorMask (0, 0, 0, 0); |
105 | //cgGLDisableProfile (CG_PROFILE_ARBVP1); |
111 | cgGLEnableProfile (vsh_profile);// z-fighting?? |
106 | cgGLDisableProfile (CG_PROFILE_ARBFP1); |
112 | cgGLDisableProfile (fsh_profile); |
107 | } |
113 | } |
108 | else |
114 | else |
109 | { |
115 | { |
110 | #if 0 |
|
|
111 | glEnable (GL_MINMAX); |
116 | glEnable (GL_MINMAX); |
112 | #endif |
|
|
113 | glDisable (GL_POLYGON_OFFSET_FILL); |
117 | glDisable (GL_POLYGON_OFFSET_FILL); |
114 | glDepthFunc (GL_LESS); |
118 | glDepthFunc (GL_LESS); |
115 | glDepthMask (0); |
119 | glDepthMask (0); |
116 | cgGLEnableProfile (CG_PROFILE_ARBVP1); |
120 | cgGLEnableProfile (vsh_profile); |
117 | cgGLEnableProfile (CG_PROFILE_ARBFP1); |
121 | cgGLEnableProfile (fsh_profile); |
118 | } |
122 | } |
119 | |
123 | |
120 | for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i) |
124 | for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i) |
121 | (*i)->display (*this); |
125 | (*i)->display (*this); |
122 | |
126 | |
123 | drawn.clear (); |
127 | drawn.clear (); |
124 | |
128 | |
|
|
129 | if (mode == view::LIGHTED) |
|
|
130 | { |
|
|
131 | glEnable (GL_DEPTH_CLAMP_NV); |
|
|
132 | glDepthFunc (GL_LEQUAL); |
|
|
133 | glEnable (GL_COLOR_MATERIAL); |
|
|
134 | glDisable (GL_CULL_FACE); |
|
|
135 | #if 0 |
|
|
136 | cgGLDisableProfile (vsh_profile); |
|
|
137 | cgGLDisableProfile (fsh_profile); |
|
|
138 | #endif |
|
|
139 | glShadeModel (GL_FLAT); |
|
|
140 | GLfloat m[4] = { 1, 0, 1, 0 }; |
|
|
141 | glColor3f (1, 0, 1); |
|
|
142 | //glMaterialfv (GL_FRONT_AND_BACK, GL_AMBIENT, m); |
|
|
143 | //glLightModelfv (GL_LIGHT_MODEL_AMBIENT, m); |
|
|
144 | |
|
|
145 | static int count; count++; |
|
|
146 | if (farlist.size ()) |
|
|
147 | printf ("%d: size %d\n", count, farlist.size ()); |
|
|
148 | |
|
|
149 | for (vector<octant *>::iterator i = farlist.begin (); i != farlist.end (); ++i) |
|
|
150 | (*i)->draw_bbox (*this); |
|
|
151 | |
|
|
152 | farlist.clear (); |
|
|
153 | |
|
|
154 | glEnable (GL_DEPTH_TEST); |
|
|
155 | glDisable (GL_DEPTH_CLAMP_NV); |
|
|
156 | glShadeModel (GL_SMOOTH); |
|
|
157 | } |
|
|
158 | |
125 | glColorMask (1, 1, 1, 0); |
159 | glColorMask (1, 1, 1, 0); |
126 | glDepthMask (1); |
160 | glDepthMask (1); |
|
|
161 | |
127 | } |
162 | } |
128 | |
163 | |
129 | |
164 | |