ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libgender/view.C
(Generate patch)

Comparing libgender/view.C (file contents):
Revision 1.23 by root, Wed Oct 6 05:24:03 2004 UTC vs.
Revision 1.30 by root, Wed Oct 6 16:19:14 2004 UTC

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
6view::view () 9view::view ()
65 glTranslatef (-p.x, -p.y, -p.z); 68 glTranslatef (-p.x, -p.y, -p.z);
66} 69}
67 70
68void view::begin () 71void view::begin ()
69{ 72{
73 glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
74 glDepthRange (0, 1. - (1. / pow (2., 16.)));
75
70 vismap.clear (); 76 vismap.clear ();
71 vislist.clear (); 77 vislist.clear ();
72 78
73 generation++; 79 generation++;
74 80
75 reset_projection (); 81 reset_projection ();
76 82
77 // check occlusion queries here 83 // check occlusion queries here
84#if 0
78 for (vector<octant *>::iterator i = checklist.begin (); i != checklist.end (); ++i) 85 for (vector<octant *>::iterator i = checklist.begin (); i != checklist.end (); ++i)
79 //printf ("%p %d\n", *i, occ_query_result ((*i)->occ_query)); 86 //printf ("%p %d\n", *i, occ_query_result ((*i)->occ_query));
80 occ_query_result ((*i)->occ_query); 87 occ_query_result ((*i)->occ_query);
81 88
82 checklist.clear (); 89 checklist.clear ();
90#endif
83 91
84 world.detect_visibility (*this); 92 world.detect_visibility (*this);
85} 93}
86 94
87void view::end () 95void view::end ()
101 glEnable (GL_POLYGON_OFFSET_FILL); 109 glEnable (GL_POLYGON_OFFSET_FILL);
102 glPolygonOffset (0, 1); 110 glPolygonOffset (0, 1);
103 glDepthFunc (GL_LESS); 111 glDepthFunc (GL_LESS);
104 glDisable (GL_LIGHTING); 112 glDisable (GL_LIGHTING);
105 glColorMask (0, 0, 0, 0); 113 glColorMask (0, 0, 0, 0);
106 //cgGLDisableProfile (vsh_profile); 114 cgGLEnableProfile (vsh_profile);// z-fighting??
107 cgGLDisableProfile (fsh_profile); 115 cgGLDisableProfile (fsh_profile);
108 } 116 }
109 else 117 else
110 { 118 {
111#if 0
112 glEnable (GL_MINMAX); 119 glEnable (GL_MINMAX);
113#endif
114 glDisable (GL_POLYGON_OFFSET_FILL); 120 glDisable (GL_POLYGON_OFFSET_FILL);
115 glDepthFunc (GL_LESS); 121 glDepthFunc (GL_LESS);
116 glDepthMask (0); 122 glDepthMask (0);
117 cgGLEnableProfile (vsh_profile); 123 cgGLEnableProfile (vsh_profile);
118 cgGLEnableProfile (fsh_profile); 124 cgGLEnableProfile (fsh_profile);
121 for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i) 127 for (vector<octant *>::iterator i = vislist.begin (); i != vislist.end (); ++i)
122 (*i)->display (*this); 128 (*i)->display (*this);
123 129
124 drawn.clear (); 130 drawn.clear ();
125 131
132 if (mode == view::LIGHTED)
133 {
134 glEnable (GL_DEPTH_CLAMP_NV);
135 glDepthFunc (GL_LESS);
136 glEnable (GL_COLOR_MATERIAL);
137 glDisable (GL_LIGHTING);
138#if 1
139 cgGLDisableProfile (vsh_profile);
140 cgGLDisableProfile (fsh_profile);
141#endif
142 glShadeModel (GL_FLAT);
143
144 static int count; count++;
145 if (farlist.size ())
146 printf ("%d: size %d\n", count, farlist.size ());
147
148 for (vector<octant *>::iterator i = farlist.begin (); i != farlist.end (); ++i)
149 {
150 glColor3f (1 / (GLfloat)(i - farlist.begin()), 1, 1 / (GLfloat)(i - farlist.begin()));
151 (*i)->draw_bbox (*this);
152 }
153
154 farlist.clear ();
155
156 glEnable (GL_DEPTH_TEST);
157 glDisable (GL_DEPTH_CLAMP_NV);
158 glShadeModel (GL_SMOOTH);
159 }
160
126 glColorMask (1, 1, 1, 0); 161 glColorMask (1, 1, 1, 0);
127 glDepthMask (1); 162 glDepthMask (1);
163
128} 164}
129 165
130 166

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines