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

Comparing libgender/util.C (file contents):
Revision 1.37 by root, Mon Oct 18 12:01:14 2004 UTC vs.
Revision 1.38 by root, Tue Oct 19 11:35:20 2004 UTC

238 return m; 238 return m;
239 } 239 }
240 240
241 ///////////////////////////////////////////////////////////////////////////// 241 /////////////////////////////////////////////////////////////////////////////
242 242
243 void draw_bbox (vertex_buffer_object &vb, const sector &a, const sector &b) 243 void draw_bbox (const sector &a, const sector &b)
244 { 244 {
245 static GLint verts[] = { 245 static vertex_buffer_object vb;
246 0x8000, 0x8004, 0x8006, 0x8002, // -x 246 static index_buffer_object ib;
247 0x8001, 0x8003, 0x8007, 0x8005, // +x 247
248 0x8000, 0x8001, 0x8005, 0x8004, // -y 248 point pa(a), pb(b);
249 0x8007, 0x8003, 0x8002, 0x8006, // +y 249
250 0x8000, 0x8002, 0x8003, 0x8001, // -z 250 vertex_v3f vd[] = {
251 0x8004, 0x8005, 0x8007, 0x8006, // +z 251 point (a.x, a.y, a.z),
252 0 252 point (b.x, a.y, a.z),
253 point (a.x, b.y, a.z),
254 point (b.x, b.y, a.z),
255 point (a.x, a.y, b.z),
256 point (b.x, a.y, b.z),
257 point (a.x, b.y, b.z),
258 point (b.x, b.y, b.z),
253 }; 259 };
254 260
255 point pa(a), pb(b); 261 if (!ib)
256
257 vector<vertex_v3f> vd;
258
259 for (GLint *v = verts; *v; v++)
260 { 262 {
261 GLint mask = *v; 263 static index_ushort verts[4*6] = {
262 264 0, 4, 6, 2, // -x
263 vd.push_back (point ( 265 1, 3, 7, 5, // +x
264 mask & 1 ? pb.x : pa.x, 266 0, 1, 5, 4, // -y
265 mask & 2 ? pb.y : pa.y, 267 7, 3, 2, 6, // +y
266 mask & 4 ? pb.z : pa.z 268 0, 2, 3, 1, // -z
269 4, 5, 7, 6, // +z
267 )); 270 };
271
272 ib.set (verts, 4*6, GL_STATIC_DRAW_ARB);
268 } 273 }
269 274
270 vb.set (vd, GL_STATIC_DRAW_ARB); 275 vb.set (vd, 8, GL_STREAM_DRAW_ARB);
276 vb.bind ();
271 vb.draw (GL_QUADS, 0, 6*4); 277 ib.draw (GL_QUADS, 0, 6*4);
272 } 278 }
273 279
274 int nesting; 280 int nesting;
275 281
276 void errchk (const char *name, const char *args, const char *file, int line) 282 void errchk (const char *name, const char *args, const char *file, int line)

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines