source: GTP/trunk/Lib/Vis/Preprocessing/src/GlRenderer.cpp @ 2023

Revision 2023, 35.4 KB checked in by mattausch, 17 years ago (diff)
  • Property svn:executable set to *
Line 
1#include "Mesh.h"
2#include "glInterface.h"
3#include "OcclusionQuery.h"
4#include "GlRenderer.h"
5#include "ViewCellsManager.h"
6#include "SceneGraph.h"
7#include "Pvs.h"
8#include "Viewcell.h"
9#include "Beam.h"
10#include "KdTree.h"
11#include "Environment.h"
12#include "Triangle3.h"
13#include "IntersectableWrapper.h"
14#include "BvHierarchy.h"
15#include "KdTree.h"
16
17#ifdef USE_CG
18
19#include <Cg/cg.h>
20#include <Cg/cgGL.h>
21
22#endif
23
24namespace GtpVisibilityPreprocessor {
25
26
27static bool arbQuerySupport = false;
28static bool nvQuerySupport = false;
29
30static GLuint frontDepthMap;
31static GLuint backDepthMap;
32
33const int depthMapSize = 512;
34
35static void InitExtensions()
36{
37        GLenum err = glewInit();
38
39        if (GLEW_OK != err)
40        {
41                // problem: glewInit failed, something is seriously wrong
42                cerr << "Error: " << glewGetErrorString(err) << endl;
43                exit(1);
44        }
45
46        if (GLEW_ARB_occlusion_query)
47                arbQuerySupport = true;
48       
49        if (GLEW_NV_occlusion_query)
50                nvQuerySupport = true;
51       
52
53        if  (!arbQuerySupport && !nvQuerySupport)
54        {
55                cout << "I require the GL_ARB_occlusion_query or the GL_NV_occlusion_query OpenGL extension to work.\n";
56                exit(1);
57        }
58}
59
60
61GlRenderer::GlRenderer(SceneGraph *sceneGraph,
62                                           ViewCellsManager *viewCellsManager,
63                                           KdTree *tree):
64  Renderer(sceneGraph, viewCellsManager),
65  mKdTree(tree)
66{
67  mSceneGraph->CollectObjects(&mObjects);
68
69  //  mViewCellsManager->GetViewPoint(mViewPoint);
70
71  viewCellsManager->GetViewPoint(mViewPoint);
72        //mSceneGraph->GetBox().Center();
73  mViewDirection = Vector3(0,0,1);
74
75  //  mViewPoint = Vector3(991.7, 187.8, -271);
76  //  mViewDirection = Vector3(0.9, 0, -0.4);
77
78  //  timerId = startTimer(10);
79  // debug coords for atlanta
80  //  mViewPoint = Vector3(3473, 6.778, -1699);
81  //  mViewDirection = Vector3(-0.2432, 0, 0.97);
82 
83  mFrame = 0;
84  mWireFrame = false;
85  Environment::GetSingleton()->GetBoolValue("Preprocessor.detectEmptyViewSpace",
86                                                                                        mDetectEmptyViewSpace);
87  mSnapErrorFrames = true;
88  mSnapPrefix = "snap/";
89  mUseForcedColors = false;
90  mRenderBoxes = false;
91  mUseGlLists = true;
92  //mUseGlLists = false;
93
94  Environment::GetSingleton()->GetIntValue("Preprocessor.pvsRenderErrorSamples", mPvsStatFrames);
95  mPvsErrorBuffer.resize(mPvsStatFrames);
96  ClearErrorBuffer();
97 
98}
99
100GlRenderer::~GlRenderer()
101{
102  cerr<<"gl renderer destructor..\n";
103 
104  //CLEAR_CONTAINER(sQueries);
105  CLEAR_CONTAINER(mOcclusionQueries);
106
107  cerr<<"done."<<endl;
108}
109
110
111void
112GlRenderer::RenderTriangle(TriangleIntersectable *object)
113{
114  Triangle3 &t = object->GetItem();
115 
116  glBegin(GL_TRIANGLES);
117  Vector3 normal = t.GetNormal();
118  glNormal3f(normal.x, normal.y, normal.z);
119  glVertex3f(t.mVertices[0].x, t.mVertices[0].y, t.mVertices[0].z);
120  glVertex3f(t.mVertices[1].x, t.mVertices[1].y, t.mVertices[1].z);
121  glVertex3f(t.mVertices[2].x, t.mVertices[2].y, t.mVertices[2].z);
122  glEnd();
123}
124
125void
126GlRenderer::RenderIntersectable(Intersectable *object)
127{
128  if (object->Mailed())
129        return;
130  object->Mail();
131 
132  glPushAttrib(GL_CURRENT_BIT);
133  if (mUseFalseColors)
134        SetupFalseColor(object->mId);
135 
136  switch (object->Type()) {
137  case Intersectable::MESH_INSTANCE:
138        RenderMeshInstance((MeshInstance *)object);
139        break;
140  case Intersectable::VIEW_CELL:
141        RenderViewCell(static_cast<ViewCell *>(object));
142        break;
143  case Intersectable::TRANSFORMED_MESH_INSTANCE:
144        RenderTransformedMeshInstance(static_cast<TransformedMeshInstance *>(object));
145        break;
146  case Intersectable::TRIANGLE_INTERSECTABLE:
147        RenderTriangle(static_cast<TriangleIntersectable *>(object));
148        break;
149  case Intersectable::BVH_INTERSECTABLE: {
150
151        BvhNode *node = static_cast<BvhNode *>(object);
152       
153        if (mRenderBoxes)
154          RenderBox(node->GetBoundingBox());
155        else
156          RenderBvhNode(node);
157        break;
158  }
159  case Intersectable::KD_INTERSECTABLE: {
160        KdNode *node = (static_cast<KdIntersectable *>(object))->GetItem();
161       
162        if (mRenderBoxes)
163          RenderBox(mKdTree->GetBox(node));
164        else
165          RenderKdNode(node);
166        break;
167  }
168       
169  default:
170        cerr<<"Rendering this object not yet implemented\n";
171        break;
172  }
173
174  glPopAttrib();
175}
176
177void
178GlRenderer::RenderRays(const VssRayContainer &rays)
179{
180  VssRayContainer::const_iterator it = rays.begin(), it_end = rays.end();
181
182  glBegin(GL_LINES);
183  for (; it != it_end; ++it) {
184        VssRay *ray = *it;
185        float importance = log10(1e3*ray->mWeightedPvsContribution)/3.0f;
186        //      cout<<"w="<<ray->mWeightedPvsContribution<<" r="<<ray->mWeightedPvsContribution;
187        glColor3f(importance, importance, importance);
188        glVertex3fv(&ray->mOrigin.x);
189        glVertex3fv(&ray->mTermination.x);
190  }
191  glEnd();
192}
193
194
195
196void
197GlRenderer::RenderViewCell(ViewCell *vc)
198{
199  if (vc->GetMesh()) {
200
201        if (!mUseFalseColors) {
202          if (vc->GetValid())
203                glColor3f(0,1,0);
204          else
205                glColor3f(0,0,1);
206        }
207       
208        RenderMesh(vc->GetMesh());
209  } else {
210        // render viewcells in the subtree
211        if (!vc->IsLeaf()) {
212          ViewCellInterior *vci = (ViewCellInterior *) vc;
213
214          ViewCellContainer::iterator it = vci->mChildren.begin();
215          for (; it != vci->mChildren.end(); ++it) {
216                RenderViewCell(*it);
217          }
218        } else {
219          //      cerr<<"Empty viewcell mesh\n";
220        }
221  }
222}
223
224
225void
226GlRenderer::RenderMeshInstance(MeshInstance *mi)
227{
228  RenderMesh(mi->GetMesh());
229}
230
231
232void
233GlRenderer::RenderTransformedMeshInstance(TransformedMeshInstance *mi)
234{
235        // apply world transform before rendering
236        Matrix4x4 m;
237        mi->GetWorldTransform(m);
238
239        glPushMatrix();
240/* cout << "\n";
241        for (int i = 0; i < 4; ++ i)
242                for (int j = 0; j < 4; ++ j)
243                        cout << m.x[i][j] << " "; cout << "\n"*/
244
245        glMultMatrixf((float *)m.x);
246
247        /*GLfloat dummy[16];
248        glGetFloatv(GL_MODELVIEW_MATRIX, dummy);
249        for (int i = 0; i < 16; ++ i)
250                cout << dummy[i] << " ";
251        cout << endl;*/
252        RenderMesh(mi->GetMesh());
253       
254        glPopMatrix();
255}
256
257
258void
259GlRenderer::SetupFalseColor(const unsigned int id)
260{
261        // swap bits of the color
262        glColor3ub(id&255, (id>>8)&255, (id>>16)&255);
263}
264
265
266unsigned int GlRenderer::GetId(const unsigned char r,
267                                                           const unsigned char g,
268                                                           const unsigned char b) const
269{
270        return r + (g << 8) + (b << 16);
271}
272
273
274void
275GlRenderer::SetupMaterial(Material *m)
276{
277  if (m)
278        glColor3fv(&(m->mDiffuseColor.r));
279}
280
281
282void
283GlRenderer::RenderMesh(Mesh *mesh)
284{
285  int i = 0;
286
287  if (!mUseFalseColors && !mUseForcedColors)
288          SetupMaterial(mesh->mMaterial);
289 
290  for (i=0; i < mesh->mFaces.size(); i++) {
291        if (mWireFrame)
292          glBegin(GL_LINE_LOOP);
293        else
294          glBegin(GL_POLYGON);
295
296        Face *face = mesh->mFaces[i];
297        for (int j = 0; j < face->mVertexIndices.size(); j++) {
298          glVertex3fv(&mesh->mVertices[face->mVertexIndices[j]].x);
299        }
300        glEnd();
301  }
302}
303       
304void
305GlRenderer::InitGL()
306{
307  mSphere = (GLUquadric *)gluNewQuadric();
308 
309  glMatrixMode(GL_PROJECTION);
310  glLoadIdentity();
311 
312  glMatrixMode(GL_MODELVIEW);
313  glLoadIdentity();
314
315  glFrontFace(GL_CCW);
316  glCullFace(GL_BACK);
317  glEnable(GL_CULL_FACE);
318  glShadeModel(GL_FLAT);
319  glDepthFunc( GL_LESS );
320  glEnable(GL_DEPTH_TEST);
321  glEnable(GL_CULL_FACE);
322 
323  InitExtensions();
324
325  glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE );
326
327  glEnable( GL_NORMALIZE );
328 
329  glClearColor(0.0f, 0.0f, 1.0f, 1.0f);
330 
331  OcclusionQuery::GenQueries(mOcclusionQueries, 10);
332}
333
334
335void
336GlRenderer::SetupProjection(const int w, const int h, const float angle)
337{
338  glViewport(0, 0, w, h);
339  glMatrixMode(GL_PROJECTION);
340  glLoadIdentity();
341  gluPerspective(angle, 1.0, 0.1, 2.0*Magnitude(mSceneGraph->GetBox().Diagonal()));
342  glMatrixMode(GL_MODELVIEW);
343}
344
345
346
347void
348GlRenderer::SetupCamera()
349{
350  Vector3 target = mViewPoint + mViewDirection;
351  //cout << "vp: " << mViewPoint << " dr: " << mViewDirection << endl;
352  //cout<<"box: " << mKdTree->GetBox()<<endl;
353  Vector3 up(0,1,0);
354 
355  if (abs(DotProd(mViewDirection, up)) > 0.99f)
356        up = Vector3(1, 0, 0);
357 
358  glLoadIdentity();
359  gluLookAt(mViewPoint.x, mViewPoint.y, mViewPoint.z,
360                        target.x, target.y, target.z,
361                        up.x, up.y, up.z);
362}
363
364void
365GlRenderer::_RenderScene()
366{
367  ObjectContainer::const_iterator oi = mObjects.begin();
368  for (; oi != mObjects.end(); oi++)
369        RenderIntersectable(*oi);
370}
371
372void
373GlRenderer::_RenderSceneTriangles()
374{
375  glBegin(GL_TRIANGLES);
376
377  ObjectContainer::const_iterator oi = mObjects.begin();
378  for (; oi != mObjects.end(); oi++) {
379       
380        if ((*oi)->Type() == Intersectable::TRIANGLE_INTERSECTABLE) {
381          TriangleIntersectable *object = (TriangleIntersectable *)*oi;
382          Triangle3 &t = object->GetItem();
383         
384          Vector3 normal = t.GetNormal();
385          glNormal3f(normal.x, normal.y, normal.z);
386          glVertex3f(t.mVertices[0].x, t.mVertices[0].y, t.mVertices[0].z);
387          glVertex3f(t.mVertices[1].x, t.mVertices[1].y, t.mVertices[1].z);
388          glVertex3f(t.mVertices[2].x, t.mVertices[2].y, t.mVertices[2].z);
389         
390        }
391  }
392
393  glEnd();
394 
395}
396
397bool
398GlRenderer::RenderScene()
399{
400  Intersectable::NewMail();
401  static int glList = -1;
402  if (mUseGlLists) {
403        if (glList == -1) {
404          glList = glGenLists(1);
405          glNewList(glList, GL_COMPILE);
406          _RenderSceneTriangles();
407          glEndList();
408        }
409       
410        glCallList(glList);
411  } else
412        _RenderSceneTriangles();
413       
414 
415  return true;
416}
417
418
419void
420GlRendererBuffer::EvalQueryWithItemBuffer(
421                                                                                  //RenderCostSample &sample
422                                                                           )
423{
424        // read back the texture
425        glReadPixels(0, 0,
426                                GetWidth(), GetHeight(),
427                                GL_RGBA,
428                                GL_UNSIGNED_BYTE,
429                                mPixelBuffer);
430               
431                       
432        unsigned int *p = mPixelBuffer;
433                       
434        for (int y = 0; y < GetHeight(); y++)
435        {
436                for (int x = 0; x < GetWidth(); x++, p++)
437                {
438                        unsigned int id = (*p) & 0xFFFFFF;
439
440                        if (id != 0xFFFFFF)
441                                ++ mObjects[id]->mCounter;
442                }
443        }
444}
445
446
447
448/****************************************************************/
449/*               GlRendererBuffer implementation                */
450/****************************************************************/
451
452
453
454GlRendererBuffer::GlRendererBuffer(SceneGraph *sceneGraph,
455                                                                   ViewCellsManager *viewcells,
456                                                                   KdTree *tree):
457GlRenderer(sceneGraph, viewcells, tree) 
458{
459 
460  mPixelBuffer = NULL;
461 
462  // implement width and height in subclasses
463}
464
465
466void
467GlRendererBuffer::EvalQueryWithOcclusionQueries(
468                                                                           //RenderCostSample &sample
469                                                                           )
470{
471        glDepthFunc(GL_LEQUAL);
472               
473        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
474        glDepthMask(GL_FALSE);
475
476
477        // simulate detectemptyviewspace using backface culling
478        if (mDetectEmptyViewSpace)
479        {
480                glEnable(GL_CULL_FACE);
481                //cout << "culling" << endl;
482        }
483        else
484        {
485                //cout << "not culling" << endl;
486                glDisable(GL_CULL_FACE);
487        }
488
489       
490        //const int numQ = 1;
491        const int numQ = (int)mOcclusionQueries.size();
492       
493        //glFinish();
494#if 0
495        //-- now issue queries for all objects
496        for (int j = 0; j < (int)mObjects.size(); ++ j)
497        {
498                mOcclusionQueries[j]->BeginQuery();
499                RenderIntersectable(mObjects[j]);
500                mOcclusionQueries[j]->EndQuery();
501
502                unsigned int pixelCount;
503
504                pixelCount = mOcclusionQueries[j]->GetQueryResult();
505                mObjects[j]->mCounter += pixelCount;
506        }
507#else
508
509        int q = 0;
510
511        //-- now issue queries for all objects
512        for (int j = 0; j < (int)mObjects.size(); j += q)
513        {       
514                for (q = 0; ((j + q) < (int)mObjects.size()) && (q < numQ); ++ q)
515                {
516                        //glFinish();
517                        mOcclusionQueries[q]->BeginQuery();
518                       
519                        RenderIntersectable(mObjects[j + q]);
520               
521                        mOcclusionQueries[q]->EndQuery();
522                        //glFinish();
523                }
524                //cout << "q: " << q << endl;
525                // collect results of the queries
526                for (int t = 0; t < q; ++ t)
527                {
528                        unsigned int pixelCount;
529               
530                        //-- reenable other state
531#if 0
532                        bool available;
533
534                        do
535                        {
536                                available = mOcclusionQueries[t]->ResultAvailable();
537                               
538                                if (!available) cout << "W";
539                        }
540                        while (!available);
541#endif
542
543                        pixelCount = mOcclusionQueries[t]->GetQueryResult();
544
545                        //if (pixelCount > 0)
546                        //      cout <<"o="<<j+q<<" q="<<mOcclusionQueries[q]->GetQueryId()<<" pc="<<pixelCount<<" ";
547                        mObjects[j + t]->mCounter += pixelCount;
548                }
549
550                //j += q;
551        }
552#endif
553        //glFinish();
554        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
555        glDepthMask(GL_TRUE);
556       
557        glEnable(GL_CULL_FACE);
558}
559
560
561void
562GlRenderer::RandomViewPoint()
563{
564  // do not use this function since it could return different viewpoints for
565  // different executions of the algorithm
566
567  //  mViewCellsManager->GetViewPoint(mViewPoint);
568
569  while (1) {
570        Vector3 pVector = Vector3(halton.GetNumber(1),
571                                                          halton.GetNumber(2),
572                                                          halton.GetNumber(3));
573       
574        mViewPoint =  mViewCellsManager->GetViewSpaceBox().GetPoint(pVector);
575        ViewCell *v = mViewCellsManager->GetViewCell(mViewPoint);
576        if (v && v->GetValid())
577          break;
578        // generate a new vector
579        halton.GenerateNext();
580  }
581 
582  Vector3 dVector = Vector3(2*M_PI*halton.GetNumber(4),
583                                                        M_PI*halton.GetNumber(5),
584                                                        0.0f);
585 
586  mViewDirection = Normalize(Vector3(sin(dVector.x),
587                                                                         //                                                                      cos(dVector.y),
588                                                                         0.0f,
589                                                                         cos(dVector.x)));
590  halton.GenerateNext();
591}
592
593
594void
595GlRenderer::RenderBox(const AxisAlignedBox3 &box)
596{
597
598  glBegin(GL_LINE_LOOP);
599  glVertex3d(box.Min().x, box.Max().y, box.Min().z );
600  glVertex3d(box.Max().x, box.Max().y, box.Min().z );
601  glVertex3d(box.Max().x, box.Min().y, box.Min().z );
602  glVertex3d(box.Min().x, box.Min().y, box.Min().z );
603  glEnd();
604
605  glBegin(GL_LINE_LOOP);
606  glVertex3d(box.Min().x, box.Min().y, box.Max().z );
607  glVertex3d(box.Max().x, box.Min().y, box.Max().z );
608  glVertex3d(box.Max().x, box.Max().y, box.Max().z );
609  glVertex3d(box.Min().x, box.Max().y, box.Max().z );
610  glEnd();
611
612  glBegin(GL_LINE_LOOP);
613  glVertex3d(box.Max().x, box.Min().y, box.Min().z );
614  glVertex3d(box.Max().x, box.Min().y, box.Max().z );
615  glVertex3d(box.Max().x, box.Max().y, box.Max().z );
616  glVertex3d(box.Max().x, box.Max().y, box.Min().z );
617  glEnd();
618
619  glBegin(GL_LINE_LOOP);
620  glVertex3d(box.Min().x, box.Min().y, box.Min().z );
621  glVertex3d(box.Min().x, box.Min().y, box.Max().z );
622  glVertex3d(box.Min().x, box.Max().y, box.Max().z );
623  glVertex3d(box.Min().x, box.Max().y, box.Min().z );
624  glEnd();
625
626  glBegin(GL_LINE_LOOP);
627  glVertex3d(box.Min().x, box.Min().y, box.Min().z );
628  glVertex3d(box.Max().x, box.Min().y, box.Min().z );
629  glVertex3d(box.Max().x, box.Min().y, box.Max().z );
630  glVertex3d(box.Min().x, box.Min().y, box.Max().z );
631  glEnd();
632
633  glBegin(GL_LINE_LOOP);
634  glVertex3d(box.Min().x, box.Max().y, box.Min().z );
635  glVertex3d(box.Max().x, box.Max().y, box.Min().z );
636  glVertex3d(box.Max().x, box.Max().y, box.Max().z );
637  glVertex3d(box.Min().x, box.Max().y, box.Max().z );
638
639  glEnd();
640
641}
642
643void
644GlRenderer::RenderBvhNode(BvhNode *node)
645{
646  if (node->IsLeaf()) {
647        BvhLeaf *leaf = (BvhLeaf *) node;
648
649#if 0
650        if (leaf->mGlList == 0) {
651          leaf->mGlList = glGenLists(1);
652          if (leaf->mGlList != 0)
653                glNewList(leaf->mGlList, GL_COMPILE);
654         
655          for (int i=0; i < leaf->mObjects.size(); i++)
656                RenderIntersectable(leaf->mObjects[i]);
657         
658          if (leaf->mGlList != 0)
659                glEndList();
660        }
661       
662        if (leaf->mGlList != 0)
663          glCallList(leaf->mGlList);
664#else
665        for (int i=0; i < leaf->mObjects.size(); i++)
666          RenderIntersectable(leaf->mObjects[i]);
667#endif
668  } else {
669        BvhInterior *in = (BvhInterior *)node;
670        RenderBvhNode(in->GetBack());
671        RenderBvhNode(in->GetFront());
672  }
673
674  //cout << "leaf obj " << i << endl;
675
676}
677
678void
679GlRenderer::RenderKdNode(KdNode *node)
680{
681  if (node->IsLeaf()) {
682        KdLeaf *leaf = (KdLeaf *) node;
683        for (int i=0; i < leaf->mObjects.size(); i++) {
684          RenderIntersectable(leaf->mObjects[i]);
685        }
686  } else {
687        KdInterior *in = (KdInterior *)node;
688        RenderKdNode(in->mBack);
689        RenderKdNode(in->mFront);
690  }
691 
692}
693
694
695
696
697
698
699
700void
701GlRendererBuffer::EvalRenderCostSample(RenderCostSample &sample,
702                                                                           const bool useOcclusionQueries,
703                                                                           const int threshold
704                                                                           )
705{
706  // choose a random view point
707  mViewCellsManager->GetViewPoint(mViewPoint);
708  sample.mPosition = mViewPoint;
709  //cout << "viewpoint: " << mViewPoint << endl;
710 
711  // take a render cost sample by rendering a cube
712  Vector3 directions[6];
713 
714  directions[0] = Vector3(1,0,0);
715  directions[1] = Vector3(0,1,0);
716  directions[2] = Vector3(0,0,1);
717  directions[3] = Vector3(-1,0,0);
718  directions[4] = Vector3(0,-1,0);
719  directions[5] = Vector3(0,0,-1);
720 
721  sample.mVisibleObjects = 0;
722 
723  // reset object counters
724  ObjectContainer::const_iterator it, it_end = mObjects.end();
725 
726  for (it = mObjects.begin(); it != it_end; ++ it)
727        {
728          (*it)->mCounter = 0;
729        }
730
731  ++ mFrame;
732 
733  //glCullFace(GL_FRONT);
734  glCullFace(GL_BACK);
735  glDisable(GL_CULL_FACE);
736 
737 
738        // query all 6 directions for a full point sample
739  for (int i = 0; i < 6; ++ i)
740        {
741          mViewDirection = directions[i];
742          SetupCamera();
743         
744          glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
745          glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
746          //glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);    glDepthMask(GL_TRUE);
747          glDepthFunc(GL_LESS);
748         
749          mUseFalseColors = true;
750         
751          // the actual scene rendering fills the depth (for occlusion queries)
752          // and the frame buffer (for item buffer)
753          RenderScene();
754         
755         
756          if (0)
757                {
758                  char filename[256];
759                  sprintf(filename, "snap/frame-%04d-%d.png", mFrame, i);
760                  //              QImage im = toImage();
761                  //              im.save(filename, "PNG");
762                }
763         
764          // evaluate the sample
765          if (useOcclusionQueries)
766                {
767                  EvalQueryWithOcclusionQueries();
768                }
769          else
770                {
771                  EvalQueryWithItemBuffer();
772                }
773        } 
774 
775  // now evaluate the statistics over that sample
776  // currently only the number of visible objects is taken into account
777  sample.Reset();
778 
779  for (it = mObjects.begin(); it != it_end; ++ it)
780        {
781          Intersectable *obj = *it;
782          if (obj->mCounter >= threshold)
783                {
784                  ++ sample.mVisibleObjects;
785                  sample.mVisiblePixels += obj->mCounter;
786                }
787        }
788 
789  //cout << "RS=" << sample.mVisibleObjects << " ";
790}
791
792
793GlRendererBuffer::~GlRendererBuffer()
794{
795#if 0
796#ifdef USE_CG
797        if (sCgFragmentProgram)
798                cgDestroyProgram(sCgFragmentProgram);
799        if (sCgContext)
800                cgDestroyContext(sCgContext);
801#endif
802#endif
803}
804
805
806void
807GlRendererBuffer::SampleRenderCost(const int numSamples,
808                                                                   vector<RenderCostSample> &samples,
809                                                                   const bool useOcclusionQueries,
810                                                                   const int threshold
811                                                                   )
812{
813  MakeCurrent();
814
815  if (mPixelBuffer == NULL)
816          mPixelBuffer = new unsigned int[GetWidth()*GetHeight()];
817 
818  // using 90 degree projection to capture 360 view with 6 samples
819  SetupProjection(GetHeight(), GetHeight(), 90.0f);
820
821  //samples.resize(numSamples);
822  halton.Reset();
823 
824  // the number of queries queried in batch mode
825  const int numQ = 500;
826
827  //const int numQ = (int)mObjects.size();
828  if (useOcclusionQueries)
829  {
830          cout << "\ngenerating " << numQ << " queries ... ";
831          OcclusionQuery::GenQueries(mOcclusionQueries, numQ);
832          cout << "finished" << endl;
833  }
834
835  // sampling queries
836  for (int i = 0; i < numSamples; ++ i)
837  {
838          cout << ".";
839          EvalRenderCostSample(samples[i], useOcclusionQueries, threshold);
840  }
841
842  DoneCurrent();
843}
844 
845
846
847
848
849void
850GlRenderer::ClearErrorBuffer()
851{
852  for (int i=0; i < mPvsStatFrames; i++) {
853        mPvsErrorBuffer[i].mError = 1.0f;
854  }
855  mPvsStat.maxError = 0.0f;
856}
857
858
859void
860GlRendererBuffer::EvalPvsStat()
861{
862cout<<"here15"<<endl;
863  MakeCurrent();
864
865  GlRenderer::EvalPvsStat();
866 
867  DoneCurrent();
868  cout<<"here185"<<endl;
869  //  mRenderingFinished.wakeAll();
870}
871
872
873void GlRendererBuffer::SampleBeamContributions(Intersectable *sourceObject,
874                                                                                           Beam &beam,
875                                                                                           const int desiredSamples,
876                                                                                           BeamSampleStatistics &stat)
877{
878        // TODO: should be moved out of here (not to be done every time)
879        // only back faces are interesting for the depth pass
880        glShadeModel(GL_FLAT);
881        glDisable(GL_LIGHTING);
882
883        // needed to kill the fragments for the front buffer
884        glEnable(GL_ALPHA_TEST);
885        glAlphaFunc(GL_GREATER, 0);
886
887        // assumes that the beam is constructed and contains kd-tree nodes
888        // and viewcells which it intersects
889 
890 
891        // Get the number of viewpoints to be sampled
892        // Now it is a sqrt but in general a wiser decision could be made.
893        // The less viewpoints the better for rendering performance, since less passes
894        // over the beam is needed.
895        // The viewpoints could actually be generated outside of the bounding box which
896        // would distribute the 'efective viewpoints' of the object surface and thus
897        // with a few viewpoints better sample the viewpoint space....
898
899        //TODO: comment in
900        //int viewPointSamples = sqrt((float)desiredSamples);
901        int viewPointSamples = max(desiredSamples / (GetWidth() * GetHeight()), 1);
902       
903        // the number of direction samples per pass is given by the number of viewpoints
904        int directionalSamples = desiredSamples / viewPointSamples;
905       
906        Debug << "directional samples: " << directionalSamples << endl;
907        for (int i = 0; i < viewPointSamples; ++ i)
908        {
909                Vector3 viewPoint = beam.mBox.GetRandomPoint();
910               
911                // perhaps the viewpoint should be shifted back a little bit so that it always lies
912                // inside the source object
913                // 'ideally' the viewpoints would be distributed on the soureObject surface, but this
914        // would require more complicated sampling (perhaps hierarchical rejection sampling of
915                // the object surface is an option here - only the mesh faces which are inside the box
916                // are considered as candidates)
917               
918                SampleViewpointContributions(sourceObject,
919                                                                         viewPoint,
920                                                                         beam,
921                                                                         directionalSamples,
922                                                                         stat);
923        }
924
925
926        // note:
927        // this routine would be called only if the number of desired samples is sufficiently
928        // large - for other rss tree cells the cpu based sampling is perhaps more efficient
929        // distributing the work between cpu and gpu would also allow us to place more sophisticated
930        // sample distributions (silhouette ones) using the cpu and the jittered once on the GPU
931        // in order that thios scheme is working well the gpu render buffer should run in a separate
932        // thread than the cpu sampler, which would not be such a big problem....
933
934        // disable alpha test again
935        glDisable(GL_ALPHA_TEST);
936}
937
938
939
940void GlRendererBuffer::SampleViewpointContributions(Intersectable *sourceObject,
941                                                                                                        const Vector3 viewPoint,
942                                                                                                        Beam &beam,
943                                                                                                        const int samples,
944                                                    BeamSampleStatistics &stat)
945{
946    // 1. setup the view port to match the desired samples
947        glViewport(0, 0, samples, samples);
948
949        // 2. setup the projection matrix and view matrix to match the viewpoint + beam.mDirBox
950        SetupProjectionForViewPoint(viewPoint, beam, sourceObject);
951
952
953        // 3. reset z-buffer to 0 and render the source object for the beam
954        //    with glCullFace(Enabled) and glFrontFace(GL_CW)
955        //    save result to the front depth map
956        //    the front depth map holds ray origins
957
958
959        // front depth buffer must be initialised to 0
960        float clearDepth;
961       
962        glGetFloatv(GL_DEPTH_CLEAR_VALUE, &clearDepth);
963        glClearDepth(0.0f);
964        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);
965
966
967        // glFrontFace(GL_CCW);
968        glEnable(GL_CULL_FACE);
969        glCullFace(GL_FRONT);
970        glColorMask(0, 0, 0, 0);
971       
972
973        // stencil is increased where the source object is located
974        glEnable(GL_STENCIL_TEST);     
975        glStencilFunc(GL_ALWAYS, 0x1, 0x1);
976        glStencilOp(GL_REPLACE, GL_REPLACE, GL_REPLACE);
977
978
979#if 0
980        static int glSourceObjList = -1;         
981        if (glSourceObjList != -1)
982        {
983                glSourceObjList = glGenLists(1);
984                glNewList(glSourceObjList, GL_COMPILE);
985
986                RenderIntersectable(sourceObject);
987       
988                glEndList();
989        }
990        glCallList(glSourceObjList);
991
992#else
993        RenderIntersectable(sourceObject);
994
995#endif 
996
997         // copy contents of the front depth buffer into depth texture
998        glBindTexture(GL_TEXTURE_2D, frontDepthMap);   
999        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, depthMapSize, depthMapSize);
1000
1001        // reset clear function
1002        glClearDepth(clearDepth);
1003       
1004       
1005        // 4. set up the termination depth buffer (= standard depth buffer)
1006        //    only rays which have non-zero entry in the origin buffer are valid since
1007        //    they realy start on the object surface (this is tagged by setting a
1008        //    stencil buffer bit at step 3).
1009       
1010        glStencilFunc(GL_EQUAL, 0x1, 0x1);
1011        glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
1012
1013        glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1014        glDepthMask(1);
1015
1016        glEnable(GL_DEPTH_TEST);
1017               
1018        glEnable(GL_CULL_FACE);
1019        glCullFace(GL_BACK);
1020
1021        // setup front depth buffer
1022        glEnable(GL_TEXTURE_2D);
1023       
1024#if 0
1025#ifdef USE_CG
1026        // bind pixel shader implementing the front depth buffer functionality
1027        cgGLBindProgram(sCgFragmentProgram);
1028        cgGLEnableProfile(sCgFragmentProfile);
1029#endif
1030#endif
1031        // 5. render all objects inside the beam
1032        //    we can use id based false color to read them back for gaining the pvs
1033
1034        glColorMask(1, 1, 1, 1);
1035
1036       
1037        // if objects not stored in beam => extract objects
1038        if (beam.mFlags & !Beam::STORE_OBJECTS)
1039        {
1040                vector<KdNode *>::const_iterator it, it_end = beam.mKdNodes.end();
1041
1042                Intersectable::NewMail();
1043                for (it = beam.mKdNodes.begin(); it != it_end; ++ it)
1044                {
1045                        mKdTree->CollectObjects(*it, beam.mObjects);
1046                }
1047        }
1048
1049
1050        //    (objects can be compiled to a gl list now so that subsequent rendering for
1051        //    this beam is fast - the same hold for step 3)
1052        //    Afterwards we have two depth buffers defining the ray origin and termination
1053       
1054
1055#if 0
1056        static int glObjList = -1;
1057        if (glObjList != -1)
1058        {
1059                glObjList = glGenLists(1);
1060                glNewList(glObjList, GL_COMPILE);
1061       
1062                ObjectContainer::const_iterator it, it_end = beam.mObjects.end();
1063                for (it = beam.mObjects.begin(); it != it_end; ++ it)
1064                {
1065                        // render all objects except the source object
1066                        if (*it != sourceObject)
1067                                RenderIntersectable(*it);
1068                }
1069               
1070                glEndList();
1071        }
1072
1073        glCallList(glObjList);
1074#else
1075        ObjectContainer::const_iterator it, it_end = beam.mObjects.end();
1076        for (it = beam.mObjects.begin(); it != it_end; ++ it)
1077        {       
1078                // render all objects except the source object
1079                if (*it != sourceObject)
1080                        RenderIntersectable(*it);
1081        }
1082#endif
1083       
1084        // 6. Use occlusion queries for all viewcell meshes associated with the beam ->
1085        //     a fragment passes if the corresponding stencil fragment is set and its depth is
1086        //     between origin and termination buffer
1087
1088        // create new queries if necessary
1089        OcclusionQuery::GenQueries(mOcclusionQueries, (int)beam.mViewCells.size());
1090
1091        // check whether any backfacing polygon would pass the depth test?
1092        // matt: should check both back /front facing because of dual depth buffer
1093        // and danger of cutting the near plane with front facing polys.
1094       
1095        glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
1096        glDepthMask(GL_FALSE);
1097        glDisable(GL_CULL_FACE);
1098
1099 
1100        ViewCellContainer::const_iterator vit, vit_end = beam.mViewCells.end();
1101
1102        int queryIdx = 0;
1103
1104        for (vit = beam.mViewCells.begin(); vit != vit_end; ++ vit)
1105        {
1106                mOcclusionQueries[queryIdx ++]->BeginQuery();
1107
1108                RenderIntersectable(*vit);
1109               
1110                mOcclusionQueries[queryIdx]->EndQuery();
1111
1112                ++ queryIdx;
1113        }
1114
1115        // at this point, if possible, go and do some other computation
1116
1117        // 7. The number of visible pixels is the number of sample rays which see the source
1118        //    object from the corresponding viewcell -> remember these values for later update
1119        //   of the viewcell pvs - or update immediately?
1120
1121        queryIdx = 0;
1122
1123        for (vit = beam.mViewCells.begin(); vit != vit_end; ++ vit)
1124        {
1125                // fetch queries
1126                unsigned int pixelCount = mOcclusionQueries[queryIdx ++]->GetQueryResult();
1127
1128                if (pixelCount)
1129                        Debug << "view cell " << (*vit)->GetId() << " visible pixels: " << pixelCount << endl;
1130        }
1131       
1132
1133        // 8. Copmpute rendering statistics
1134        // In general it is not neccessary to remember to extract all the rays cast. I hope it
1135        // would be sufficient to gain only the intergral statistics about the new contributions
1136        // and so the rss tree would actually store no new rays (only the initial ones)
1137        // the subdivision of the tree would only be driven by the statistics (the glrender could
1138        // evaluate the contribution entropy for example)
1139        // However might be an option to extract/store only those the rays which made a contribution
1140        // (new viewcell has been discovered) or relative contribution greater than a threshold ...
1141
1142        ObjectContainer pvsObj;
1143        stat.pvsSize = ComputePvs(beam.mObjects, pvsObj);
1144       
1145        // to gain ray source and termination
1146        // copy contents of ray termination buffer into depth texture
1147        // and compare with ray source buffer
1148#if 0
1149        VssRayContainer rays;
1150
1151        glBindTexture(GL_TEXTURE_2D, backDepthMap);     
1152        glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, depthMapSize, depthMapSize);
1153
1154        ComputeRays(Intersectable *sourceObj, rays);
1155
1156#endif
1157
1158        ////////
1159        //-- cleanup
1160
1161        // reset gl state
1162        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
1163        glDepthMask(GL_TRUE);
1164        glEnable(GL_CULL_FACE);
1165        glDisable(GL_STENCIL_TEST);
1166
1167#if 0
1168#ifdef USE_CG
1169        cgGLDisableProfile(sCgFragmentProfile);
1170#endif
1171#endif
1172
1173        glDisable(GL_TEXTURE_2D);
1174
1175        // remove objects from beam
1176        if (beam.mFlags & !Beam::STORE_OBJECTS)
1177                beam.mObjects.clear();
1178}
1179
1180
1181void GlRendererBuffer::SetupProjectionForViewPoint(const Vector3 &viewPoint,
1182                                                                                                   const Beam &beam,
1183                                                                                                   Intersectable *sourceObject)
1184{
1185        float left, right, bottom, top, znear, zfar;
1186
1187        beam.ComputePerspectiveFrustum(left, right, bottom, top, znear, zfar,
1188                                                                   mSceneGraph->GetBox());
1189
1190        //Debug << left << " " << right << " " << bottom << " " << top << " " << znear << " " << zfar << endl;
1191        glMatrixMode(GL_PROJECTION);
1192        glLoadIdentity();
1193        glFrustum(left, right, bottom, top, znear, zfar);
1194        //glFrustum(-1, 1, -1, 1, 1, 20000);
1195
1196    const Vector3 center = viewPoint + beam.GetMainDirection() * (zfar - znear) * 0.3f;
1197        const Vector3 up =
1198                Normalize(CrossProd(beam.mPlanes[0].mNormal, beam.mPlanes[4].mNormal));
1199
1200#ifdef GTP_DEBUG
1201        Debug << "view point: " << viewPoint << endl;
1202        Debug << "eye: " << center << endl;
1203        Debug << "up: " << up << endl;
1204#endif
1205
1206        glMatrixMode(GL_MODELVIEW);
1207        glLoadIdentity();
1208        gluLookAt(viewPoint.x, viewPoint.y, viewPoint.z,
1209                          center.x, center.y, center.z,                   
1210                          up.x, up.y, up.z);
1211}               
1212
1213 
1214void GlRendererBuffer::InitGL()
1215{
1216        MakeCurrent();
1217        GlRenderer::InitGL();
1218
1219        // initialise dual depth buffer textures
1220        glGenTextures(1, &frontDepthMap);
1221        glBindTexture(GL_TEXTURE_2D, frontDepthMap);
1222       
1223        glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, depthMapSize,
1224                                 depthMapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
1225
1226        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1227        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1228        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1229        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1230
1231        glGenTextures(1, &backDepthMap);
1232        glBindTexture(GL_TEXTURE_2D, backDepthMap);
1233       
1234        glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT, depthMapSize,
1235                                 depthMapSize, 0, GL_DEPTH_COMPONENT, GL_UNSIGNED_BYTE, NULL);
1236        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
1237        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
1238        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
1239        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
1240
1241#if 0
1242#ifdef USE_CG
1243
1244        // cg initialization
1245        cgSetErrorCallback(handleCgError);
1246        sCgContext = cgCreateContext();
1247       
1248        if (cgGLIsProfileSupported(CG_PROFILE_ARBFP1))
1249                sCgFragmentProfile = CG_PROFILE_ARBFP1;
1250        else
1251        {
1252          // try FP30
1253          if (cgGLIsProfileSupported(CG_PROFILE_FP30))
1254            sCgFragmentProfile = CG_PROFILE_FP30;
1255          else
1256          {
1257                  Debug << "Neither arbfp1 or fp30 fragment profiles supported on this system" << endl;
1258                  exit(1);
1259          }
1260  }
1261
1262 sCgFragmentProgram = cgCreateProgramFromFile(sCgContext,
1263                                                                                           CG_SOURCE, "../src/dual_depth.cg",
1264                                                                                           sCgFragmentProfile,
1265                                                                                           NULL,
1266                                                                                           NULL);
1267
1268  if (!cgIsProgramCompiled(sCgFragmentProgram))
1269          cgCompileProgram(sCgFragmentProgram);
1270
1271  cgGLLoadProgram(sCgFragmentProgram);
1272  cgGLBindProgram(sCgFragmentProgram);
1273
1274  Debug << "---- PROGRAM BEGIN ----\n" <<
1275          cgGetProgramString(sCgFragmentProgram, CG_COMPILED_PROGRAM) << "---- PROGRAM END ----\n";
1276
1277#endif
1278
1279#endif
1280  DoneCurrent();
1281}
1282
1283
1284void GlRendererBuffer::ComputeRays(Intersectable *sourceObj, VssRayContainer &rays)
1285{
1286        for (int i = 0; i < depthMapSize * depthMapSize; ++ i)
1287        {
1288                //todo glGetTexImage()
1289        }
1290}
1291
1292bool GlRendererBuffer::ValidViewPoint()
1293{       cout << "here49" << endl;
1294        /*MakeCurrent();
1295
1296        bool result = GlRenderer::ValidViewPoint();
1297        DoneCurrent();
1298*/bool result = true;
1299        return result;
1300}
1301
1302
1303void
1304GlRenderer::EvalPvsStat()
1305{
1306cout <<"here3399"<<endl;
1307  mPvsStat.Reset();
1308  halton.Reset();
1309
1310  SetupProjection(GetWidth(), GetHeight());
1311
1312  cout<<"mPvsStatFrames="<<mPvsStatFrames<<endl;
1313 
1314  for (int i=0; i < mPvsStatFrames; i++) {
1315        float err;
1316        // set frame id for saving the error buffer
1317        mFrame = i;
1318        RandomViewPoint();
1319
1320        if (mPvsErrorBuffer[i].mError == 1.0f) {
1321          // check if the view point is valid
1322          if (!ValidViewPoint())
1323                mPvsErrorBuffer[i].mError = -1.0f;
1324
1325          // manualy corrected view point
1326          if (mFrame == 5105)
1327                mPvsErrorBuffer[i].mError = -1.0f;
1328        }
1329       
1330       
1331        // atlanta problematic frames: 325 525 691 1543
1332#if 0
1333        if (mFrame != 325 &&
1334                mFrame != 525 &&
1335                mFrame != 691 &&
1336                mFrame != 1543)
1337          mPvsErrorBuffer[i] = -1;
1338        else {
1339          Debug<<"frame ="<<mFrame<<" vp="<<mViewPoint<<" vd="<<mViewDirection<<endl;
1340        }
1341#endif
1342       
1343        if (mPvsErrorBuffer[i].mError > 0.0f) {
1344          int pvsSize;
1345         
1346          float error = GetPixelError(pvsSize);
1347          mPvsErrorBuffer[i].mError = error;
1348          mPvsErrorBuffer[i].mPvsSize = pvsSize;
1349
1350          //      emit UpdatePvsErrorItem(i,
1351          //                                                      mPvsErrorBuffer[i]);
1352          cout<<"("<<i<<","<<mPvsErrorBuffer[i].mError<<")";
1353          //      swapBuffers();
1354        }
1355       
1356        err = mPvsErrorBuffer[i].mError;
1357       
1358        if (err >= 0.0f) {
1359          if (err > mPvsStat.maxError)
1360                mPvsStat.maxError = err;
1361          mPvsStat.sumError += err;
1362          mPvsStat.sumPvsSize += mPvsErrorBuffer[i].mPvsSize;
1363         
1364          if (err == 0.0f)
1365                mPvsStat.errorFreeFrames++;
1366          mPvsStat.frames++;
1367        }
1368  }
1369 
1370  glFinish();
1371  cout<<endl<<flush;
1372}
1373
1374bool
1375GlRenderer::ValidViewPoint()
1376{
1377  if (!mDetectEmptyViewSpace)
1378        return true;
1379
1380  OcclusionQuery *query = mOcclusionQueries[0];
1381
1382  // now check whether any backfacing polygon would pass the depth test
1383  SetupCamera();
1384  glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
1385  glEnable( GL_CULL_FACE );
1386  glCullFace(GL_BACK);
1387 
1388  //cout<<"VV1 ";
1389  RenderScene();
1390 
1391  glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
1392  glDepthMask(GL_FALSE);
1393  glDisable( GL_CULL_FACE );
1394 
1395  query->BeginQuery();
1396 
1397  //  cout<<"VV2 ";
1398  RenderScene();
1399  //  cout<<"VV3 ";
1400 
1401  query->EndQuery();
1402 
1403  // at this point, if possible, go and do some other computation
1404  glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
1405  glDepthMask(GL_TRUE);
1406  glEnable( GL_CULL_FACE );
1407
1408  //  int wait = 0;
1409  //  while (!query.ResultAvailable()) {
1410  //    wait++;
1411  //  }
1412 
1413  // reenable other state
1414  unsigned int pixelCount = query->GetQueryResult();
1415  //  cout<<"VV4 ";
1416 
1417  if (pixelCount > 0)
1418  {cout<<"count: " << pixelCount<<endl;
1419        return false; // backfacing polygon found -> not a valid viewspace sample
1420  }
1421  return true;
1422}
1423
1424float
1425GlRenderer::GetPixelError(int &pvsSize)
1426{
1427  return -1.0f;
1428}
1429
1430void
1431GlRenderer::RenderViewPoint()
1432{
1433  mWireFrame = true;
1434  glPushMatrix();
1435  glTranslatef(mViewPoint.x, mViewPoint.y, mViewPoint.z);
1436  glScalef(5.0f,5.0f,5.0f);
1437  glPushAttrib(GL_CURRENT_BIT);
1438  glColor3f(1.0f, 0.0f, 0.0f);
1439  gluSphere((::GLUquadric *)mSphere,
1440                        1e-3*Magnitude(mViewCellsManager->GetViewSpaceBox().Size()), 6, 6);
1441  glPopAttrib();
1442  glPopMatrix();
1443  mWireFrame = false;
1444}
1445
1446
1447
1448
1449
1450}
Note: See TracBrowser for help on using the repository browser.